From fcd9278a4b7ad71885e34e46998ab25f7e5b240f Mon Sep 17 00:00:00 2001 From: William Desportes Date: Sat, 20 Sep 2025 12:15:06 +0200 Subject: [PATCH 01/15] Exclude tests/Mocks from phpunit tests filter --- phpunit.xml.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 2bbfaf422..95801f435 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -10,6 +10,7 @@ tests + tests/Mocks From 75d7dbae01fae6ff44278e15b354f3c4c36d19f9 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Sat, 20 Sep 2025 12:15:51 +0200 Subject: [PATCH 02/15] Make phpunit providers static --- tests/AppTest.php | 8 ++++---- tests/Factory/AppFactoryTest.php | 2 +- tests/Factory/ServerRequestCreatorFactoryTest.php | 2 +- tests/Middleware/BodyParsingMiddlewareTest.php | 2 +- tests/MiddlewareDispatcherTest.php | 2 +- tests/Routing/FastRouteDispatcherTest.php | 6 +++--- tests/Routing/RouteContextTest.php | 2 +- tests/Routing/RouteParserTest.php | 2 +- tests/Routing/RouteResolverTest.php | 2 +- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/AppTest.php b/tests/AppTest.php index 80c6e9f66..44d3f6893 100644 --- a/tests/AppTest.php +++ b/tests/AppTest.php @@ -155,7 +155,7 @@ public function testGetMiddlewareDispatcherGetsSeededAndReturnsInjectedInstance( $this->assertSame($middlewareDispatcherProphecy->reveal(), $app->getMiddlewareDispatcher()); } - public function lowerCaseRequestMethodsProvider(): array + public static function lowerCaseRequestMethodsProvider(): array { return [ ['get'], @@ -244,7 +244,7 @@ public function testAnyRoute(): void * Route collector proxy methods *******************************************************************************/ - public function upperCaseRequestMethodsProvider(): array + public static function upperCaseRequestMethodsProvider(): array { return [ ['GET'], @@ -376,7 +376,7 @@ public function testRouteWithInternationalCharacters(): void * Route Patterns *******************************************************************************/ - public function routePatternsProvider(): array + public static function routePatternsProvider(): array { return [ [''], // Empty Route @@ -409,7 +409,7 @@ public function testRoutePatterns(string $pattern): void * Route Groups *******************************************************************************/ - public function routeGroupsDataProvider(): array + public static function routeGroupsDataProvider(): array { return [ 'empty group with empty route' => [ diff --git a/tests/Factory/AppFactoryTest.php b/tests/Factory/AppFactoryTest.php index 25349ffc8..73f6b42b2 100644 --- a/tests/Factory/AppFactoryTest.php +++ b/tests/Factory/AppFactoryTest.php @@ -50,7 +50,7 @@ protected function tearDown(): void $reflectionClass->setStaticPropertyValue('responseFactoryClass', DecoratedResponseFactory::class); } - public function provideImplementations() + public static function provideImplementations() { return [ [SlimPsr17Factory::class, SlimResponseFactory::class], diff --git a/tests/Factory/ServerRequestCreatorFactoryTest.php b/tests/Factory/ServerRequestCreatorFactoryTest.php index e68a08382..8da78de3a 100644 --- a/tests/Factory/ServerRequestCreatorFactoryTest.php +++ b/tests/Factory/ServerRequestCreatorFactoryTest.php @@ -31,7 +31,7 @@ class ServerRequestCreatorFactoryTest extends TestCase { - public function provideImplementations() + public static function provideImplementations() { return [ [SlimPsr17Factory::class, SlimServerRequest::class], diff --git a/tests/Middleware/BodyParsingMiddlewareTest.php b/tests/Middleware/BodyParsingMiddlewareTest.php index 30cba022c..67548416a 100644 --- a/tests/Middleware/BodyParsingMiddlewareTest.php +++ b/tests/Middleware/BodyParsingMiddlewareTest.php @@ -64,7 +64,7 @@ protected function createRequestWithBody($contentType, $body) } - public function parsingProvider() + public static function parsingProvider() { return [ 'form' => [ diff --git a/tests/MiddlewareDispatcherTest.php b/tests/MiddlewareDispatcherTest.php index ad87fedfc..4af63d808 100644 --- a/tests/MiddlewareDispatcherTest.php +++ b/tests/MiddlewareDispatcherTest.php @@ -138,7 +138,7 @@ public function testDeferredResolvedCallableWithDirectConstructorCall(): void $this->assertSame(1, $handler->getCalledCount()); } - public function deferredCallableProvider(): array + public static function deferredCallableProvider(): array { return [ [MockMiddlewareSlimCallable::class . ':custom', new MockMiddlewareSlimCallable()], diff --git a/tests/Routing/FastRouteDispatcherTest.php b/tests/Routing/FastRouteDispatcherTest.php index 0f49c42d9..fd8ffabb2 100644 --- a/tests/Routing/FastRouteDispatcherTest.php +++ b/tests/Routing/FastRouteDispatcherTest.php @@ -160,7 +160,7 @@ public function testCapturing() }, $this->generateDispatcherOptions()); } - public function provideFoundDispatchCases() + public static function provideFoundDispatchCases() { $cases = []; @@ -459,7 +459,7 @@ public function provideFoundDispatchCases() return $cases; } - public function provideNotFoundDispatchCases() + public static function provideNotFoundDispatchCases() { $cases = []; @@ -536,7 +536,7 @@ public function provideNotFoundDispatchCases() return $cases; } - public function provideMethodNotAllowedDispatchCases() + public static function provideMethodNotAllowedDispatchCases() { $cases = []; diff --git a/tests/Routing/RouteContextTest.php b/tests/Routing/RouteContextTest.php index 871843792..8f28985c0 100644 --- a/tests/Routing/RouteContextTest.php +++ b/tests/Routing/RouteContextTest.php @@ -70,7 +70,7 @@ public function testCanCreateInstanceWithoutBasePathAndThrowExceptionIfGetBasePa $routeContext->getBasePath(); } - public function requiredRouteContextRequestAttributes(): array + public static function requiredRouteContextRequestAttributes(): array { return [ [RouteContext::ROUTE_PARSER], diff --git a/tests/Routing/RouteParserTest.php b/tests/Routing/RouteParserTest.php index 839575f6a..71579f236 100644 --- a/tests/Routing/RouteParserTest.php +++ b/tests/Routing/RouteParserTest.php @@ -17,7 +17,7 @@ class RouteParserTest extends TestCase { - public function urlForCases() + public static function urlForCases() { return [ 'with base path' => [ diff --git a/tests/Routing/RouteResolverTest.php b/tests/Routing/RouteResolverTest.php index 2a3a7e288..42a0d94e3 100644 --- a/tests/Routing/RouteResolverTest.php +++ b/tests/Routing/RouteResolverTest.php @@ -23,7 +23,7 @@ class RouteResolverTest extends TestCase { - public function computeRoutingResultsDataProvider(): array + public static function computeRoutingResultsDataProvider(): array { return [ ['GET', '', '/'], From ae6cf5d513429ed8f38d452d6f3300e8de5313c9 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Sat, 20 Sep 2025 12:16:34 +0200 Subject: [PATCH 03/15] Allow phpunit 10 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 6ff4d8b4d..0a542aefa 100644 --- a/composer.json +++ b/composer.json @@ -65,7 +65,7 @@ "phpspec/prophecy": "^1.19", "phpspec/prophecy-phpunit": "^2.1", "phpstan/phpstan": "^1 || ^2", - "phpunit/phpunit": "^9.6", + "phpunit/phpunit": "^9.6 || ^10", "slim/http": "^1.3", "slim/psr7": "^1.6", "squizlabs/php_codesniffer": "^3.10", From 8341eab2efbf409ee428062b55a903a5602e2ae5 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Sat, 20 Sep 2025 12:20:25 +0200 Subject: [PATCH 04/15] Allow phpunit 11 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 0a542aefa..f0cc5eafd 100644 --- a/composer.json +++ b/composer.json @@ -65,7 +65,7 @@ "phpspec/prophecy": "^1.19", "phpspec/prophecy-phpunit": "^2.1", "phpstan/phpstan": "^1 || ^2", - "phpunit/phpunit": "^9.6 || ^10", + "phpunit/phpunit": "^9.6 || ^10 || ^11", "slim/http": "^1.3", "slim/psr7": "^1.6", "squizlabs/php_codesniffer": "^3.10", From 74d70efeb50989b0390af1e212cde8ee883d3309 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Sat, 20 Sep 2025 12:23:21 +0200 Subject: [PATCH 05/15] Add a missing parameter to testMethodNotAllowedDispatches --- tests/Routing/FastRouteDispatcherTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Routing/FastRouteDispatcherTest.php b/tests/Routing/FastRouteDispatcherTest.php index fd8ffabb2..399816049 100644 --- a/tests/Routing/FastRouteDispatcherTest.php +++ b/tests/Routing/FastRouteDispatcherTest.php @@ -74,8 +74,9 @@ public function testNotFoundDispatches($method, $uri, $callback) * @param $method * @param $uri * @param $callback + * @param $allowedMethods */ - public function testMethodNotAllowedDispatches($method, $uri, $callback) + public function testMethodNotAllowedDispatches($method, $uri, $callback, $allowedMethods) { /** @var FastRouteDispatcher $dispatcher */ $dispatcher = simpleDispatcher($callback, $this->generateDispatcherOptions()); From d4e0faf9f5af44aef9c2961e82d30aec6a9dcb2f Mon Sep 17 00:00:00 2001 From: William Desportes Date: Sat, 20 Sep 2025 12:32:14 +0200 Subject: [PATCH 06/15] Migrate mock creation --- tests/Handlers/ErrorHandlerTest.php | 30 ++++++----------------------- 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/tests/Handlers/ErrorHandlerTest.php b/tests/Handlers/ErrorHandlerTest.php index b50dff4b3..296e38b8a 100644 --- a/tests/Handlers/ErrorHandlerTest.php +++ b/tests/Handlers/ErrorHandlerTest.php @@ -36,10 +36,7 @@ private function getMockLogger(): LoggerInterface public function testDetermineRenderer() { - $handler = $this - ->getMockBuilder(ErrorHandler::class) - ->disableOriginalConstructor() - ->getMock(); + $handler = $this->createMock(ErrorHandler::class); $class = new ReflectionClass(ErrorHandler::class); $callableResolverProperty = $class->getProperty('callableResolver'); @@ -77,10 +74,7 @@ public function testDetermineRenderer() public function testDetermineStatusCode() { $request = $this->createServerRequest('/'); - $handler = $this - ->getMockBuilder(ErrorHandler::class) - ->disableOriginalConstructor() - ->getMock(); + $handler = $this->createMock(ErrorHandler::class); $class = new ReflectionClass(ErrorHandler::class); $reflectionProperty = $class->getProperty('responseFactory'); @@ -129,10 +123,7 @@ public function testHalfValidContentType() ->createServerRequest('/', 'GET') ->withHeader('Content-Type', 'unknown/json+'); - $handler = $this - ->getMockBuilder(ErrorHandler::class) - ->disableOriginalConstructor() - ->getMock(); + $handler = $this->createMock(ErrorHandler::class); $newErrorRenderers = [ 'application/xml' => XmlErrorRenderer::class, 'text/xml' => XmlErrorRenderer::class, @@ -164,10 +155,7 @@ public function testDetermineContentTypeTextPlainMultiAcceptHeader() ->withHeader('Content-Type', 'text/plain') ->withHeader('Accept', 'text/plain,text/xml'); - $handler = $this - ->getMockBuilder(ErrorHandler::class) - ->disableOriginalConstructor() - ->getMock(); + $handler = $this->createMock(ErrorHandler::class); $errorRenderers = [ 'text/plain' => PlainTextErrorRenderer::class, @@ -199,10 +187,7 @@ public function testDetermineContentTypeApplicationJsonOrXml() ->withHeader('Content-Type', 'text/json') ->withHeader('Accept', 'application/xhtml+xml'); - $handler = $this - ->getMockBuilder(ErrorHandler::class) - ->disableOriginalConstructor() - ->getMock(); + $handler = $this->createMock(ErrorHandler::class); $errorRenderers = [ 'application/xml' => XmlErrorRenderer::class @@ -242,10 +227,7 @@ public function testAcceptableMediaTypeIsNotFirstInList() $method->setAccessible(true); // use a mock object here as ErrorHandler cannot be directly instantiated - $handler = $this - ->getMockBuilder(ErrorHandler::class) - ->disableOriginalConstructor() - ->getMock(); + $handler = $this->createMock(ErrorHandler::class); // call determineContentType() $return = $method->invoke($handler, $request); From 415a4b0f97949d3085be240774633566e40919f1 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Sat, 20 Sep 2025 12:25:22 +0200 Subject: [PATCH 07/15] Add PHPUnit 12 attributes --- tests/AppTest.php | 5 +++++ tests/Factory/AppFactoryTest.php | 5 +++++ tests/Factory/Psr17/Psr17FactoryProviderTest.php | 2 ++ tests/Factory/ServerRequestCreatorFactoryTest.php | 4 ++++ tests/Middleware/BodyParsingMiddlewareTest.php | 1 + tests/MiddlewareDispatcherTest.php | 1 + tests/Routing/FastRouteDispatcherTest.php | 4 ++++ tests/Routing/RouteContextTest.php | 1 + tests/Routing/RouteParserTest.php | 1 + tests/Routing/RouteResolverTest.php | 1 + 10 files changed, 25 insertions(+) diff --git a/tests/AppTest.php b/tests/AppTest.php index 44d3f6893..1724695d6 100644 --- a/tests/AppTest.php +++ b/tests/AppTest.php @@ -171,6 +171,7 @@ public static function lowerCaseRequestMethodsProvider(): array * @param string $method * @dataProvider upperCaseRequestMethodsProvider() */ + #[\PHPUnit\Framework\Attributes\DataProvider('upperCaseRequestMethodsProvider')] public function testGetPostPutPatchDeleteOptionsMethods(string $method): void { $streamProphecy = $this->prophesize(StreamInterface::class); @@ -261,6 +262,8 @@ public static function upperCaseRequestMethodsProvider(): array * @dataProvider lowerCaseRequestMethodsProvider * @dataProvider upperCaseRequestMethodsProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('lowerCaseRequestMethodsProvider')] + #[\PHPUnit\Framework\Attributes\DataProvider('upperCaseRequestMethodsProvider')] public function testMapRoute(string $method): void { $streamProphecy = $this->prophesize(StreamInterface::class); @@ -391,6 +394,7 @@ public static function routePatternsProvider(): array * @param string $pattern * @dataProvider routePatternsProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('routePatternsProvider')] public function testRoutePatterns(string $pattern): void { $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class); @@ -539,6 +543,7 @@ public function testGroupClosureIsBoundToThisClass(): void * @param array $sequence * @param string $expectedPath */ + #[\PHPUnit\Framework\Attributes\DataProvider('routeGroupsDataProvider')] public function testRouteGroupCombinations(array $sequence, string $expectedPath): void { $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class); diff --git a/tests/Factory/AppFactoryTest.php b/tests/Factory/AppFactoryTest.php index 73f6b42b2..700c85ebf 100644 --- a/tests/Factory/AppFactoryTest.php +++ b/tests/Factory/AppFactoryTest.php @@ -66,6 +66,7 @@ public static function provideImplementations() * @param string $psr17factory * @param string $expectedResponseFactoryClass */ + #[\PHPUnit\Framework\Attributes\DataProvider('provideImplementations')] public function testCreateAppWithAllImplementations(string $psr17factory, string $expectedResponseFactoryClass) { Psr17FactoryProvider::setFactories([$psr17factory]); @@ -134,6 +135,7 @@ public function testSetPsr17FactoryProvider() /** * @runInSeparateProcess - Psr17FactoryProvider::setFactories breaks other tests */ + #[\PHPUnit\Framework\Attributes\RunInSeparateProcess] public function testResponseFactoryIsStillReturnedIfStreamFactoryIsNotAvailable() { Psr17FactoryProvider::setFactories([MockPsr17FactoryWithoutStreamFactory::class]); @@ -147,6 +149,7 @@ public function testResponseFactoryIsStillReturnedIfStreamFactoryIsNotAvailable( /** * @runInSeparateProcess - AppFactory::setResponseFactory breaks other tests */ + #[\PHPUnit\Framework\Attributes\RunInSeparateProcess] public function testAppIsCreatedWithInstancesFromSetters() { $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class); @@ -204,6 +207,7 @@ public function testAppIsCreatedWithInstancesFromSetters() * @runInSeparateProcess - AppFactory::create saves $responseFactory into static::$responseFactory, * this breaks other tests */ + #[\PHPUnit\Framework\Attributes\RunInSeparateProcess] public function testAppIsCreatedWithInjectedInstancesFromFunctionArguments() { $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class); @@ -254,6 +258,7 @@ public function testAppIsCreatedWithInjectedInstancesFromFunctionArguments() /** * @runInSeparateProcess - AppFactory::setResponseFactory breaks other tests */ + #[\PHPUnit\Framework\Attributes\RunInSeparateProcess] public function testResponseAndStreamFactoryIsBeingInjectedInDecoratedResponseFactory() { $responseProphecy = $this->prophesize(ResponseInterface::class); diff --git a/tests/Factory/Psr17/Psr17FactoryProviderTest.php b/tests/Factory/Psr17/Psr17FactoryProviderTest.php index 291000ddb..144a13376 100644 --- a/tests/Factory/Psr17/Psr17FactoryProviderTest.php +++ b/tests/Factory/Psr17/Psr17FactoryProviderTest.php @@ -18,6 +18,7 @@ class Psr17FactoryProviderTest extends TestCase /** * @runInSeparateProcess - Psr17FactoryProvider::setFactories breaks other tests */ + #[\PHPUnit\Framework\Attributes\RunInSeparateProcess] public function testGetSetFactories() { Psr17FactoryProvider::setFactories([]); @@ -29,6 +30,7 @@ public function testGetSetFactories() /** * @runInSeparateProcess - Psr17FactoryProvider::setFactories breaks other tests */ + #[\PHPUnit\Framework\Attributes\RunInSeparateProcess] public function testAddFactory() { Psr17FactoryProvider::setFactories(['Factory 1']); diff --git a/tests/Factory/ServerRequestCreatorFactoryTest.php b/tests/Factory/ServerRequestCreatorFactoryTest.php index 8da78de3a..8c25d126c 100644 --- a/tests/Factory/ServerRequestCreatorFactoryTest.php +++ b/tests/Factory/ServerRequestCreatorFactoryTest.php @@ -47,6 +47,7 @@ public static function provideImplementations() * @param string $psr17factory * @param string $expectedServerRequestClass */ + #[\PHPUnit\Framework\Attributes\DataProvider('provideImplementations')] public function testCreateAppWithAllImplementations(string $psr17factory, string $expectedServerRequestClass) { Psr17FactoryProvider::setFactories([$psr17factory]); @@ -72,6 +73,7 @@ public function testDetermineServerRequestCreatorReturnsDecoratedServerRequestCr /** * @runInSeparateProcess - Psr17FactoryProvider::setFactories breaks other tests */ + #[\PHPUnit\Framework\Attributes\RunInSeparateProcess] public function testDetermineServerRequestCreatorThrowsRuntimeException() { $this->expectException(RuntimeException::class); @@ -96,6 +98,7 @@ public function testSetPsr17FactoryProvider() /** * @runInSeparateProcess - ServerRequestCreatorFactory::setServerRequestCreator breaks other tests */ + #[\PHPUnit\Framework\Attributes\RunInSeparateProcess] public function testSetServerRequestCreatorWithoutDecorators() { ServerRequestCreatorFactory::setSlimHttpDecoratorsAutomaticDetection(false); @@ -117,6 +120,7 @@ public function testSetServerRequestCreatorWithoutDecorators() /** * @runInSeparateProcess - ServerRequestCreatorFactory::setServerRequestCreator breaks other tests */ + #[\PHPUnit\Framework\Attributes\RunInSeparateProcess] public function testSetServerRequestCreatorWithDecorators() { ServerRequestCreatorFactory::setSlimHttpDecoratorsAutomaticDetection(true); diff --git a/tests/Middleware/BodyParsingMiddlewareTest.php b/tests/Middleware/BodyParsingMiddlewareTest.php index 67548416a..c6f11512d 100644 --- a/tests/Middleware/BodyParsingMiddlewareTest.php +++ b/tests/Middleware/BodyParsingMiddlewareTest.php @@ -148,6 +148,7 @@ public static function parsingProvider() /** * @dataProvider parsingProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('parsingProvider')] public function testParsing($contentType, $body, $expected) { $request = $this->createRequestWithBody($contentType, $body); diff --git a/tests/MiddlewareDispatcherTest.php b/tests/MiddlewareDispatcherTest.php index 4af63d808..be1cc12f3 100644 --- a/tests/MiddlewareDispatcherTest.php +++ b/tests/MiddlewareDispatcherTest.php @@ -157,6 +157,7 @@ public static function deferredCallableProvider(): array * @param string $callable * @param callable|MiddlewareInterface */ + #[\PHPUnit\Framework\Attributes\DataProvider('deferredCallableProvider')] public function testDeferredResolvedCallableWithContainerAndNonAdvancedCallableResolverUnableToResolveCallable( $callable, $result diff --git a/tests/Routing/FastRouteDispatcherTest.php b/tests/Routing/FastRouteDispatcherTest.php index 399816049..48e575ac4 100644 --- a/tests/Routing/FastRouteDispatcherTest.php +++ b/tests/Routing/FastRouteDispatcherTest.php @@ -23,6 +23,7 @@ class FastRouteDispatcherTest extends TestCase /** * @dataProvider provideFoundDispatchCases */ + #[\PHPUnit\Framework\Attributes\DataProvider('provideFoundDispatchCases')] public function testFoundDispatches($method, $uri, $callback, $handler, $argDict) { /** @var FastRouteDispatcher $dispatcher */ @@ -59,6 +60,7 @@ protected function getDispatcherClass() /** * @dataProvider provideNotFoundDispatchCases */ + #[\PHPUnit\Framework\Attributes\DataProvider('provideNotFoundDispatchCases')] public function testNotFoundDispatches($method, $uri, $callback) { /** @var FastRouteDispatcher $dispatcher */ @@ -76,6 +78,7 @@ public function testNotFoundDispatches($method, $uri, $callback) * @param $callback * @param $allowedMethods */ + #[\PHPUnit\Framework\Attributes\DataProvider('provideMethodNotAllowedDispatchCases')] public function testMethodNotAllowedDispatches($method, $uri, $callback, $allowedMethods) { /** @var FastRouteDispatcher $dispatcher */ @@ -93,6 +96,7 @@ public function testMethodNotAllowedDispatches($method, $uri, $callback, $allowe * @param $callback * @param $allowedMethods */ + #[\PHPUnit\Framework\Attributes\DataProvider('provideMethodNotAllowedDispatchCases')] public function testGetAllowedMethods($method, $uri, $callback, $allowedMethods) { /** @var FastRouteDispatcher $dispatcher */ diff --git a/tests/Routing/RouteContextTest.php b/tests/Routing/RouteContextTest.php index 8f28985c0..7dfec8ecf 100644 --- a/tests/Routing/RouteContextTest.php +++ b/tests/Routing/RouteContextTest.php @@ -82,6 +82,7 @@ public static function requiredRouteContextRequestAttributes(): array * @dataProvider requiredRouteContextRequestAttributes * @param string $attribute */ + #[\PHPUnit\Framework\Attributes\DataProvider('requiredRouteContextRequestAttributes')] public function testCannotCreateInstanceIfRequestIsMissingAttributes(string $attribute): void { $this->expectException(RuntimeException::class); diff --git a/tests/Routing/RouteParserTest.php b/tests/Routing/RouteParserTest.php index 71579f236..e16036620 100644 --- a/tests/Routing/RouteParserTest.php +++ b/tests/Routing/RouteParserTest.php @@ -122,6 +122,7 @@ public function testBasePathIsIgnoreInRelativePathFor() * @param $queryParams * @param $expectedResult */ + #[\PHPUnit\Framework\Attributes\DataProvider('urlForCases')] public function testUrlForWithBasePath($withBasePath, $pattern, $arguments, $queryParams, $expectedResult) { $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class); diff --git a/tests/Routing/RouteResolverTest.php b/tests/Routing/RouteResolverTest.php index 42a0d94e3..efb3df06a 100644 --- a/tests/Routing/RouteResolverTest.php +++ b/tests/Routing/RouteResolverTest.php @@ -40,6 +40,7 @@ public static function computeRoutingResultsDataProvider(): array * @param string $uri The request uri * @param string $expectedUri The expected uri after transformation in the computeRoutingResults() */ + #[\PHPUnit\Framework\Attributes\DataProvider('computeRoutingResultsDataProvider')] public function testComputeRoutingResults(string $method, string $uri, string $expectedUri) { $routeCollectorProphecy = $this->prophesize(RouteCollectorInterface::class); From c271a94c4382da9b7181a15bcd50b0a8064fbc32 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Sat, 20 Sep 2025 12:33:45 +0200 Subject: [PATCH 08/15] Allow phpunit 12 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f0cc5eafd..aa966cab3 100644 --- a/composer.json +++ b/composer.json @@ -65,7 +65,7 @@ "phpspec/prophecy": "^1.19", "phpspec/prophecy-phpunit": "^2.1", "phpstan/phpstan": "^1 || ^2", - "phpunit/phpunit": "^9.6 || ^10 || ^11", + "phpunit/phpunit": "^9.6 || ^10 || ^11 || ^12", "slim/http": "^1.3", "slim/psr7": "^1.6", "squizlabs/php_codesniffer": "^3.10", From 419c6e2865d20ab921b85c2089a40bd2a1eb4f34 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Sat, 20 Sep 2025 17:37:04 +0200 Subject: [PATCH 09/15] Bump actions/checkout to v5 --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 87dbf99fa..b0f8de873 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,7 +18,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Set up PHP ${{ matrix.php }} uses: shivammathur/setup-php@v2 From c7d6ea0462c1ffcb6cf72d358889b9c17e4f66ba Mon Sep 17 00:00:00 2001 From: William Desportes Date: Sat, 20 Sep 2025 17:38:19 +0200 Subject: [PATCH 10/15] Add GitHub token permissions --- .github/workflows/tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b0f8de873..4133646f8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,5 +1,8 @@ name: Tests +permissions: + contents: read + on: [push, pull_request] jobs: From 3497652b83018a668ec39005a1dec8605aa3371f Mon Sep 17 00:00:00 2001 From: William Desportes Date: Sat, 20 Sep 2025 17:38:36 +0200 Subject: [PATCH 11/15] Use coveralls GH action --- .github/workflows/tests.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4133646f8..8f8e22832 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -50,8 +50,7 @@ jobs: - name: Upload coverage results to Coveralls if: matrix.analysis - env: - COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - composer require php-coveralls/php-coveralls -n -W - vendor/bin/php-coveralls --coverage_clover=clover.xml -v + uses: coverallsapp/github-action@v2 + with: + flag-name: php-${{ matrix.php }} + files: clover.xml From 037aa354cadfa86b9fc19c16044374b8f745d324 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Sat, 20 Sep 2025 17:43:34 +0200 Subject: [PATCH 12/15] Only do coverage if we send it to Coveralls --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8f8e22832..3be993414 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -46,7 +46,7 @@ jobs: run: vendor/bin/phpstan - name: Tests - run: vendor/bin/phpunit --coverage-clover clover.xml + run: vendor/bin/phpunit ${{ matrix.analysis && '--coverage-clover clover.xml' || '--no-coverage' }} - name: Upload coverage results to Coveralls if: matrix.analysis From aed61348f30acb01b328776612f32d8e1e4275ed Mon Sep 17 00:00:00 2001 From: William Desportes Date: Sat, 20 Sep 2025 17:47:12 +0200 Subject: [PATCH 13/15] Migrate the configuration for recent phpunit versions --- phpunit.xml.dist | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 95801f435..5c837c614 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,11 +1,12 @@ @@ -13,13 +14,14 @@ tests/Mocks - - - - Slim - + + + + Slim + + From f190e6025bb53de6c37f34db56ff967d0360174a Mon Sep 17 00:00:00 2001 From: William Desportes Date: Sat, 20 Sep 2025 17:41:12 +0200 Subject: [PATCH 14/15] Simplify the matrix by using composer options and test nightly --- .github/workflows/tests.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3be993414..e7fd8a78e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,9 +15,13 @@ jobs: matrix: php: [7.4, 8.0, 8.1, 8.2, 8.3, 8.4] experimental: [false] + composer-options: [''] include: - php: 8.2 analysis: true + - php: nightly + experimental: true + composer-options: '--ignore-platform-req=php+' steps: - name: Checkout @@ -30,12 +34,7 @@ jobs: coverage: xdebug - name: Install dependencies with Composer - if: matrix.php < '8.4' - run: composer update --prefer-dist --no-progress --no-interaction --ansi - - - name: Install dependencies with Composer - if: matrix.php >= '8.4' - run: composer update --prefer-dist --no-progress --no-interaction --ansi --ignore-platform-reqs + run: composer update --prefer-dist --no-progress --no-interaction --ansi ${{ matrix.composer-options }} - name: Coding standards if: matrix.analysis From d2a99757e77d51e3c8f112bc0cf868d24441da3d Mon Sep 17 00:00:00 2001 From: William Desportes Date: Sat, 20 Sep 2025 17:59:16 +0200 Subject: [PATCH 15/15] Do not export MAINTAINERS.md and psalm.xml --- .gitattributes | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitattributes b/.gitattributes index eaddab84c..3bf0f2918 100644 --- a/.gitattributes +++ b/.gitattributes @@ -10,9 +10,11 @@ /.gitignore export-ignore /CODE_OF_CONDUCT.md export-ignore /CONTRIBUTING.md export-ignore +/MAINTAINERS.md export-ignore /README.md export-ignore /UPGRADING.md export-ignore /phpcs.xml.dist export-ignore /phpstan.neon.dist export-ignore /phpunit.xml.dist export-ignore +/psalm.xml export-ignore /tests export-ignore