Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Commit

Permalink
Add tests fo get entities by tag
Browse files Browse the repository at this point in the history
  • Loading branch information
David Durieux committed Sep 2, 2015
1 parent 2c6f00d commit a1c54b5
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 6 deletions.
12 changes: 6 additions & 6 deletions phpunit/2_Integration/ConfigDifferentItemtypesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,28 +137,28 @@ public function testGenerateHostsConfig() {
'active_checks_enabled' => 1,
'passive_checks_enabled' => 1,
'check_period' => '24x7',
'check_freshness' => '',
'check_freshness' => 0,
'freshness_threshold' => 0,
'event_handler_enabled' => 1,
'realm' => 'All',
'business_impact' => 3,
'notes' => 'Comment,,comment::',
'process_perf_data' => 1,
'flap_detection_enabled' => '',
'flap_detection_enabled' => 0,
'flap_detection_options' => 'o',
'low_flap_threshold' => 25,
'high_flap_threshold' => 50,
'failure_prediction_enabled' => '',
'retain_status_information' => '',
'retain_nonstatus_information' => '',
'failure_prediction_enabled' => 0,
'retain_status_information' => 0,
'retain_nonstatus_information' => 0,
'notes_url' => '',
'action_url' => '',
'icon_image' => '',
'icon_image_alt' => '',
'vrml_image' => '',
'statusmap_image' => '',
'contacts' => '',
'notifications_enabled' => '',
'notifications_enabled' => 0,
'notification_period' => '24x7',
'notification_options' => 'd,u,r,f,s',
'notification_interval' => 86400
Expand Down
114 changes: 114 additions & 0 deletions phpunit/2_Integration/EntitiesByTagTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?php

class EntitiesByTagTest extends RestoreDatabase_TestCase {

/**
* @test
*/
public function test2Entities_tagA() {

$entity = new Entity();
$pmEntity = new PluginMonitoringEntity();

$entities_id = $entity->add(array(
'name' => 'entityA',
'entities_id' => 0,
'comment' => ''
));
$pmEntity->add(array(
'entities_id' => $entities_id,
'tag' => 'tagA'
));

$entities_id = $entity->add(array(
'name' => 'entityA2',
'entities_id' => 0,
'comment' => ''
));
$pmEntity->add(array(
'entities_id' => $entities_id,
'tag' => 'tagA'
));

$entities_id = $entity->add(array(
'name' => 'entityB',
'entities_id' => 0,
'comment' => ''
));
$pmEntity->add(array(
'entities_id' => $entities_id,
'tag' => 'tagB'
));

$entities_id = $entity->add(array(
'name' => 'entityC',
'entities_id' => 0,
'comment' => ''
));
$pmEntity->add(array(
'entities_id' => $entities_id,
'tag' => ''
));

$ent_list = $pmEntity->getEntitiesByTag('tagA');

$a_reference = array(
1 => 1,
2 => 2
);

$this->assertEquals($a_reference, $ent_list, "May have 2 entities");
}


/**
* @depends test2Entities_tagA
*/
public function test2Entities_tagB() {

$pmEntity = new PluginMonitoringEntity();

$ent_list = $pmEntity->getEntitiesByTag('tagB');

$a_reference = array(
3 => 3
);

$this->assertEquals($a_reference, $ent_list, "May have 1 entity");
}


/**
* @depends test2Entities_tagA
*/
public function test2Entities_notag() {

$pmEntity = new PluginMonitoringEntity();

$ent_list = $pmEntity->getEntitiesByTag('');

$a_reference = array(
-1 => -1
);

$this->assertEquals($a_reference, $ent_list, "May have 1 entity");
}


/**
* @depends test2Entities_tagA
*/
public function test2Entities_tagnotexist() {

$pmEntity = new PluginMonitoringEntity();

$ent_list = $pmEntity->getEntitiesByTag('tagxx');

$a_reference = array();

$this->assertEquals($a_reference, $ent_list, "May have 0 entity");
}

}

?>

0 comments on commit a1c54b5

Please sign in to comment.