diff --git a/composer.json b/composer.json index a81e1f04..d27ba7f3 100644 --- a/composer.json +++ b/composer.json @@ -139,12 +139,12 @@ "brainmaestro/composer-git-hooks": "^2.8", "extensions": { "phpunit/phpunit": { - "fakerphp/faker": "1.20.*" + "fakerphp/faker": "1.24.*" } }, "friendsofphp/php-cs-fixer": "^3.3", "phpstan/phpstan": "^1.10", - "phpunit/phpunit": "^9", + "phpunit/phpunit": "^10", "rector/rector": "^1.0", "vimeo/psalm": "^5.23" } diff --git a/phpunit.xml b/phpunit.xml index ccc8bc0e..01218e0d 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,10 +1,6 @@ - - - - ./src/ - - + + ./tests/unit/ @@ -16,4 +12,9 @@ ./tests/functional/ + + + ./src + + diff --git a/tests/integration/Http/Transport/CurlTransportTest.php b/tests/integration/Http/Transport/CurlTransportTest.php index 0980173b..fb51caa5 100644 --- a/tests/integration/Http/Transport/CurlTransportTest.php +++ b/tests/integration/Http/Transport/CurlTransportTest.php @@ -42,7 +42,7 @@ public static function setUpBeforeClass(): void } /** @return array> */ - public function provideBadResponseCodes(): iterable + public static function provideBadResponseCodes(): iterable { // cURL does not understand codes below 200 properly. // foreach (range(100, 199) as $badCode) { diff --git a/tests/unit/Http/SetCookieTest.php b/tests/unit/Http/SetCookieTest.php index 8ad3a0c8..91a3b834 100644 --- a/tests/unit/Http/SetCookieTest.php +++ b/tests/unit/Http/SetCookieTest.php @@ -150,7 +150,7 @@ public function testMatchesDomain(): void } /** @return array> */ - public function pathMatchProvider(): array + public static function pathMatchProvider(): array { return [ ['/foo', '/foo', true], @@ -182,7 +182,7 @@ public function testMatchesPath(string $cookiePath, string $requestPath, bool $i } /** @return array> */ - public function cookieValidateProvider(): array + public static function cookieValidateProvider(): array { return [ ['foo', 'baz', 'bar', true], @@ -240,7 +240,7 @@ public function testConvertsToString(): void * * @return array */ - public function cookieParserDataProvider(): array + public static function cookieParserDataProvider(): array { return [ [ @@ -442,7 +442,7 @@ public function testParseCookie(array|string $cookie, array $parsed): void * * @return array> */ - public function isExpiredProvider(): array + public static function isExpiredProvider(): array { return [ [ diff --git a/tests/unit/Http/Transport/Bridge/PsrHttpClient/PsrHttpClientTransportTest.php b/tests/unit/Http/Transport/Bridge/PsrHttpClient/PsrHttpClientTransportTest.php index 093d23cb..0af8a69e 100644 --- a/tests/unit/Http/Transport/Bridge/PsrHttpClient/PsrHttpClientTransportTest.php +++ b/tests/unit/Http/Transport/Bridge/PsrHttpClient/PsrHttpClientTransportTest.php @@ -165,11 +165,23 @@ public function testRequestWithDefaultHeaders(): void $this->requestFactoryMock->expects($this->once())->method('createRequest')->with('POST', 'https://example.com/')->willReturn($requestMock); $this->streamFactoryMock->expects($this->once())->method('createStream')->with('Hi Doc!')->willReturn($requestStreamMock); $requestMock->expects($this->once())->method('withBody')->with($requestStreamMock)->willReturn($requestMock); - $requestMock->expects($this->exactly(3))->method('withHeader')->withConsecutive( - ['X-A-Custom-Header', 'Foo'], - ['X-Another-Custom-Header', 'Bar'], - ['Content-Type', 'application/xml'] - )->willReturn($requestMock); + $matcher = $this->exactly(3); + $requestMock->expects($matcher)->method('withHeader')->willReturnCallback(function (...$parameters) use ($matcher, $requestMock) { + if ($matcher->numberOfInvocations() === 1) { + $this->assertSame('X-A-Custom-Header', $parameters[0]); + $this->assertSame('Foo', $parameters[1]); + } + if ($matcher->numberOfInvocations() === 2) { + $this->assertSame('X-Another-Custom-Header', $parameters[0]); + $this->assertSame('Bar', $parameters[1]); + } + if ($matcher->numberOfInvocations() === 3) { + $this->assertSame('Content-Type', $parameters[0]); + $this->assertSame('application/xml', $parameters[1]); + } + + return $requestMock; + }); $this->httpClientMock->expects($this->once())->method('sendRequest')->with($requestMock)->willReturn($responseMock); $responseMock->expects($this->exactly(2))->method('getStatusCode')->willReturn(200); $responseMock->expects($this->once())->method('getHeader')->with('Set-Cookie')->willReturn(['JSESSIONID=MartyMcFlySession']); @@ -199,7 +211,7 @@ public function testRequestWithClientException(): void } /** @return iterable> */ - public function provideBadResponseCodes(): iterable + public static function provideBadResponseCodes(): iterable { foreach (range(100, 199) as $badCode) { yield 'HTTP code '.$badCode => [$badCode]; diff --git a/tests/unit/Http/Transport/Bridge/SymfonyHttpClient/SymfonyHttpClientTransportTest.php b/tests/unit/Http/Transport/Bridge/SymfonyHttpClient/SymfonyHttpClientTransportTest.php index 740596ce..10dc5a99 100644 --- a/tests/unit/Http/Transport/Bridge/SymfonyHttpClient/SymfonyHttpClientTransportTest.php +++ b/tests/unit/Http/Transport/Bridge/SymfonyHttpClient/SymfonyHttpClientTransportTest.php @@ -202,7 +202,7 @@ public function testRequestWithDefaultOptions(): void } /** @return iterable> */ - public function provideBadResponseCodes(): iterable + public static function provideBadResponseCodes(): iterable { foreach (range(100, 199) as $badCode) { yield 'HTTP code '.$badCode => [$badCode]; @@ -244,7 +244,7 @@ public function testRequestWithBadResponseCode(int $badCode): void } /** @return iterable> */ - public function provideBadResponseExceptions(): iterable + public static function provideBadResponseExceptions(): iterable { yield 'Client exception' => [new FakeClientException(), 400]; yield 'Server exception' => [new FakeServerException(), 500]; diff --git a/tests/unit/Http/Transport/HeaderTest.php b/tests/unit/Http/Transport/HeaderTest.php index d823c559..ff923817 100644 --- a/tests/unit/Http/Transport/HeaderTest.php +++ b/tests/unit/Http/Transport/HeaderTest.php @@ -49,7 +49,7 @@ public function testMergeCurlHeaders(): void /** * @return iterable */ - public function provideBadlyFormattedHeaders(): iterable + public static function provideBadlyFormattedHeaders(): iterable { yield ['This is not valid.']; yield ['Foo:Bar']; @@ -69,7 +69,7 @@ public function testMergeCurlHeadersWithBadHeaders(string $badHeader): void /** * @return iterable */ - public function provideNonStringHeaders(): iterable + public static function provideNonStringHeaders(): iterable { yield [123]; yield [false]; diff --git a/tests/unit/Util/ArrayHelperTest.php b/tests/unit/Util/ArrayHelperTest.php index 9ea33908..9c1f5b75 100644 --- a/tests/unit/Util/ArrayHelperTest.php +++ b/tests/unit/Util/ArrayHelperTest.php @@ -30,7 +30,7 @@ final class ArrayHelperTest extends TestCase { /** @return iterable> */ - public function provideArrays(): iterable + public static function provideArrays(): iterable { yield 'simple flat arrays' => [ ['foo' => 'bar', 'foo2' => 'bar2'], diff --git a/tools/.phpunit/composer.json b/tools/.phpunit/composer.json index 4db33099..2dc16d75 100644 --- a/tools/.phpunit/composer.json +++ b/tools/.phpunit/composer.json @@ -1,6 +1,6 @@ { "require": { - "phpunit/phpunit": "^9.0", - "fakerphp/faker": "1.20.*" + "phpunit/phpunit": "^10.0", + "fakerphp/faker": "1.24.*" } }