From 6e8cdb7240f8f87285ccca818d40284e2792c05f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Thu, 14 May 2026 01:00:49 +0200 Subject: [PATCH] [Tests] Fix CI failures in TemplateLinterTest and invokable controller test TemplateLinterTest asserts on verbose output from the linter, but writeLinterMessage() is only called when the output is verbose. Pass -v explicitly to runMaker() instead of relying on SHELL_VERBOSITY being inherited from the PHPUnit parent process. The invokable controller fixture was calling the controller directly without a request in the RequestStack, causing Twig to crash on app.request.server (null) after the Flex base.html.twig recipe update. Push a synthetic Request onto the RequestStack before invoking. --- tests/Maker/TemplateLinterTest.php | 6 +++--- .../tests/it_generates_an_invokable_controller.php | 13 ++++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/Maker/TemplateLinterTest.php b/tests/Maker/TemplateLinterTest.php index 7c235cd35..f5aa40cb4 100644 --- a/tests/Maker/TemplateLinterTest.php +++ b/tests/Maker/TemplateLinterTest.php @@ -47,7 +47,7 @@ public static function getTestDetails(): \Generator ); // Voter class name - $output = $runner->runMaker(['FooBar']); + $output = $runner->runMaker(['FooBar'], '-v'); $generatedTemplate = file_get_contents($runner->getPath('src/Security/Voter/FooBarVoter.php')); @@ -73,7 +73,7 @@ public static function getTestDetails(): \Generator ); // Voter class name - $output = $runner->runMaker(['FooBar']); + $output = $runner->runMaker(['FooBar'], '-v'); $generatedTemplate = file_get_contents($runner->getPath('src/Security/Voter/FooBarVoter.php')); @@ -87,7 +87,7 @@ public static function getTestDetails(): \Generator yield 'lints_templates_with_bundled_php_cs_fixer' => [self::buildMakerTest() ->run(static function (MakerTestRunner $runner) { // Voter class name - $output = $runner->runMaker(['FooBar']); + $output = $runner->runMaker(['FooBar'], '-v'); $expectedOutput = 'Bundled PHP-CS-Fixer & Bundled PHP-CS-Fixer Configuration'; self::assertStringContainsString($expectedOutput, $output); diff --git a/tests/fixtures/make-controller/tests/it_generates_an_invokable_controller.php b/tests/fixtures/make-controller/tests/it_generates_an_invokable_controller.php index 6e6a80a22..09e4077ce 100644 --- a/tests/fixtures/make-controller/tests/it_generates_an_invokable_controller.php +++ b/tests/fixtures/make-controller/tests/it_generates_an_invokable_controller.php @@ -3,6 +3,8 @@ namespace App\Tests; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; final class GeneratedControllerTest extends WebTestCase { @@ -16,11 +18,16 @@ public function testControllerValidity() public function testControllerInvokability() { - $kernel = self::bootKernel(); - $controller = $kernel->getContainer()->get('App\Controller\FooInvokableController'); + self::bootKernel(); + $container = static::getContainer(); + + $controller = $container->get('App\Controller\FooInvokableController'); $this->assertIsCallable($controller); + $request = Request::create('/foo/invokable'); + $container->get('request_stack')->push($request); + $response = $controller(); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response); + $this->assertInstanceOf(Response::class, $response); } }