You are here

public function WatchdogCheckTest::testWithLevelError in Nagios Monitoring 8

File

tests/src/Kernel/WatchdogCheckTest.php, line 114

Class

WatchdogCheckTest
Tests the functionality to report dblog/watchdog entries.

Namespace

Drupal\Tests\nagios\Kernel

Code

public function testWithLevelError() {
  $config = \Drupal::configFactory()
    ->getEditable('nagios.settings');
  $config
    ->set('nagios.min_report_severity', NAGIOS_STATUS_CRITICAL);
  $config
    ->save();
  $this
    ->getLogger('test')
    ->info('info');
  $this
    ->assertAllGreen();
  $this
    ->getLogger('test')
    ->warning('warning');
  $this
    ->assertAllGreen();
  $this
    ->getLogger('test')
    ->error('error');
  $expected = [
    'status' => NAGIOS_STATUS_CRITICAL,
    'type' => 'state',
    'text' => 'test error',
  ];
  self::expectWatchdog($expected);
}