-
-
Notifications
You must be signed in to change notification settings - Fork 437
Closed
Labels
Description
Symfony version(s) affected
6.0.x
Description
Generating a new ApiTestCase via cli results in failing tests. It seems as the generator uses the wrong class path.
How to reproduce
run
symfony new --dir .
composer require symfony/maker-bundle symfony/test-pack symfony/http-client --dev
php bin/console make:test
# > ApiTestCase
# > Example
composer require api
php bin/phpunitresults in
PHP Fatal error: Uncaught Error: Class "ApiPlatform\Symfony\Bundle\Test\ApiTestCase" not found in [...]/tests/ExampleTest.php:7
Possible Solution
In the resulting tests/ExampleTest.php, cange the import:
<?php
namespace App\Tests;
-use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
+use ApiPlatform\Core\Bridge\Symfony\Bundle\Test\ApiTestCase;
class ExampleTest extends ApiTestCase
{
public function testSomething(): void
{
$response = static::createClient()->request('GET', '/');
$this->assertResponseIsSuccessful();
$this->assertJsonContains(['@id' => '/']);
}
}Additional Context
PHP 8.1.3
Symfony CLI version 5.4.7
gladx