Skip to content

Commit

Permalink
Update ApiTestCase FQCN to be compliant with ApiPlatform v3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
laryjulien committed Nov 17, 2021
1 parent 40b9b55 commit 7d95fae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/Maker/MakeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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' => PHP_VERSION_ID < 80100 && !class_exists(ApiTestCase::class) ? LegacyApiTestCase::class : ApiTestCase::class,
]
);

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/skeleton/test/ApiTestCase.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace <?= $namespace; ?>;

use ApiPlatform\Core\Bridge\Symfony\Bundle\Test\ApiTestCase;
use <?= $api_test_case_fqcn; ?>;

class <?= $class_name ?> extends ApiTestCase
{
Expand Down

0 comments on commit 7d95fae

Please sign in to comment.