Skip to content

Commit 06ab798

Browse files
committed
Fix profiler test failure with symfony 6.2
Fixes ``` 1) Doctrine\Bundle\DoctrineBundle\Tests\ProfilerTest::testRender Twig\Error\RuntimeError: Impossible to access an attribute ("statusText") on a boolean variable (""). /home/runner/work/DoctrineBundle/DoctrineBundle/vendor/symfony/web-profiler-bundle/Resources/views/Profiler/layout.html.twig:64 ```
1 parent 1af518a commit 06ab798

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Tests/ProfilerTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
use Symfony\Bridge\Twig\Extension\RoutingExtension;
1414
use Symfony\Bundle\WebProfilerBundle\Twig\WebProfilerExtension;
1515
use Symfony\Component\HttpFoundation\Request;
16+
use Symfony\Component\HttpFoundation\RequestStack;
1617
use Symfony\Component\HttpFoundation\Response;
18+
use Symfony\Component\HttpKernel\DataCollector\RequestDataCollector;
1719
use Symfony\Component\HttpKernel\Fragment\FragmentHandler;
1820
use Symfony\Component\HttpKernel\Profiler\Profile;
1921
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
@@ -91,6 +93,15 @@ public function testRender(): void
9193

9294
$profile = new Profile('foo');
9395
$profile->setMethod('GET');
96+
$requestStack = new RequestStack();
97+
$requestStack->push($request);
98+
99+
/** @psalm-suppress TooManyArguments Since Symfony 5.2 */
100+
$requestDataCollector = new RequestDataCollector($requestStack);
101+
$requestDataCollector->collect($request, new Response());
102+
$requestDataCollector->lateCollect();
103+
104+
$profile->addCollector($requestDataCollector);
94105

95106
$output = $this->twig->render('db.html.twig', [
96107
'request' => $request,

0 commit comments

Comments
 (0)