getRawCommands(); $this->assertCount(173, $commands); $this->assertTrue(in_array('SCHEDULE_SERVICEGROUP_SVC_DOWNTIME', $commands)); $this->assertTrue(in_array('SCHEDULE_SVC_CHECK', $commands)); $this->assertTrue(in_array('ENABLE_HOSTGROUP_SVC_CHECKS', $commands)); $this->assertTrue(in_array('PROCESS_HOST_CHECK_RESULT', $commands)); $this->assertTrue(in_array('ACKNOWLEDGE_SVC_PROBLEM', $commands)); $this->assertTrue(in_array('ACKNOWLEDGE_HOST_PROBLEM', $commands)); $this->assertTrue(in_array('SCHEDULE_FORCED_SVC_CHECK', $commands)); $this->assertTrue(in_array('DISABLE_FLAP_DETECTION', $commands)); } public function testRawCommands2() { $meta = new Meta(); $categories = $meta->getRawCategories(); $this->assertCount(7, $categories); $this->assertEquals( array( 'comment', 'contact', 'global', 'host', 'hostgroup', 'service', 'servicegroup' ), $categories ); } public function testRawCommands3() { $meta = new Meta(); $this->assertCount(9, $meta->getRawCommandsForCategory('hostgroup')); $this->assertCount(14, $meta->getRawCommandsForCategory('servicegroup')); $test1 = $meta->getRawCommandsForCategory('global'); $this->count(26, $test1); $this->assertTrue(in_array('DISABLE_NOTIFICATIONS', $test1)); $this->assertTrue(in_array('RESTART_PROCESS', $test1)); $this->assertTrue(in_array('ENABLE_FLAP_DETECTION', $test1)); $this->assertTrue(in_array('PROCESS_FILE', $test1)); } /** * @expectedException Icinga\Exception\ProgrammingError * @expectedExceptionMessage Category does not exists: DOES_NOT_EXIST */ public function testRawCommands4() { $meta = new Meta(); $meta->getRawCommandsForCategory('DOES_NOT_EXIST'); } public function testObjectForCommand1() { $meta = new Meta(); $object = new HostStruct(); $commands = $meta->getCommandForObject($object, Meta::TYPE_SMALL); $this->assertEquals(3, $commands[0]->id); $this->assertEquals(27, $commands[1]->id); $object->host_state = '0'; $commands = $meta->getCommandForObject($object, Meta::TYPE_SMALL); $this->assertEquals(3, $commands[0]->id); $this->assertFalse(isset($commands[1])); // STATE IS OK AGAIN $object->host_state = '1'; $object->host_acknowledged = '0'; $commands = $meta->getCommandForObject($object, Meta::TYPE_SMALL); $this->assertEquals(3, $commands[0]->id); $this->assertEquals(26, $commands[1]->id); } public function testObjectForCommand2() { $meta = new Meta(); $object = new HostStruct(); $object->host_obsessing = '0'; $object->host_flap_detection_enabled = '0'; $object->host_active_checks_enabled = '0'; $commands = $meta->getCommandForObject($object, Meta::TYPE_FULL); $this->assertEquals(2, $commands[0]->id); $this->assertEquals(6, $commands[3]->id); } /** * @expectedException Icinga\Exception\ProgrammingError * @expectedExceptionMessage Type has no commands defined: UNKNOWN */ public function testObjectForCommand3() { $meta = new Meta(); $test = new \stdClass(); $test->UNKNOWN_state = '2'; $test->UNKNOWN_flap_detection_enabled = '1'; $commands = $meta->getCommandForObject($test, Meta::TYPE_FULL); } }