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
Hey! After upgrading from 4.25.2 to 4.26.1 (Checked with 4.25.0 aswell), the controller tests fail with phpunit 11, when Attributes are being nested. (Symfony: 7.0.6, PHP 8.3)
Reproduce:
use OpenApi\Attributes as OA;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\AsController;
use Symfony\Component\Routing\Attribute\Route;
#[AsController]
final class SimpleController
{
#[OA\Get(
operationId: 'simpleController',
description: 'A simple Controller',
summary: 'Returns a simple response.',
tags: ['Simple'],
responses: [
new OA\Response(
response: 200,
description: 'The Response attribute nested inside the Get attribute.',
content: new OA\MediaType(
mediaType: 'application/json',
schema: new OA\Schema(type: 'string', example: 'simple'),
example: 'simple'
)
),
]
)]
#[Route(path: '/simple', name: 'simple', methods: ['GET'], format: 'json')]
public function __invoke(): Response
{
return new JsonResponse('simple');
}
}
The failing test:
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
final class SimpleControllerTest extends WebTestCase
{
public function testSimpleController(): void
{
$client = self::createClient();
$client->request('GET', '/simple');
self::assertResponseIsSuccessful();
self::assertSame('"simple"', $client->getResponse()->getContent());
}
}
I was not able to pinpoint the exact line where the code breaks, was only able to observe that the test works when excluding the "responses" array from the Get attribute. When moving the Response to a separate attribute, it also only works when removing the MediaType from it.
The logged exception was also not very helpful here (for me at least):
Version
4.26.0
Description
Hey! After upgrading from 4.25.2 to 4.26.1 (Checked with 4.25.0 aswell), the controller tests fail with phpunit 11, when Attributes are being nested. (Symfony: 7.0.6, PHP 8.3)
Reproduce:
The failing test:
I was not able to pinpoint the exact line where the code breaks, was only able to observe that the test works when excluding the "responses" array from the
Get
attribute. When moving theResponse
to a separate attribute, it also only works when removing theMediaType
from it.The logged exception was also not very helpful here (for me at least):
I hope you have an idea what the issue might be and that my example is sufficient to reproduce the bug.
Cheers!
Additional context
No response
The text was updated successfully, but these errors were encountered: