diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php index 11de754..180c58f 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php @@ -54,7 +54,6 @@ function setUp() { * Test the internal browsers functionality. */ function testInternalBrowser() { - global $conf; if (!$this->inCURL()) { // Retrieve the test page and check its title and headers. $this->drupalGet('test-page'); @@ -64,8 +63,11 @@ function testInternalBrowser() { ))); $this->assertNoTitle('Foo'); + $old_user_id = $this->container->get('current_user')->id(); $user = $this->drupalCreateUser(); $this->drupalLogin($user); + // Check that current user service updated. + $this->assertNotEqual($old_user_id, $this->container->get('current_user')->id(), 'Current user service updated.'); $headers = $this->drupalGetHeaders(TRUE); $this->assertEqual(count($headers), 2, 'There was one intermediate request.'); $this->assertTrue(strpos($headers[0][':status'], '302') !== FALSE, 'Intermediate response code was 302.'); @@ -76,6 +78,8 @@ function testInternalBrowser() { // Test the maximum redirection option. $this->drupalLogout(); + // Check that current user service updated to anonymous user. + $this->assertEqual(0, $this->container->get('current_user')->id(), 'Current user service updated.'); $edit = array( 'name' => $user->getUsername(), 'pass' => $user->pass_raw @@ -94,7 +98,6 @@ function testInternalBrowser() { global $base_url; $this->drupalGet(url($base_url . '/core/install.php', array('external' => TRUE, 'absolute' => TRUE))); $this->assertResponse(403, 'Cannot access install.php.'); - } } diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 300430a..a064d01 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -639,6 +639,7 @@ protected function drupalLogin(AccountInterface $account) { $pass = $this->assert($this->drupalUserIsLoggedIn($account), format_string('User %name successfully logged in.', array('%name' => $account->getUsername())), 'User login'); if ($pass) { $this->loggedInUser = $account; + $this->container->set('current_user', $account); } } @@ -682,6 +683,7 @@ protected function drupalLogout() { // @see WebTestBase::drupalUserIsLoggedIn() unset($this->loggedInUser->session_id); $this->loggedInUser = FALSE; + $this->container->set('current_user', drupal_anonymous_user()); } }