diff --git a/Tests/ProfilerTest.php b/Tests/ProfilerTest.php index 1f53d840..e978d826 100644 --- a/Tests/ProfilerTest.php +++ b/Tests/ProfilerTest.php @@ -12,6 +12,7 @@ use Symfony\Bridge\Twig\Extension\HttpKernelExtension; use Symfony\Bridge\Twig\Extension\HttpKernelRuntime; use Symfony\Bridge\Twig\Extension\RoutingExtension; +use Symfony\Bundle\WebProfilerBundle\Profiler\CodeExtension as CodeExtensionV7; 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(CodeExtensionV7::class)) { + $this->twig->addExtension(new CodeExtensionV7('', '', '')); + } else { + $this->twig->addExtension(new CodeExtension('', '', '')); + } + $this->twig->addExtension(new RoutingExtension($urlGenerator)); $this->twig->addExtension(new HttpKernelExtension()); /**