public function LoginSecurityUserBlockingTest::testLoginMessage in Login Security 8
Test login message.
File
- src/
Tests/ LoginSecurityUserBlockingTest.php, line 262
Class
- LoginSecurityUserBlockingTest
- Test Login Security's user-blocking restrictions and default messages.
Namespace
Drupal\login_security\TestsCode
public function testLoginMessage() {
$config = \Drupal::configFactory()
->getEditable('login_security.settings');
$normal_user = $this
->drupalCreateUser();
$config
->set('last_login_timestamp', 1)
->save();
$config
->set('last_access_timestamp', 1)
->save();
$this
->drupalLogin($normal_user);
// This is the very first login ever, so there should be no previous login
// to show.
$this
->assertNoTextLastLoginMessage();
$config
->set('last_login_timestamp', 0)
->save();
$config
->set('last_access_timestamp', 0)
->save();
$this
->drupalLogin($normal_user);
$this
->assertNoTextLastLoginMessage();
$this
->assertNoTextLastPageAccess();
$config
->set('last_login_timestamp', 1)
->save();
$this
->drupalLogin($normal_user);
$this
->assertTextLastLoginMessage();
$this
->assertNoTextLastPageAccess();
$config
->set('last_login_timestamp', 0)
->save();
$config
->set('last_access_timestamp', 1)
->save();
$this
->drupalLogin($normal_user);
$this
->assertNoTextLastLoginMessage();
$this
->assertTextLastPageAccess();
$config
->set('last_login_timestamp', 1)
->save();
$this
->drupalLogin($normal_user);
$this
->assertTextLastLoginMessage();
$this
->assertTextLastPageAccess();
}