function ShutdownFunctionsTest::testShutdownFunctions
Same name in other branches
- 7.x modules/system/system.test \ShutdownFunctionsTest::testShutdownFunctions()
- 9 core/modules/system/tests/src/Functional/System/ShutdownFunctionsTest.php \Drupal\Tests\system\Functional\System\ShutdownFunctionsTest::testShutdownFunctions()
- 10 core/modules/system/tests/src/Functional/System/ShutdownFunctionsTest.php \Drupal\Tests\system\Functional\System\ShutdownFunctionsTest::testShutdownFunctions()
- 11.x core/modules/system/tests/src/Functional/System/ShutdownFunctionsTest.php \Drupal\Tests\system\Functional\System\ShutdownFunctionsTest::testShutdownFunctions()
Test shutdown functions.
File
-
core/
modules/ system/ tests/ src/ Functional/ System/ ShutdownFunctionsTest.php, line 37
Class
- ShutdownFunctionsTest
- Functional tests shutdown functions.
Namespace
Drupal\Tests\system\Functional\SystemCode
public function testShutdownFunctions() {
$arg1 = $this->randomMachineName();
$arg2 = $this->randomMachineName();
$this->drupalGet('system-test/shutdown-functions/' . $arg1 . '/' . $arg2);
// If using PHP-FPM then fastcgi_finish_request() will have been fired
// returning the response before shutdown functions have fired.
// @see \Drupal\system_test\Controller\SystemTestController::shutdownFunctions()
$server_using_fastcgi = strpos($this->getSession()
->getPage()
->getContent(), 'The function fastcgi_finish_request exists when serving the request.');
if ($server_using_fastcgi) {
// We need to wait to ensure that the shutdown functions have fired.
sleep(1);
}
$this->assertEqual(\Drupal::state()->get('_system_test_first_shutdown_function'), [
$arg1,
$arg2,
]);
$this->assertEqual(\Drupal::state()->get('_system_test_second_shutdown_function'), [
$arg1,
$arg2,
]);
if (!$server_using_fastcgi) {
// Make sure exceptions displayed through
// \Drupal\Core\Utility\Error::renderExceptionSafe() are correctly
// escaped.
$this->assertRaw('Drupal is <blink>awesome</blink>.');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.