function _simpletest_batch_finished

Same name in other branches
  1. 7.x modules/simpletest/simpletest.module \_simpletest_batch_finished()

Implements callback_batch_finished().

1 call to _simpletest_batch_finished()
TestDeprecatedTestHooks::testHookTestGroupFinished in core/modules/simpletest/tests/src/Kernel/TestDeprecatedTestHooks.php
@expectedDeprecation The deprecated hook hook_test_group_finished() is implemented in these functions: simpletest_deprecation_test_test_group_finished(). Convert your test to a PHPUnit-based one and implement test listeners. Seeā€¦
1 string reference to '_simpletest_batch_finished'
simpletest_run_tests in core/modules/simpletest/simpletest.module
Runs tests.

File

core/modules/simpletest/simpletest.module, line 400

Code

function _simpletest_batch_finished($success, $results, $operations, $elapsed) {
    if ($success) {
        \Drupal::messenger()->addStatus(t('The test run finished in @elapsed.', [
            '@elapsed' => $elapsed,
        ]));
    }
    else {
        // Use the test_id passed as a parameter to _simpletest_batch_operation().
        $test_id = $operations[0][1][1];
        // Retrieve the last database prefix used for testing and the last test
        // class that was run from. Use the information to read the lgo file
        // in case any fatal errors caused the test to crash.
        $last_test = TestDatabase::lastTestGet($test_id);
        (new TestDatabase($last_test['last_prefix']))->logRead($test_id, $last_test['test_class']);
        \Drupal::messenger()->addError(t('The test run did not successfully finish.'));
        \Drupal::messenger()->addWarning(t('Use the <em>Clean environment</em> button to clean-up temporary files and tables.'));
    }
    \Drupal::moduleHandler()->invokeAllDeprecated('Convert your test to a PHPUnit-based one and implement test listeners. See https://www.drupal.org/node/2934242', 'test_group_finished');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.