From 2c890ff93b58496ab1139ec4ad6fc7942e7f7584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zdene=CC=8Ck=20Drahos=CC=8C?= Date: Sat, 10 Jul 2021 18:00:11 +0200 Subject: [PATCH] Hotfix testing private service in Symfony < 5.3 https://github.com/nelmio/NelmioApiDocBundle/runs/3031148906?check_suite_focus=true#step:7:106 Error: Call to undefined method Nelmio\ApiDocBundle\Tests\Render\Html\GetNelmioAssetTest::getContainer() https://symfony.com/blog/new-in-symfony-4-1-simpler-service-testing In practice, tests based on WebTestCase and KernelTestCase now access to a special container via the static::$container property that allows fetching non-removed private services: https://github.com/symfony/symfony/blob/5.3/CHANGELOG-5.3.md#changelog-for-53x feature #40366 [FrameworkBundle] Add KernelTestCase::getContainer() (Nyholm) static $container @deprecated since Symfony 5.3, use static::getContainer() instead --- Tests/Render/Html/GetNelmioAssetTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Render/Html/GetNelmioAssetTest.php b/Tests/Render/Html/GetNelmioAssetTest.php index 2077a11..ce33be5 100644 --- a/Tests/Render/Html/GetNelmioAssetTest.php +++ b/Tests/Render/Html/GetNelmioAssetTest.php @@ -22,7 +22,7 @@ class GetNelmioAssetTest extends WebTestCase { static::bootKernel(); /** @var GetNelmioAsset $getNelmioAsset */ - $getNelmioAsset = self::getContainer()->get('nelmio_api_doc.render_docs.html.asset'); + $getNelmioAsset = static::$container->get('nelmio_api_doc.render_docs.html.asset'); $twigFunction = $getNelmioAsset->toTwigFunction($mode); self::assertSame($expectedContent, $twigFunction->getCallable()->__invoke($asset, $mode)); }