diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:17:47 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:17:47 +0000 |
commit | 5419d4428c86c488a43124f85e5407d7cbae6541 (patch) | |
tree | 772c4221a20fd7d1b3e7e67c6e21755a50e80fd7 /test/php/library/Director/PropertyModifier | |
parent | Adding upstream version 1.10.2. (diff) | |
download | icingaweb2-module-director-upstream.tar.xz icingaweb2-module-director-upstream.zip |
Adding upstream version 1.11.1.upstream/1.11.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/php/library/Director/PropertyModifier')
3 files changed, 19 insertions, 27 deletions
diff --git a/test/php/library/Director/PropertyModifier/PropertyModifierArrayElementByPositionTest.php b/test/php/library/Director/PropertyModifier/PropertyModifierArrayElementByPositionTest.php index 84465f3..2f0522a 100644 --- a/test/php/library/Director/PropertyModifier/PropertyModifierArrayElementByPositionTest.php +++ b/test/php/library/Director/PropertyModifier/PropertyModifierArrayElementByPositionTest.php @@ -31,11 +31,10 @@ class PropertyModifierArrayElementByPositionTest extends BaseTestCase ); } - /** - * @expectedException \InvalidArgumentException - */ public function testGettingFirstFailsForEmptyArray() { + $this->expectException(\InvalidArgumentException::class); + $this->buildModifier('first')->transform([]); } @@ -60,11 +59,10 @@ class PropertyModifierArrayElementByPositionTest extends BaseTestCase ); } - /** - * @expectedException \InvalidArgumentException - */ public function testGettingLastFailsForEmptyArray() { + $this->expectException(\InvalidArgumentException::class); + $this->buildModifier('last')->transform([]); } @@ -89,11 +87,10 @@ class PropertyModifierArrayElementByPositionTest extends BaseTestCase ); } - /** - * @expectedException \InvalidArgumentException - */ public function testGettingSpecificFailsForEmptyArray() { + $this->expectException(\InvalidArgumentException::class); + $this->buildModifier('fixed', 1)->transform([]); } @@ -102,11 +99,10 @@ class PropertyModifierArrayElementByPositionTest extends BaseTestCase $this->assertNull($this->buildModifier('fixed', 1, 'null')->transform([])); } - /** - * @expectedException \InvalidArgumentException - */ public function testGettingSpecificFailsForMissingValue() { + $this->expectException(\InvalidArgumentException::class); + $this->buildModifier('fixed', 3)->transform(['one', 'two', 'three']); } @@ -115,11 +111,10 @@ class PropertyModifierArrayElementByPositionTest extends BaseTestCase $this->assertNull($this->buildModifier('fixed', 3, 'null')->transform(['one', 'two', 'three'])); } - /** - * @expectedException \InvalidArgumentException - */ public function testFailsForStrings() { + $this->expectException(\InvalidArgumentException::class); + $this->buildModifier('first')->transform('string'); } diff --git a/test/php/library/Director/PropertyModifier/PropertyModifierListToObjectTest.php b/test/php/library/Director/PropertyModifier/PropertyModifierListToObjectTest.php index 93d498c..0a150be 100644 --- a/test/php/library/Director/PropertyModifier/PropertyModifierListToObjectTest.php +++ b/test/php/library/Director/PropertyModifier/PropertyModifierListToObjectTest.php @@ -23,21 +23,19 @@ class PropertyModifierListToObjectTest extends BaseTestCase ); } - /** - * @expectedException \InvalidArgumentException - */ public function testFailsOnMissingKey() { + $this->expectException(\InvalidArgumentException::class); + $input = $this->getInputArrays(); unset($input[0]['name']); $this->getNewModifier()->transform($input); } - /** - * @expectedException \InvalidArgumentException - */ public function testFailsWithDuplicateRows() { + $this->expectException(\InvalidArgumentException::class); + $input = $this->getInputArrays(); $input[1]['name'] = 'row1'; $this->getNewModifier()->transform($input); diff --git a/test/php/library/Director/PropertyModifier/PropertyModifierParseURLTest.php b/test/php/library/Director/PropertyModifier/PropertyModifierParseURLTest.php index a5ccb79..fe89ac6 100644 --- a/test/php/library/Director/PropertyModifier/PropertyModifierParseURLTest.php +++ b/test/php/library/Director/PropertyModifier/PropertyModifierParseURLTest.php @@ -2,6 +2,7 @@ namespace Tests\Icinga\Module\Director\PropertyModifier; +use Icinga\Exception\InvalidPropertyException; use Icinga\Module\Director\PropertyModifier\PropertyModifierParseURL; use Icinga\Module\Director\Test\BaseTestCase; @@ -50,11 +51,10 @@ class PropertyModifierParseURLTest extends BaseTestCase $this->assertEquals('http://www.icinga.org/path/', $modifier->transform('http://www.icinga.org/path/')); } - /** - * @expectedException \Icinga\Exception\InvalidPropertyException - */ public function testMissingComponentThrowsExceptionOnfailureFail() { + $this->expectException(InvalidPropertyException::class); + $modifier = new PropertyModifierParseURL(); $modifier->setSettings([ 'url_component' => 'query', @@ -87,11 +87,10 @@ class PropertyModifierParseURLTest extends BaseTestCase $this->assertEquals(self::$invalidurl, $modifier->transform(self::$invalidurl)); } - /** - * @expectedException \Icinga\Exception\InvalidPropertyException - */ public function testInvalidUrlThrowsExceptionOnfailureFail() { + $this->expectException(InvalidPropertyException::class); + $modifier = new PropertyModifierParseURL(); $modifier->setSettings([ 'url_component' => 'host', |