From c799161d0188cb25ca9765ec419d19fc0b1419c4 Mon Sep 17 00:00:00 2001 From: Christopher Hertel Date: Fri, 10 Nov 2023 23:04:24 +0100 Subject: [PATCH] fix move of CodeExtension --- Tests/ProfilerTest.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Tests/ProfilerTest.php b/Tests/ProfilerTest.php index 1f53d840..50fad6b7 100644 --- a/Tests/ProfilerTest.php +++ b/Tests/ProfilerTest.php @@ -8,10 +8,11 @@ use PHPUnit\Framework\TestCase as BaseTestCase; use Symfony\Bridge\Doctrine\Middleware\Debug\DebugDataHolder; use Symfony\Bridge\Doctrine\Middleware\Debug\Query; -use Symfony\Bridge\Twig\Extension\CodeExtension; +use Symfony\Bridge\Twig\Extension\CodeExtension as CodeExtensionLegacy; use Symfony\Bridge\Twig\Extension\HttpKernelExtension; use Symfony\Bridge\Twig\Extension\HttpKernelRuntime; use Symfony\Bridge\Twig\Extension\RoutingExtension; +use Symfony\Bundle\WebProfilerBundle\Profiler\CodeExtension; use Symfony\Bundle\WebProfilerBundle\Twig\WebProfilerExtension; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; @@ -24,6 +25,7 @@ use Twig\Loader\FilesystemLoader; use Twig\RuntimeLoader\RuntimeLoaderInterface; +use function class_exists; use function html_entity_decode; use function preg_match; use function preg_quote; @@ -62,7 +64,12 @@ public function setUp(): void $urlGenerator = $this->getMockBuilder(UrlGeneratorInterface::class)->getMock(); $urlGenerator->method('generate')->willReturn(''); - $this->twig->addExtension(new CodeExtension('', '', '')); + if (class_exists(CodeExtension::class)) { + $this->twig->addExtension(new CodeExtension('', '', '')); + } else { + $this->twig->addExtension(new CodeExtensionLegacy('', '', '')); + } + $this->twig->addExtension(new RoutingExtension($urlGenerator)); $this->twig->addExtension(new HttpKernelExtension()); /**