public function LoginHistoryTest::testLoginHistory in Login History 8
Test Login History.
File
- tests/
src/ Functional/ LoginHistoryTest.php, line 74
Class
- LoginHistoryTest
- Tests Login History functionality.
Namespace
Drupal\Tests\login_history\FunctionalCode
public function testLoginHistory() {
// Verify we can successfully access the Login history page.
$this
->drupalLogin($this->adminUser);
$this
->drupalGet('admin/reports/login-history');
$this
->assertResponse(200);
// Verify the Login history page has the table.
$this
->assertText('Date');
$this
->assertText('Username');
$this
->assertText('IP Address');
$this
->assertText('One-time login?');
$this
->assertText('User Agent');
// Verify the Last Login block is on the home page.
$this
->drupalGet('<front>');
$this
->assertText('You last logged in from');
// Verify the link is in the block.
$this
->clickLink($this
->t('View your login history'));
// Verify the Login History tab is reachable.
$this
->drupalGet('user/' . $this->adminUser
->id() . '/login-history');
$this
->assertResponse(200);
$this
->drupalLogout();
// Verify the Authenticated User
// cannot go to the admin page,
// doesn't see the block,
// doesn't have the Login History tab in their user profile.
$this
->drupalLogin($this->authenticatedUser);
$this
->drupalGet('admin/reports/login-history');
$this
->assertSession()
->statusCodeNotEquals(200);
$this
->drupalGet('<front>');
$this
->assertNoText('You last logged in from');
$this
->drupalGet('user/' . $this->authenticatedUser
->id() . '/login-history');
$this
->assertResponse(403);
$this
->drupalLogout();
}