You are here

public function MonitoringPastTest::testPastSensors in Monitoring 8

Tests the sensors that monitors past events.

File

tests/src/Kernel/MonitoringPastTest.php, line 37
Contains \Drupal\Tests\monitoring\Kernel\MonitoringPastTest.

Class

MonitoringPastTest
Tests for the past sensors in monitoring.

Namespace

Drupal\Tests\monitoring\Kernel

Code

public function testPastSensors() {

  // Creates dummy events for testing.
  $this
    ->createEvents();

  // Run each sensor and test output.
  $result = $this
    ->runSensor('past_db_critical');
  $this
    ->assertEqual($result
    ->getMessage(), '3 events in 1 day');
  $result = $this
    ->runSensor('past_db_debug');
  $this
    ->assertEqual($result
    ->getMessage(), '2 events in 1 day');
  $result = $this
    ->runSensor('past_db_emergency');
  $this
    ->assertEqual($result
    ->getMessage(), '3 events in 1 day');
  $result = $this
    ->runSensor('past_db_error');
  $this
    ->assertEqual($result
    ->getMessage(), '3 events in 1 day');
  $result = $this
    ->runSensor('past_db_info');
  $this
    ->assertEqual($result
    ->getMessage(), '2 events in 1 day');
  $result = $this
    ->runSensor('past_db_notice');
  $this
    ->assertEqual($result
    ->getMessage(), '2 events in 1 day');
  $result = $this
    ->runSensor('past_db_warning');
  $this
    ->assertEqual($result
    ->getMessage(), '3 events in 1 day');
}