You are here

public function CustomHookCheckTest::testHooksInAnotherModule in Nagios Monitoring 8

File

tests/src/Kernel/CustomHookCheckTest.php, line 36

Class

CustomHookCheckTest
Tests if external module's hook is executed

Namespace

Drupal\Tests\nagios\Kernel

Code

public function testHooksInAnotherModule() {
  $results = nagios_invoke_all();
  $expected = [
    'status' => 1,
    'type' => 'state',
    'text' => 'Text description for the problem',
  ];
  self::assertSame($expected, $results["nagios_hook_test_module"]['NAGIOS_CHECK_KEY']);
  $config = \Drupal::configFactory()
    ->getEditable('nagios.settings');
  $config
    ->set('nagios.enable.nagios_hook_test_module', 0);
  $config
    ->save();
  $results = nagios_invoke_all();

  /** @noinspection PhpUnitTestsInspection */
  self::assertTrue(empty($results['nagios_hook_test_module']));
}