public function LoginSecurityUserBlockingTest::testDrupalErrorToggle in Login Security 8
Test disable core login error toggle.
File
- src/
Tests/ LoginSecurityUserBlockingTest.php, line 224
Class
- LoginSecurityUserBlockingTest
- Test Login Security's user-blocking restrictions and default messages.
Namespace
Drupal\login_security\TestsCode
public function testDrupalErrorToggle() {
$config = \Drupal::configFactory()
->getEditable('login_security.settings');
$normal_user = $this
->drupalCreateUser();
// Intentionally break the password to repeat invalid logins.
$new_pass = user_password();
$normal_user
->setPassword($new_pass);
$config
->set('disable_core_login_error', 0)
->save();
$this
->drupalLoginLite($normal_user);
$this
->assertRaw($this
->getDefaultDrupalLoginErrorMessage(), 'Drupal "...Have you forgotten your password?" login error message found.');
// Block user.
$normal_user->status
->setValue(0);
$normal_user
->save();
$this
->drupalLoginLite($normal_user);
$this
->assertRaw($this
->getDefaultDrupalBlockedUserErrorMessage($normal_user
->getAccountName()), 'Drupal "...has not been activated or is blocked." login error message found.');
$config
->set('disable_core_login_error', 1)
->save();
// Unblock user.
$normal_user->status
->setValue(1);
$normal_user
->save();
$this
->drupalLoginLite($normal_user);
$this
->assertNoRaw($this
->getDefaultDrupalLoginErrorMessage(), 'Drupal "...Have you forgotten your password?" login error message NOT found.');
// Block user.
$normal_user->status
->setValue(0);
$normal_user
->save();
$this
->drupalLoginLite($normal_user);
$this
->assertNoRaw($this
->getDefaultDrupalBlockedUserErrorMessage($normal_user
->getAccountName()), 'Drupal "...has not been activated or is blocked." login error message NOT found.');
}