From cc497f92b76a3408f308df386cd97e5e701b9786 Mon Sep 17 00:00:00 2001 From: Julien LARY <47776596+laryjulien@users.noreply.github.com> Date: Tue, 16 Nov 2021 23:26:35 +0100 Subject: [PATCH] Update ApiTestCase FQCN to be compliant with ApiPlatform v3.0 --- src/Maker/MakeTest.php | 8 +++++--- src/Resources/skeleton/test/ApiTestCase.tpl.php | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Maker/MakeTest.php b/src/Maker/MakeTest.php index 845dfe1dc6..944ab98cc3 100644 --- a/src/Maker/MakeTest.php +++ b/src/Maker/MakeTest.php @@ -11,7 +11,8 @@ namespace Symfony\Bundle\MakerBundle\Maker; -use ApiPlatform\Core\Bridge\Symfony\Bundle\Test\ApiTestCase; +use ApiPlatform\Core\Bridge\Symfony\Bundle\Test\ApiTestCase as LegacyApiTestCase; +use ApiPlatform\Symfony\Bundle\Test\ApiTestCase; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestAssertionsTrait; use Symfony\Bundle\MakerBundle\ConsoleStyle; @@ -103,7 +104,7 @@ public function interact(InputInterface $input, ConsoleStyle $io, Command $comma ); } - if ('ApiTestCase' === $input->getArgument('type') && !class_exists(ApiTestCase::class)) { + if ('ApiTestCase' === $input->getArgument('type') && !class_exists(ApiTestCase::class) && !class_exists(LegacyApiTestCase::class)) { $io->warning([ 'API Platform is required for this test type. Install it with', 'composer require api', @@ -148,6 +149,7 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen [ 'web_assertions_are_available' => trait_exists(WebTestAssertionsTrait::class), 'use_legacy_container_property' => $this->useLegacyContainerProperty(), + 'api_test_case_fqcn' => class_exists(ApiTestCase::class) ? ApiTestCase::class : LegacyApiTestCase::class, ] ); @@ -186,7 +188,7 @@ public function configureDependencies(DependencyBuilder $dependencies, InputInte case 'ApiTestCase': $dependencies->addClassDependency( - ApiTestCase::class, + PHP_VERSION_ID < 80100 && !class_exists(ApiTestCase::class) ? LegacyApiTestCase::class : ApiTestCase::class, 'api', true, false diff --git a/src/Resources/skeleton/test/ApiTestCase.tpl.php b/src/Resources/skeleton/test/ApiTestCase.tpl.php index 48d3545059..2f55519f45 100644 --- a/src/Resources/skeleton/test/ApiTestCase.tpl.php +++ b/src/Resources/skeleton/test/ApiTestCase.tpl.php @@ -2,7 +2,7 @@ namespace ; -use ApiPlatform\Core\Bridge\Symfony\Bundle\Test\ApiTestCase; +use ; class extends ApiTestCase {