From bb78ba82ab00395670f0c00683b87ff78ff087c5 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Mon, 8 Sep 2025 16:06:05 +0200 Subject: [PATCH 1/3] Fix tests for PHPUnit 12 Origin: vendor Forwarded: https://github.com/pear/Net_URL2/pull/22 --- tests/Net/URL2Test.php | 56 ++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/tests/Net/URL2Test.php b/tests/Net/URL2Test.php index 5ae3c1a..7a5fd94 100644 --- a/tests/Net/URL2Test.php +++ b/tests/Net/URL2Test.php @@ -827,28 +827,30 @@ public static function provideEquivalentUrlLists() { return array( // String equivalence: - array('http://example.com/', 'http://example.com/'), + array('http://example.com/', 'http://example.com/', true), // Originally first dataset: - array('http://www.example.com/%9a', 'http://www.example.com/%9A'), + array('http://www.example.com/%9a', 'http://www.example.com/%9A', false), // Example from RFC 3986 6.2.2.: - array('example://a/b/c/%7Bfoo%7D', 'eXAMPLE://a/./b/../b/%63/%7bfoo%7d'), + array('example://a/b/c/%7Bfoo%7D', 'eXAMPLE://a/./b/../b/%63/%7bfoo%7d', false), // Example from RFC 3986 6.2.2.1.: - array('HTTP://www.EXAMPLE.com/', 'http://www.example.com/'), + array('HTTP://www.EXAMPLE.com/', 'http://www.example.com/', false), // Example from RFC 3986 6.2.3.: array( - 'http://example.com', 'http://example.com/', - 'http://example.com:/', 'http://example.com:80/' + 'http://example.com', 'http://example.com/', false + ), + array( + 'http://example.com:/', 'http://example.com:80/', false ), // Bug #20161: URLs with "0" as host fail to normalize with empty path - array('http://0/', 'http://0'), + array('http://0/', 'http://0', false), // Bug #20473: Normalize query and fragment broken - array('foo:///?%66%6f%6f#%62%61%72', 'foo:///?foo#bar'), + array('foo:///?%66%6f%6f#%62%61%72', 'foo:///?foo#bar', false), ); } @@ -861,22 +863,19 @@ public static function provideEquivalentUrlLists() * @dataProvider provideEquivalentUrlLists */ #[PHPUnit\Framework\Attributes\DataProvider('provideEquivalentUrlLists')] - public function testNormalize() + public function testNormalize(string $urlOne, string $urlTwo, bool $identical) { - $urls = func_get_args(); + $urlOne = new Net_Url2($urlOne); + $urlTwo = new Net_Url2($urlTwo); - $this->assertGreaterThanOrEqual(2, count($urls)); + if (! $identical) { + $this->assertNotSame($urlOne->__toString(), $urlTwo->__toString()); + } - $last = null; + $urlOne->normalize(); + $urlTwo->normalize(); - foreach ($urls as $index => $url) { - $url = new Net_Url2($url); - $url->normalize(); - if ($index) { - $this->assertSame((string)$last, (string)$url); - } - $last = $url; - } + $this->assertSame($urlOne->__toString(), $urlTwo->__toString()); } /** @@ -952,14 +951,17 @@ public function testComponentRecompositionAndNormalization($uri) * @return void */ #[PHPUnit\Framework\Attributes\DataProvider('provideEquivalentUrlLists')] - public function testConstructSelf() + public function testConstructSelf(string $urlOne, string $urlTwo, bool $identical) { - $urls = func_get_args(); - foreach ($urls as $url) { - $urlA = new Net_URL2($url); - $urlB = new Net_URL2($urlA); - $this->assertSame((string)$urlA, (string)$urlB); - } + $urlOne = new Net_Url2($urlOne); + $urlOneExtended = new Net_Url2($urlOne); + + $this->assertSame($urlOne->__toString(), $urlOneExtended->__toString()); + + $urlTwo = new Net_Url2($urlTwo); + $urlTwoExtended = new Net_Url2($urlTwo); + + $this->assertSame($urlTwo->__toString(), $urlTwoExtended->__toString()); } /** From 285666a252d16fef0027888492a29f3ff75f88ba Mon Sep 17 00:00:00 2001 From: William Desportes Date: Mon, 8 Sep 2025 17:27:02 +0200 Subject: [PATCH 2/3] Fix signatures for old PHP versions --- tests/Net/URL2Test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Net/URL2Test.php b/tests/Net/URL2Test.php index 7a5fd94..f348242 100644 --- a/tests/Net/URL2Test.php +++ b/tests/Net/URL2Test.php @@ -863,7 +863,7 @@ public static function provideEquivalentUrlLists() * @dataProvider provideEquivalentUrlLists */ #[PHPUnit\Framework\Attributes\DataProvider('provideEquivalentUrlLists')] - public function testNormalize(string $urlOne, string $urlTwo, bool $identical) + public function testNormalize($urlOne, $urlTwo, $identical) { $urlOne = new Net_Url2($urlOne); $urlTwo = new Net_Url2($urlTwo); @@ -951,7 +951,7 @@ public function testComponentRecompositionAndNormalization($uri) * @return void */ #[PHPUnit\Framework\Attributes\DataProvider('provideEquivalentUrlLists')] - public function testConstructSelf(string $urlOne, string $urlTwo, bool $identical) + public function testConstructSelf($urlOne, $urlTwo, $identical) { $urlOne = new Net_Url2($urlOne); $urlOneExtended = new Net_Url2($urlOne); From 8f6978d7dac89e7dd067e0e64245bfe1bef4a265 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Mon, 8 Sep 2025 17:29:36 +0200 Subject: [PATCH 3/3] Ajust the project requirements to what is tested --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 772e901..1bb7717 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "source": "https://github.com/pear/Net_URL2" }, "require": { - "php": ">=5.1.4" + "php": ">=5.3" }, "autoload": { "classmap": ["Net/URL2.php"] @@ -45,7 +45,7 @@ } }, "require-dev": { - "phpunit/phpunit": ">=3.3.0" + "phpunit/phpunit": ">=4.8" }, "scripts": { "test": "phpunit"