b199e11dabe758a50829d0d4de63387eef3ce946
[yaffs-website] / vendor / symfony / http-kernel / Tests / DependencyInjection / LoggerPassTest.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\HttpKernel\Tests\DependencyInjection;
13
14 use PHPUnit\Framework\TestCase;
15 use Psr\Log\LoggerInterface;
16 use Symfony\Component\HttpKernel\DependencyInjection\LoggerPass;
17 use Symfony\Component\HttpKernel\Log\Logger;
18 use Symfony\Component\DependencyInjection\ContainerBuilder;
19
20 /**
21  * @author Kévin Dunglas <dunglas@gmail.com>
22  */
23 class LoggerPassTest extends TestCase
24 {
25     public function testAlwaysSetAutowiringAlias()
26     {
27         $container = new ContainerBuilder();
28         $container->register('logger', 'Foo');
29
30         (new LoggerPass())->process($container);
31
32         $this->assertFalse($container->getAlias(LoggerInterface::class)->isPublic());
33     }
34
35     public function testDoNotOverrideExistingLogger()
36     {
37         $container = new ContainerBuilder();
38         $container->register('logger', 'Foo');
39
40         (new LoggerPass())->process($container);
41
42         $this->assertSame('Foo', $container->getDefinition('logger')->getClass());
43     }
44
45     public function testRegisterLogger()
46     {
47         $container = new ContainerBuilder();
48         $container->setParameter('kernel.debug', false);
49
50         (new LoggerPass())->process($container);
51
52         $definition = $container->getDefinition('logger');
53         $this->assertSame(Logger::class, $definition->getClass());
54         $this->assertFalse($definition->isPublic());
55     }
56 }