You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to migrate my project to API Platform 4.1, I'm encountering issues with my test suite.
In my tests, I automatically load my fixtures using the RefreshDatabaseTrait and I have an AbstractApiTestCase class that all my functional tests inherit from:
then the fixtures seem to load, but some of my tests are still failing. The failing tests appear to be those that make two requests in the same test, like this one:
publicfunctiontestInvalidPayload(): void
{
$client = self::createClient();
$user = static::getContainer()->get('doctrine')->getRepository(User::class)->findOneBy(['email' => '[email protected]']);
$client->loginUser($user);
$client->request('POST', '/users', [
'json' => [
'email' => 'new_user',
'firstName' => '',
'lastName' => '',
'role' => Role::USER->value,
],
]);
self::assertResponseStatusCodeSame(422);
self::assertJsonContains([
'violations' => [
['propertyPath' => 'email', 'message' => 'This value is not a valid email address.'],
['propertyPath' => 'firstName', 'message' => 'This value should not be blank.'],
['propertyPath' => 'lastName', 'message' => 'This value should not be blank.'],
],
]);
$client = self::createClient();
$client->loginUser($user);
$client->request('POST', '/users', [
'json' => [
'firstName' => 'John',
'lastName' => 'Doe',
'role' => Role::USER->value,
'email' => '',
],
]);
self::assertResponseStatusCodeSame(422);
self::assertJsonContains([
'violations' => [
['propertyPath' => 'email', 'message' => 'This value should not be blank.'],
],
]);
}
The second request fails with the following error:
{"code":401,"message":"JWT Token not found"}
I believe these changes are caused by this PR because if I revert all its changes, my tests pass correctly again.
Unfortunately, I cannot find what I can modify in my tests to fix this second issue (and I'm not sure if my first fix is the correct one).
Please tell me if there is anything I can do to help find the issue.
The text was updated successfully, but these errors were encountered:
API Platform version(s) affected: 4.1.0
Description
Hello,
When trying to migrate my project to API Platform 4.1, I'm encountering issues with my test suite.
In my tests, I automatically load my fixtures using the
RefreshDatabaseTrait
and I have anAbstractApiTestCase
class that all my functional tests inherit from:Since the migration, all my tests are failing because my fixtures are no longer loaded automatically.
I noticed that if I modify the
setUp
method in myAbstractApiTestCase
class to:then the fixtures seem to load, but some of my tests are still failing. The failing tests appear to be those that make two requests in the same test, like this one:
The second request fails with the following error:
I believe these changes are caused by this PR because if I revert all its changes, my tests pass correctly again.
Unfortunately, I cannot find what I can modify in my tests to fix this second issue (and I'm not sure if my first fix is the correct one).
Please tell me if there is anything I can do to help find the issue.
The text was updated successfully, but these errors were encountered: