function TestDatabase::lastTestGet
Same name in other branches
- 8.9.x core/lib/Drupal/Core/Test/TestDatabase.php \Drupal\Core\Test\TestDatabase::lastTestGet()
Get information about the last test that ran given a test ID.
@internal
Parameters
int $test_id: The test ID to get the last test from.
Return value
array Associative array containing the last database prefix used and the last test class that ran.
File
-
core/
lib/ Drupal/ Core/ Test/ TestDatabase.php, line 254
Class
- TestDatabase
- Provides helper methods for interacting with the fixture database.
Namespace
Drupal\Core\TestCode
public static function lastTestGet($test_id) {
$connection = static::getConnection();
// Define a subquery to identify the latest 'message_id' given the
// $test_id.
$max_message_id_subquery = $connection->select('simpletest', 'sub')
->condition('test_id', $test_id);
$max_message_id_subquery->addExpression('MAX([message_id])', 'max_message_id');
// Run a select query to return 'last_prefix' from {simpletest_test_id} and
// 'test_class' from {simpletest}.
$select = $connection->select($max_message_id_subquery, 'st_sub');
$select->join('simpletest', 'st', '[st].[message_id] = [st_sub].[max_message_id]');
$select->join('simpletest_test_id', 'sttid', '[st].[test_id] = [sttid].[test_id]');
$select->addField('sttid', 'last_prefix');
$select->addField('st', 'test_class');
return $select->execute()
->fetchAssoc();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.