public static function TestDatabase::lastTestGet in Drupal 8
Same name and namespace in other branches
- 9 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.
2 calls to TestDatabase::lastTestGet()
- simpletest_last_test_get in core/
modules/ simpletest/ simpletest.module - Get information about the last test that ran given a test ID.
- _simpletest_batch_finished in core/
modules/ simpletest/ simpletest.module - Implements callback_batch_finished().
File
- core/
lib/ Drupal/ Core/ Test/ TestDatabase.php, line 252
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();
}