diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php index d6a2968..4edd715 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php @@ -1164,6 +1164,8 @@ private function restoreEnvironment() { $_SESSION = array(); 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']); } session_name($this->originalSessionName); @@ -1533,15 +1535,4 @@ public function copyConfig(StorageInterface $source_storage, StorageInterface $t $target_storage->write($name, $source_storage->read($name)); } } - - /** - * Return the session name in use on the child site. - * - * @return string - * The name of the session cookie. - */ - public function sessionName() { - return $this->originalSessionName; - } - } diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 9078a1c..9bf4c87 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -777,6 +777,16 @@ protected function drupalLogout() { } /** + * Return the session name in use on the child site. + * + * @return string + * The name of the session cookie. + */ + public function getSessionName() { + return $this->session_name; + } + + /** * Sets up a Drupal site for running functional and integration tests. * * Installs Drupal with the installation profile specified in @@ -807,6 +817,12 @@ protected function setUp() { 'pass_raw' => $this->randomName(), )); + // The simpletest child site currently uses the same session name as the + // execution environment. + // @todo: Introduce a setting such that the session name can be customized + // for the child site. + $this->session_name = $this->originalSessionName; + // Reset the static batch to remove Simpletest's batch operations. $batch = &batch_get(); $batch = array(); @@ -1223,9 +1239,6 @@ protected function curlInitialize() { if (!$result) { throw new \UnexpectedValueException('One or more cURL options could not be set.'); } - - // By default, the child session name should be the same as the parent. - $this->session_name = $this->sessionName(); } // We set the user agent header on each request so as to use the current // time and a new uniqid. diff --git a/core/modules/system/lib/Drupal/system/Tests/Session/SessionHttpsTest.php b/core/modules/system/lib/Drupal/system/Tests/Session/SessionHttpsTest.php index d9d641b..cc753b6 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Session/SessionHttpsTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Session/SessionHttpsTest.php @@ -40,12 +40,12 @@ public function setUp() { protected function testHttpsSession() { if ($this->request->isSecure()) { - $secure_session_name = $this->sessionName(); - $insecure_session_name = substr($this->sessionName(), 1); + $secure_session_name = $this->getSessionName(); + $insecure_session_name = substr($this->getSessionName(), 1); } else { - $secure_session_name = 'S' . $this->sessionName(); - $insecure_session_name = $this->sessionName(); + $secure_session_name = 'S' . $this->getSessionName(); + $insecure_session_name = $this->getSessionName(); } $user = $this->drupalCreateUser(array('access administration pages')); @@ -124,8 +124,8 @@ protected function testMixedModeSslSession() { return; } else { - $secure_session_name = 'S' . $this->sessionName(); - $insecure_session_name = $this->sessionName(); + $secure_session_name = 'S' . $this->getSessionName(); + $insecure_session_name = $this->getSessionName(); } // Enable secure pages. @@ -231,12 +231,12 @@ protected function testMixedModeSslSession() { */ protected function testCsrfTokenWithMixedModeSsl() { if ($this->request->isSecure()) { - $secure_session_name = $this->sessionName(); - $insecure_session_name = substr($this->sessionName(), 1); + $secure_session_name = $this->getSessionName(); + $insecure_session_name = substr($this->getSessionName(), 1); } else { - $secure_session_name = 'S' . $this->sessionName(); - $insecure_session_name = $this->sessionName(); + $secure_session_name = 'S' . $this->getSessionName(); + $insecure_session_name = $this->getSessionName(); } // Enable mixed mode SSL.