You are here

public function MonitoringCoreKernelTest::testDatabaseAggregatorSensorPluginUserLogout in Monitoring 8

Tests user logouts through db aggregator sensor.

See also

\Drupal\monitoring\Plugin\monitoring\SensorPlugin\DatabaseAggregatorSensorPlugin

File

tests/src/Kernel/MonitoringCoreKernelTest.php, line 593

Class

MonitoringCoreKernelTest
Kernel tests for the core pieces of monitoring.

Namespace

Drupal\Tests\monitoring\Kernel

Code

public function testDatabaseAggregatorSensorPluginUserLogout() {

  // Fake some logout dblog records.
  \Drupal::logger('user')
    ->notice('Session closed for %name.', array(
    '%user' => 'user1',
  ));
  \Drupal::logger('user')
    ->notice('Session closed for %name.', array(
    '%user' => 'user1',
  ));
  \Drupal::logger('user')
    ->notice('Session closed for %name.', array(
    '%user' => 'user2',
  ));

  // Run sensor and test the output.
  $result = $this
    ->runSensor('user_session_logouts');
  $this
    ->assertEqual($result
    ->getValue(), 3);
  $this
    ->assertEqual($result
    ->getMessage(), '3 logouts in 1 day');
}