diff --git a/core/modules/simpletest/src/TestBase.php b/core/modules/simpletest/src/TestBase.php index 021de93..dd583f5 100644 --- a/core/modules/simpletest/src/TestBase.php +++ b/core/modules/simpletest/src/TestBase.php @@ -1047,7 +1047,7 @@ private function prepareEnvironment() { // it will be associated with a different session-name. After the test-run // it can be safely destroyed. // @see TestBase::restoreEnvironment() - if (PHP_SAPI != 'cli' && session_status() == PHP_SESSION_ACTIVE) { + if (PHP_SAPI !== 'cli' && session_status() === PHP_SESSION_ACTIVE) { session_write_close(); } $this->originalSessionName = session_name(); @@ -1168,7 +1168,7 @@ protected function tearDown() { private function restoreEnvironment() { // Destroy the session if one was started during the test-run. $_SESSION = array(); - if (PHP_SAPI != 'cli' && session_status() == PHP_SESSION_ACTIVE) { + if (PHP_SAPI !== 'cli' && session_status() === PHP_SESSION_ACTIVE) { session_destroy(); $params = session_get_cookie_params(); setcookie(session_name(), '', REQUEST_TIME - 3600, $params['path'], $params['domain'], $params['secure'], $params['httponly']); diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php index 4ddce53..cd4991d 100644 --- a/core/modules/simpletest/src/WebTestBase.php +++ b/core/modules/simpletest/src/WebTestBase.php @@ -786,7 +786,7 @@ protected function drupalLogout() { } /** - * Return the session name in use on the child site. + * Returns the session name in use on the child site. * * @return string * The name of the session cookie. @@ -826,8 +826,10 @@ protected function setUp() { 'pass_raw' => $this->randomName(), )); - // The simpletest child site currently uses the same session name as the - // execution environment. + // Some tests (SessionTest and SessionHttpsTest) need to examine whether the + // proper session cookies were set on a response. Because the child site + // uses the same session name as the test runner, it is necessary to make + // that available to test-methods. // @todo: Introduce a setting such that the session name can be customized // for the child site. $this->session_name = $this->originalSessionName; diff --git a/core/modules/system/src/Tests/Session/SessionTest.php b/core/modules/system/src/Tests/Session/SessionTest.php index c64d1ad..47ef4b3 100644 --- a/core/modules/system/src/Tests/Session/SessionTest.php +++ b/core/modules/system/src/Tests/Session/SessionTest.php @@ -260,7 +260,7 @@ function testEmptySessionID() { // be valid. Closing the curl handler will stop the previous session ID // from persisting. $this->curlClose(); - $this->additionalCurlOptions[CURLOPT_COOKIE] = rawurlencode($this->session_name) . '=;'; + $this->additionalCurlOptions[CURLOPT_COOKIE] = rawurlencode($this->getSessionName()) . '=;'; $this->drupalGet('session-test/id-from-cookie'); $this->assertRaw("session_id:\n", 'Session ID is blank as sent from cookie header.'); // Assert that we have an anonymous session now.