From b9cd10701811150d803d055d17ac53cb03bfa845 Mon Sep 17 00:00:00 2001 From: Martin Hujer Date: Wed, 21 Feb 2018 20:34:57 +0100 Subject: [PATCH] tests: add aliases for private services --- .../MonologTracyExtensionTest.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/DependencyInjection/MonologTracyExtensionTest.php b/tests/DependencyInjection/MonologTracyExtensionTest.php index e3d4ebd..cc8408f 100644 --- a/tests/DependencyInjection/MonologTracyExtensionTest.php +++ b/tests/DependencyInjection/MonologTracyExtensionTest.php @@ -15,6 +15,7 @@ use Nella\MonologTracy\BlueScreenHandler; use Symfony\Bundle\MonologBundle\DependencyInjection\MonologExtension; use Symfony\Component\Config\FileLocator; +use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; use Symfony\Component\DependencyInjection\Reference; @@ -272,11 +273,18 @@ public function testCollapsePaths() public function testHandlerInstance() { $this->load(); + + // alias private service with public alias so it can be fetched from container + $this->container->setAlias( + 'bluescreenhandler', + new Alias(MonologTracyExtension::BLUESCREEN_HANDLER_SERVICE_ID, TRUE) + ); + $this->compile(); @mkdir($this->container->getParameter(MonologTracyExtension::LOG_DIRECTORY_PARAMETER), 0777, TRUE); - $handler = $this->container->get(MonologTracyExtension::BLUESCREEN_HANDLER_SERVICE_ID); + $handler = $this->container->get('bluescreenhandler'); $this->assertInstanceOf(BlueScreenHandler::class, $handler); } @@ -285,11 +293,18 @@ public function testHandlerInstanceWithPanel() $this->load([], [ 'sectionPanels.yml', ]); + + // alias private service with public alias so it can be fetched from container + $this->container->setAlias( + 'bluescreenhandler', + new Alias(MonologTracyExtension::BLUESCREEN_HANDLER_SERVICE_ID, TRUE) + ); + $this->compile(); @mkdir($this->container->getParameter(MonologTracyExtension::LOG_DIRECTORY_PARAMETER), 0777, TRUE); - $handler = $this->container->get(MonologTracyExtension::BLUESCREEN_HANDLER_SERVICE_ID); + $handler = $this->container->get('bluescreenhandler'); $this->assertInstanceOf(BlueScreenHandler::class, $handler); }