Beispiel #1
0
 public function testGetList()
 {
     $testResult = array(array('host_id' => '2', 'host_template_model_htm_id' => '1', 'command_command_id' => null, 'command_command_id_arg1' => null, 'timeperiod_tp_id' => null, 'timeperiod_tp_id2' => null, 'command_command_id2' => null, 'command_command_id_arg2' => null, 'host_name' => 'Host 1', 'host_alias' => 'Host 1', 'host_address' => '192.168.1.1', 'display_name' => 'Host 1', 'host_max_check_attempts' => null, 'host_check_interval' => null, 'host_retry_check_interval' => null, 'host_active_checks_enabled' => null, 'host_passive_checks_enabled' => null, 'host_checks_enabled' => null, 'initial_state' => null, 'host_obsess_over_host' => null, 'host_check_freshness' => null, 'host_freshness_threshold' => null, 'host_event_handler_enabled' => null, 'host_low_flap_threshold' => null, 'host_high_flap_threshold' => null, 'host_flap_detection_enabled' => null, 'flap_detection_options' => null, 'host_process_perf_data' => null, 'host_retain_status_information' => null, 'host_retain_nonstatus_information' => null, 'host_notification_interval' => null, 'host_notification_options' => null, 'host_notifications_enabled' => null, 'contact_additive_inheritance' => '0', 'cg_additive_inheritance' => '0', 'host_first_notification_delay' => null, 'host_snmp_community' => null, 'host_snmp_version' => null, 'host_location' => '0', 'host_comment' => 'First host', 'host_register' => '1', 'host_activate' => '1', 'organization_id' => 1, 'environment_id' => null), array('host_id' => '3', 'host_template_model_htm_id' => '1', 'command_command_id' => null, 'command_command_id_arg1' => '3!4', 'timeperiod_tp_id' => null, 'timeperiod_tp_id2' => null, 'command_command_id2' => null, 'command_command_id_arg2' => '70!80', 'host_name' => 'Host 2', 'host_alias' => 'Host 2', 'host_address' => '192.168.1.2', 'display_name' => 'Host 2', 'host_max_check_attempts' => null, 'host_check_interval' => null, 'host_retry_check_interval' => null, 'host_active_checks_enabled' => null, 'host_passive_checks_enabled' => '0', 'host_checks_enabled' => null, 'initial_state' => null, 'host_obsess_over_host' => null, 'host_check_freshness' => null, 'host_freshness_threshold' => null, 'host_event_handler_enabled' => null, 'host_low_flap_threshold' => null, 'host_high_flap_threshold' => null, 'host_flap_detection_enabled' => null, 'flap_detection_options' => null, 'host_process_perf_data' => null, 'host_retain_status_information' => null, 'host_retain_nonstatus_information' => null, 'host_notification_interval' => null, 'host_notification_options' => null, 'host_notifications_enabled' => null, 'contact_additive_inheritance' => '0', 'cg_additive_inheritance' => '0', 'host_first_notification_delay' => null, 'host_snmp_community' => null, 'host_snmp_version' => null, 'host_location' => '0', 'host_comment' => 'Second host', 'host_register' => '1', 'host_activate' => '1', 'organization_id' => 1, 'environment_id' => null));
     $result = Host::getList();
     $this->assertEquals($testResult, $result);
     $testResult = array(array('host_id' => '2', 'host_template_model_htm_id' => '1', 'command_command_id' => null, 'command_command_id_arg1' => null, 'timeperiod_tp_id' => null, 'timeperiod_tp_id2' => null, 'command_command_id2' => null, 'command_command_id_arg2' => null, 'host_name' => 'Host 1', 'host_alias' => 'Host 1', 'host_address' => '192.168.1.1', 'display_name' => 'Host 1', 'host_max_check_attempts' => null, 'host_check_interval' => null, 'host_retry_check_interval' => null, 'host_active_checks_enabled' => null, 'host_passive_checks_enabled' => null, 'host_checks_enabled' => null, 'initial_state' => null, 'host_obsess_over_host' => null, 'host_check_freshness' => null, 'host_freshness_threshold' => null, 'host_event_handler_enabled' => null, 'host_low_flap_threshold' => null, 'host_high_flap_threshold' => null, 'host_flap_detection_enabled' => null, 'flap_detection_options' => null, 'host_process_perf_data' => null, 'host_retain_status_information' => null, 'host_retain_nonstatus_information' => null, 'host_notification_interval' => null, 'host_notification_options' => null, 'host_notifications_enabled' => null, 'contact_additive_inheritance' => '0', 'cg_additive_inheritance' => '0', 'host_first_notification_delay' => null, 'host_snmp_community' => null, 'host_snmp_version' => null, 'host_location' => '0', 'host_comment' => 'First host', 'host_register' => '1', 'host_activate' => '1', 'organization_id' => 1, 'environment_id' => null));
     $result = Host::getList('*', 1);
     $this->assertEquals($testResult, $result);
     $testResult = array(array('host_id' => '3', 'host_template_model_htm_id' => '1', 'command_command_id' => null, 'command_command_id_arg1' => '3!4', 'timeperiod_tp_id' => null, 'timeperiod_tp_id2' => null, 'command_command_id2' => null, 'command_command_id_arg2' => '70!80', 'host_name' => 'Host 2', 'host_alias' => 'Host 2', 'host_address' => '192.168.1.2', 'display_name' => 'Host 2', 'host_max_check_attempts' => null, 'host_check_interval' => null, 'host_retry_check_interval' => null, 'host_active_checks_enabled' => null, 'host_passive_checks_enabled' => '0', 'host_checks_enabled' => null, 'initial_state' => null, 'host_obsess_over_host' => null, 'host_check_freshness' => null, 'host_freshness_threshold' => null, 'host_event_handler_enabled' => null, 'host_low_flap_threshold' => null, 'host_high_flap_threshold' => null, 'host_flap_detection_enabled' => null, 'flap_detection_options' => null, 'host_process_perf_data' => null, 'host_retain_status_information' => null, 'host_retain_nonstatus_information' => null, 'host_notification_interval' => null, 'host_notification_options' => null, 'host_notifications_enabled' => null, 'contact_additive_inheritance' => '0', 'cg_additive_inheritance' => '0', 'host_first_notification_delay' => null, 'host_snmp_community' => null, 'host_snmp_version' => null, 'host_location' => '0', 'host_comment' => 'Second host', 'host_register' => '1', 'host_activate' => '1', 'organization_id' => 1, 'environment_id' => null));
     $result = Host::getList('*', 1, 1);
     $this->assertEquals($testResult, $result);
     $testResult = array(array('host_name' => 'Host 1'), array('host_name' => 'Host 2'));
     $result = Host::getList('host_name');
     $this->assertEquals($testResult, $result);
     $testResult = array(array('host_name' => 'Host 1', 'host_id' => 2), array('host_name' => 'Host 2', 'host_id' => 3));
     $result = Host::getList(array('host_name', 'host_id'));
     $this->assertEquals($testResult, $result);
     $testResult = array(array('host_name' => 'Host 2'), array('host_name' => 'Host 1'));
     $result = Host::getList('host_name', -1, 0, 'host_name', 'DESC');
     $this->assertEquals($testResult, $result);
     $testResult = array(array('host_name' => 'Host 1'));
     $result = Host::getList('host_name', -1, 0, null, 'ASC', array('host_name' => 'Host 1'));
     $this->assertEquals($testResult, $result);
     $testResult = array(array('host_name' => 'Host 1'), array('host_name' => 'Host 2'));
     $result = Host::getList('host_name', -1, 0, null, 'ASC', array('host_name' => array('Host 1', 'Host 2')));
     $this->assertEquals($testResult, $result);
     $this->setExpectedException('\\Centreon\\Internal\\Exception', "Unknown filter type", 0);
     Host::getList('host_name', -1, 0, null, 'ASC', array('host_name' => array('Host 1', 'Host 2')), 'ERR');
 }