From 5419d4428c86c488a43124f85e5407d7cbae6541 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 15:17:47 +0200 Subject: Adding upstream version 1.11.1. Signed-off-by: Daniel Baumann --- .../PropertyModifierArrayElementByPositionTest.php | 25 +++++++++------------- .../PropertyModifierListToObjectTest.php | 10 ++++----- .../PropertyModifierParseURLTest.php | 11 +++++----- 3 files changed, 19 insertions(+), 27 deletions(-) (limited to 'test/php/library/Director/PropertyModifier') 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', -- cgit v1.2.3