LoginSecurityTestBase.php in Login Security 2.x
File
tests/src/Functional/LoginSecurityTestBase.php
View source
<?php
namespace Drupal\Tests\login_security\Functional;
use Drupal\Tests\BrowserTestBase;
abstract class LoginSecurityTestBase extends BrowserTestBase {
const ADMIN_SETTINGS_PATH = 'admin/config/people/login_security';
public static $modules = [
'login_security',
];
protected $defaultTheme = 'stark';
public function setUp() {
parent::setUp();
\Drupal::database()
->query('TRUNCATE TABLE {login_security_track}');
\Drupal::database()
->query('TRUNCATE TABLE {ban_ip}');
\Drupal::configFactory()
->getEditable('login_security.settings')
->set('track_time', 1)
->save();
}
protected function getAdminUserSettingsFields() {
return [
'track_time',
'user_wrong_count',
'host_wrong_count',
'host_wrong_count_hard',
'notice_attempts_available',
'notice_attempts_message',
'host_soft_banned',
'host_hard_banned',
'user_blocked',
'user_blocked_notification_emails',
'user_blocked_email_subject',
'user_blocked_email_body',
'last_login_timestamp',
'last_access_timestamp',
'login_activity_notification_emails',
'login_activity_email_subject',
'login_activity_email_body',
'activity_threshold',
];
}
protected function drupalLoginLite($user) {
if ($this
->drupalUserIsLoggedIn($user)) {
$this
->drupalLogout();
}
$edit = [
'name' => $user
->getAccountName(),
'pass' => $user
->getPassword(),
];
$this
->drupalPostForm('user', $edit, $this
->t('Log in'));
$this
->assertResponse(200, $this
->t('Login page reloaded.'));
$this->loggedInUser = TRUE;
}
}