You are here

public function WatchdogCheckTest::testFilter in Nagios Monitoring 8

File

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

Class

WatchdogCheckTest
Tests the functionality to report dblog/watchdog entries.

Namespace

Drupal\Tests\nagios\Kernel

Code

public function testFilter() {
  $config = \Drupal::configFactory()
    ->getEditable('nagios.settings');
  $config
    ->set('nagios.limit_watchdog.channel_filter', [
    'onion',
  ]);
  $config
    ->set('nagios.limit_watchdog.negate', FALSE);
  $config
    ->save();
  $this
    ->getLogger('onion')
    ->error('error');
  $this
    ->getLogger('garlic')
    ->error('error');
  $expected = [
    'status' => NAGIOS_STATUS_CRITICAL,
    'type' => 'state',
    'text' => 'garlic error',
  ];
  self::expectWatchdog($expected);
  $config
    ->set('nagios.limit_watchdog.negate', TRUE);
  $config
    ->save();
  $expected = [
    'status' => NAGIOS_STATUS_CRITICAL,
    'type' => 'state',
    'text' => 'onion error',
  ];
  self::expectWatchdog($expected);
}