Mercurial > hg > isophonics-drupal-site
comparison core/tests/Drupal/FunctionalTests/UserHelpersTest.php @ 18:af1871eacc83
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:33:08 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
17:129ea1e6d783 | 18:af1871eacc83 |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\FunctionalTests; | |
4 | |
5 use Drupal\Tests\BrowserTestBase; | |
6 | |
7 /** | |
8 * Tests User related helper methods of WebTestBase. | |
9 * | |
10 * @group browsertestbase | |
11 */ | |
12 class UserHelpersTest extends BrowserTestBase { | |
13 | |
14 /** | |
15 * Tests WebTestBase::drupalUserIsLoggedIn(). | |
16 */ | |
17 public function testDrupalUserIsLoggedIn() { | |
18 $first_user = $this->drupalCreateUser(); | |
19 $second_user = $this->drupalCreateUser(); | |
20 | |
21 // After logging in, the first user should be logged in, the second not. | |
22 $this->drupalLogin($first_user); | |
23 $this->assertTrue($this->drupalUserIsLoggedIn($first_user)); | |
24 $this->assertFalse($this->drupalUserIsLoggedIn($second_user)); | |
25 | |
26 // Verify that logged in state is retained across pages. | |
27 $this->drupalGet(''); | |
28 $this->assertTrue($this->drupalUserIsLoggedIn($first_user)); | |
29 $this->assertFalse($this->drupalUserIsLoggedIn($second_user)); | |
30 | |
31 // After logging out, both users should be logged out. | |
32 $this->drupalLogout(); | |
33 $this->assertFalse($this->drupalUserIsLoggedIn($first_user)); | |
34 $this->assertFalse($this->drupalUserIsLoggedIn($second_user)); | |
35 | |
36 // After logging back in, the second user should still be logged out. | |
37 $this->drupalLogin($first_user); | |
38 $this->assertTrue($this->drupalUserIsLoggedIn($first_user)); | |
39 $this->assertFalse($this->drupalUserIsLoggedIn($second_user)); | |
40 | |
41 // After logging in the second user, the first one should be logged out. | |
42 $this->drupalLogin($second_user); | |
43 $this->assertTrue($this->drupalUserIsLoggedIn($second_user)); | |
44 $this->assertFalse($this->drupalUserIsLoggedIn($first_user)); | |
45 | |
46 // After logging out, both should be logged out. | |
47 $this->drupalLogout(); | |
48 $this->assertFalse($this->drupalUserIsLoggedIn($first_user)); | |
49 $this->assertFalse($this->drupalUserIsLoggedIn($second_user)); | |
50 } | |
51 | |
52 } |