public function MonitoringCoreWebTest::testNonExistingUserFailedLoginSensorPlugin in Monitoring 8
Tests the non existing user failed login sensor.
File
- tests/
src/ Functional/ MonitoringCoreWebTest.php, line 428
Class
- MonitoringCoreWebTest
- Integration tests for the core pieces of monitoring.
Namespace
Drupal\Tests\monitoring\FunctionalCode
public function testNonExistingUserFailedLoginSensorPlugin() {
// Insert a failed login event.
\Drupal::database()
->insert('watchdog')
->fields(array(
'type' => 'user',
'message' => 'Login attempt failed from %ip.',
'variables' => serialize([
'%ip' => '127.0.0.1',
]),
'location' => 'http://example.com/user/login',
'timestamp' => \Drupal::time()
->getRequestTime(),
))
->execute();
// Check the verbose sensor result.
$this
->drupalLogin($this->rootUser);
$this
->drupalGet('admin/reports/monitoring/sensors/user_void_failed_logins');
$rows = $this
->getSession()
->getPage()
->findAll('css', '#unaggregated_result tbody tr');
$this
->assertEquals(1, count($rows), 'Found 1 results in table');
$this
->assertSession()
->elementTextContains('css', '#unaggregated_result tbody tr:nth-child(1) td:nth-child(2)', 'Login attempt failed from 127.0.0.1');
}