From a8a8746ab908d024ef47a507cdb4544c6dae4093 Mon Sep 17 00:00:00 2001 From: Aleksei Khudiakov Date: Sun, 12 Oct 2025 06:06:29 +1000 Subject: [PATCH] Add support for PHPUnit 11 and 12 Signed-off-by: Aleksei Khudiakov --- composer.json | 2 +- src/MessageTrait.php | 3 +++ src/RequestIntegrationTest.php | 2 ++ src/ResponseIntegrationTest.php | 2 ++ src/ServerRequestIntegrationTest.php | 3 +++ src/UriIntegrationTest.php | 7 +++++++ 6 files changed, 18 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index cee5f90..22770aa 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ ], "require": { "php": "^7.3 || ^8.0", - "phpunit/phpunit": "^9.3 || ^10.0", + "phpunit/phpunit": "^9.3 || ^10.0 || ^11.5 || ^12.4", "psr/http-message": "^1.0 || ^2.0" }, "require-dev": { diff --git a/src/MessageTrait.php b/src/MessageTrait.php index 506d5f1..ef84eb8 100644 --- a/src/MessageTrait.php +++ b/src/MessageTrait.php @@ -4,6 +4,7 @@ use InvalidArgumentException; use PHPUnit\Framework\AssertionFailedError; +use PHPUnit\Framework\Attributes\DataProvider; use Psr\Http\Message\MessageInterface; use Throwable; use TypeError; @@ -135,6 +136,7 @@ public function testWithHeader() /** * @dataProvider getInvalidHeaderArguments */ + #[DataProvider('getInvalidHeaderArguments')] public function testWithHeaderInvalidArguments($name, $value) { if (isset($this->skippedTests[__FUNCTION__])) { @@ -188,6 +190,7 @@ public function testWithAddedHeader() /** * @dataProvider getInvalidHeaderArguments */ + #[DataProvider('getInvalidHeaderArguments')] public function testWithAddedHeaderInvalidArguments($name, $value) { if (isset($this->skippedTests[__FUNCTION__])) { diff --git a/src/RequestIntegrationTest.php b/src/RequestIntegrationTest.php index f847093..921e768 100644 --- a/src/RequestIntegrationTest.php +++ b/src/RequestIntegrationTest.php @@ -4,6 +4,7 @@ use InvalidArgumentException; use PHPUnit\Framework\AssertionFailedError; +use PHPUnit\Framework\Attributes\DataProvider; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\UriInterface; use Throwable; @@ -94,6 +95,7 @@ public function testMethodIsExtendable() /** * @dataProvider getInvalidMethods */ + #[DataProvider('getInvalidMethods')] public function testMethodWithInvalidArguments($method) { if (isset($this->skippedTests[__FUNCTION__])) { diff --git a/src/ResponseIntegrationTest.php b/src/ResponseIntegrationTest.php index 415ccc4..bb9029c 100644 --- a/src/ResponseIntegrationTest.php +++ b/src/ResponseIntegrationTest.php @@ -4,6 +4,7 @@ use InvalidArgumentException; use PHPUnit\Framework\AssertionFailedError; +use PHPUnit\Framework\Attributes\DataProvider; use Psr\Http\Message\ResponseInterface; use Throwable; use TypeError; @@ -56,6 +57,7 @@ public function testStatusCode() /** * @dataProvider getInvalidStatusCodeArguments */ + #[DataProvider('getInvalidStatusCodeArguments')] public function testStatusCodeInvalidArgument($statusCode) { if (isset($this->skippedTests[__FUNCTION__])) { diff --git a/src/ServerRequestIntegrationTest.php b/src/ServerRequestIntegrationTest.php index d06a8f1..1d29081 100644 --- a/src/ServerRequestIntegrationTest.php +++ b/src/ServerRequestIntegrationTest.php @@ -2,6 +2,7 @@ namespace Http\Psr7Test; +use PHPUnit\Framework\Attributes\DataProvider; use Psr\Http\Message\ServerRequestInterface; /** @@ -88,6 +89,7 @@ public function testGetUploadedFiles() /** * @dataProvider validParsedBodyParams */ + #[DataProvider('validParsedBodyParams')] public function testGetParsedBody($value) { if (isset($this->skippedTests[__FUNCTION__])) { @@ -111,6 +113,7 @@ public static function validParsedBodyParams() /** * @dataProvider invalidParsedBodyParams */ + #[DataProvider('invalidParsedBodyParams')] public function testGetParsedBodyInvalid($value) { if (isset($this->skippedTests[__FUNCTION__])) { diff --git a/src/UriIntegrationTest.php b/src/UriIntegrationTest.php index 7c76378..0522f33 100644 --- a/src/UriIntegrationTest.php +++ b/src/UriIntegrationTest.php @@ -4,6 +4,8 @@ use InvalidArgumentException; use PHPUnit\Framework\AssertionFailedError; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Depends; use Psr\Http\Message\UriInterface; use Throwable; use TypeError; @@ -45,6 +47,7 @@ public function testScheme() /** * @dataProvider getInvalidSchemaArguments */ + #[DataProvider('getInvalidSchemaArguments')] public function testWithSchemeInvalidArguments($schema) { if (isset($this->skippedTests[__FUNCTION__])) { @@ -155,6 +158,7 @@ public function testPort() /** * @dataProvider getPaths */ + #[DataProvider('getPaths')] public function testPath(UriInterface $uri, string $expected) { if (isset($this->skippedTests[__FUNCTION__])) { @@ -181,6 +185,7 @@ public static function getPaths() /** * @dataProvider getQueries */ + #[DataProvider('getQueries')] public function testQuery(UriInterface $uri, string $expected) { if (isset($this->skippedTests[__FUNCTION__])) { @@ -206,6 +211,7 @@ public static function getQueries() /** * @dataProvider getFragments */ + #[DataProvider('getFragments')] public function testFragment(UriInterface $uri, string $expected) { if (isset($this->skippedTests[__FUNCTION__])) { @@ -304,6 +310,7 @@ public function testGetPathNormalizesMultipleLeadingSlashesToSingleSlashToPreven * * @psalm-param array{expected: non-empty-string, uri: UriInterface} $test */ + #[Depends('testGetPathNormalizesMultipleLeadingSlashesToSingleSlashToPreventXSS')] public function testStringRepresentationWithMultipleSlashes(array $test) { $this->assertSame($test['expected'], (string) $test['uri']);