LoginSecurityTestBase.php in Login Security 8
File
src/Tests/LoginSecurityTestBase.php
View source
<?php
namespace Drupal\login_security\Tests;
use Drupal\simpletest\WebTestBase;
abstract class LoginSecurityTestBase extends WebTestBase {
const ADMIN_SETTINGS_PATH = 'admin/config/people/login_security';
public static $modules = [
'login_security',
];
public function setUp() {
parent::setUp();
db_query("TRUNCATE TABLE {login_security_track}");
db_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, t('Log in'));
$this
->assertResponse(200, t('Login page reloaded.'));
$this->loggedInUser = TRUE;
}
}