X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fsystem%2Ftests%2Fsrc%2FFunctional%2FSystem%2FShutdownFunctionsTest.php;fp=web%2Fcore%2Fmodules%2Fsystem%2Ftests%2Fsrc%2FFunctional%2FSystem%2FShutdownFunctionsTest.php;h=f5d55be7822a04f9b79fa21c1a420abc8a6f30ad;hp=0000000000000000000000000000000000000000;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/modules/system/tests/src/Functional/System/ShutdownFunctionsTest.php b/web/core/modules/system/tests/src/Functional/System/ShutdownFunctionsTest.php new file mode 100644 index 000000000..f5d55be78 --- /dev/null +++ b/web/core/modules/system/tests/src/Functional/System/ShutdownFunctionsTest.php @@ -0,0 +1,56 @@ +siteDirectory . '/error.log'); + parent::tearDown(); + } + + /** + * Test shutdown functions. + */ + 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>.'); + } + } + +}