Commit 2d105716 authored by alexpott's avatar alexpott

Issue #2102539 by andypost: Fixed Current user service should be updated in...

Issue #2102539 by andypost: Fixed Current user service should be updated in drupalLogin() and drupalLogout().
parent 63d02738
......@@ -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.');
}
}
......
......@@ -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());
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment