public function setUp() { IcingaWebTestTool::authenticateTestUser(); $ctx = IcingaWebTestTool::getContext(); $user = $ctx->getUser(); $record = $user->getNsmUser(); $principal = $record->principal; $target = Doctrine::getTable('NsmTarget')->findOneBy("target_name", 'IcingaHostgroup'); $this->principal_target = new NsmPrincipalTarget(); $this->principal_target->NsmPrincipal = $principal; $this->principal_target->NsmTarget = $target; $this->target_value = new NsmTargetValue(); $this->target_value->tv_key = 'hostgroup'; $this->target_value->tv_val = self::HOSTGROUP; $this->principal_target->NsmTargetValue[] = $this->target_value; $this->target_value->save(); $this->principal_target->save(); $this->assertGreaterThan(0, $this->target_value->tv_pt_id); $this->assertGreaterThan(0, $this->principal_target->pt_id); }
/** * @group Module */ public function testCronkNotInGroup() { IcingaWebTestTool::authenticateTestUser(); $ctx = IcingaWebTestTool::getContext(); $ctx->getUser()->removeCredential('icinga.cronk.admin'); // Drop cache unset($_SESSION["icinga.cronks.cache.xml"]); $cronk_model = $ctx->getModel('Provider.CronksData', 'Cronks'); $cronks = $cronk_model->getCronks(); $this->assertFalse(array_key_exists('dummyTestCronk3', $cronks)); }
/** * @group CronkCategory * @expectedException AppKitModelException * @expectedExceptionMessage Category not found: phpunit_test_123123 */ public function testCategoryCreation() { $ctx = IcingaWebTestTool::getContext(); IcingaWebTestTool::authenticateTestUser(); $catid = 'phpunit_test_123123'; $catmodel = $ctx->getModel('Provider.CronkCategoryData', 'Cronks'); $catmodel->createCategory(array('catid' => $catid, 'title' => 'PHPUNIT test category', 'visible' => true, 'position' => '123443')); $test_cat = $catmodel->getCategory($catid); $this->assertEquals('123443', $test_cat['position']); $catmodel->deleteCategoryRecord($catid); // Throw at least $test_cat = $catmodel->getCategory($catid); }