From 36babd9e34916f518166a6fcf50a8590faadd665 Mon Sep 17 00:00:00 2001 From: Ousama Ben Younes Date: Wed, 23 Sep 2026 22:51:13 +0000 Subject: [PATCH] fix(symfony): guard test client service when api-platform/test is absent Since 5.0 ApiTestCase and Client live in the split api-platform/test package. TestClientPass still registered test.api_platform.client -> ApiPlatform\Test\Client without checking the class exists, so lint:container failed when api-platform/test was not installed. Guard the registration with class_exists(Client::class). --- .../Bundle/DependencyInjection/Compiler/TestClientPass.php | 3 ++- .../Bundle/DependencyInjection/Compiler/TestClientPassTest.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/DependencyInjection/Compiler/TestClientPass.php b/src/Symfony/Bundle/DependencyInjection/Compiler/TestClientPass.php index bd0c4bddb65..c00bcdfc7ff 100644 --- a/src/Symfony/Bundle/DependencyInjection/Compiler/TestClientPass.php +++ b/src/Symfony/Bundle/DependencyInjection/Compiler/TestClientPass.php @@ -26,7 +26,8 @@ final class TestClientPass implements CompilerPassInterface public function process(ContainerBuilder $container): void { if ( - !class_exists(AbstractBrowser::class) + !class_exists(Client::class) + || !class_exists(AbstractBrowser::class) || !trait_exists(HttpClientTrait::class) || !$container->hasParameter('test.client.parameters') ) { diff --git a/tests/Symfony/Bundle/DependencyInjection/Compiler/TestClientPassTest.php b/tests/Symfony/Bundle/DependencyInjection/Compiler/TestClientPassTest.php index 3409af97d3a..0f939c43239 100644 --- a/tests/Symfony/Bundle/DependencyInjection/Compiler/TestClientPassTest.php +++ b/tests/Symfony/Bundle/DependencyInjection/Compiler/TestClientPassTest.php @@ -11,7 +11,7 @@ declare(strict_types=1); -namespace ApiPlatform\Tests\Symfony\Bundle\DependencyInjection\Compiler; +namespace ApiPlatform\Symfony\Bundle\DependencyInjection\Compiler; use ApiPlatform\Symfony\Bundle\DependencyInjection\Compiler\TestClientPass; use ApiPlatform\Test\Client;