From 41ed29df8cea5345fd69d91b6e44369728c936b4 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Sat, 2 Apr 2016 20:19:19 +0200 Subject: [PATCH] IcingaCommandTest: add new command-related tests --- .../Director/Objects/IcingaCommandTest.php | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/test/php/library/Director/Objects/IcingaCommandTest.php b/test/php/library/Director/Objects/IcingaCommandTest.php index 26076748..a20d3923 100644 --- a/test/php/library/Director/Objects/IcingaCommandTest.php +++ b/test/php/library/Director/Objects/IcingaCommandTest.php @@ -29,6 +29,35 @@ class IcingaCommandTest extends BaseTestCase $command->arguments()->get('-H')->required = true; } + public function testCommandsWithArgumentsCanBeModified() + { + $command = $this->command(); + $command->arguments = array( + '-H' => '$host$' + ); + + $command->arguments = array( + '-x' => (object) array( + 'required' => true + ) + ); + + $this->assertEquals( + null, + $command->arguments()->get('-H') + ); + + $this->assertEquals( + 'y', + $command->arguments()->get('-x')->get('required') + ); + + $this->assertEquals( + true, + $command->toPlainObject()->arguments['-x']->required + ); + } + protected function command() { return IcingaCommand::create( @@ -39,11 +68,11 @@ class IcingaCommandTest extends BaseTestCase ); } - public function XXtearDown() + public function tearDown() { $db = $this->getDb(); - if (IcingaTimePeriod::exists($this->testPeriodName, $db)) { - IcingaTimePeriod::load($this->testPeriodName, $db)->delete(); + if (IcingaCommand::exists($this->testCommandName, $db)) { + IcingaCommand::load($this->testCommandName, $db)->delete(); } } }