4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\HttpKernel\Tests\DependencyInjection;
14 use PHPUnit\Framework\TestCase;
15 use Psr\Log\LoggerInterface;
16 use Symfony\Component\DependencyInjection\ContainerBuilder;
17 use Symfony\Component\HttpKernel\DependencyInjection\LoggerPass;
18 use Symfony\Component\HttpKernel\Log\Logger;
21 * @author Kévin Dunglas <dunglas@gmail.com>
23 class LoggerPassTest extends TestCase
25 public function testAlwaysSetAutowiringAlias()
27 $container = new ContainerBuilder();
28 $container->register('logger', 'Foo');
30 (new LoggerPass())->process($container);
32 $this->assertFalse($container->getAlias(LoggerInterface::class)->isPublic());
35 public function testDoNotOverrideExistingLogger()
37 $container = new ContainerBuilder();
38 $container->register('logger', 'Foo');
40 (new LoggerPass())->process($container);
42 $this->assertSame('Foo', $container->getDefinition('logger')->getClass());
45 public function testRegisterLogger()
47 $container = new ContainerBuilder();
48 $container->setParameter('kernel.debug', false);
50 (new LoggerPass())->process($container);
52 $definition = $container->getDefinition('logger');
53 $this->assertSame(Logger::class, $definition->getClass());
54 $this->assertFalse($definition->isPublic());