Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / symfony / dependency-injection / Tests / Compiler / ResolveHotPathPassTest.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\DependencyInjection\Tests\Compiler;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
16 use Symfony\Component\DependencyInjection\Compiler\ResolveHotPathPass;
17 use Symfony\Component\DependencyInjection\ContainerBuilder;
18 use Symfony\Component\DependencyInjection\Definition;
19 use Symfony\Component\DependencyInjection\Reference;
20
21 class ResolveHotPathPassTest extends TestCase
22 {
23     public function testProcess()
24     {
25         $container = new ContainerBuilder();
26
27         $container->register('foo')
28             ->addTag('container.hot_path')
29             ->addArgument(new IteratorArgument(array(new Reference('lazy'))))
30             ->addArgument(new Reference('service_container'))
31             ->addArgument(new Definition('', array(new Reference('bar'))))
32             ->addArgument(new Reference('baz', ContainerBuilder::IGNORE_ON_UNINITIALIZED_REFERENCE))
33             ->addArgument(new Reference('missing'))
34         ;
35
36         $container->register('lazy');
37         $container->register('bar')
38             ->addArgument(new Reference('buz'))
39             ->addArgument(new Reference('deprec_ref_notag'));
40         $container->register('baz')
41             ->addArgument(new Reference('lazy'))
42             ->addArgument(new Reference('lazy'));
43         $container->register('buz');
44         $container->register('deprec_with_tag')->setDeprecated()->addTag('container.hot_path');
45         $container->register('deprec_ref_notag')->setDeprecated();
46
47         (new ResolveHotPathPass())->process($container);
48
49         $this->assertFalse($container->getDefinition('lazy')->hasTag('container.hot_path'));
50         $this->assertTrue($container->getDefinition('bar')->hasTag('container.hot_path'));
51         $this->assertTrue($container->getDefinition('buz')->hasTag('container.hot_path'));
52         $this->assertFalse($container->getDefinition('baz')->hasTag('container.hot_path'));
53         $this->assertFalse($container->getDefinition('service_container')->hasTag('container.hot_path'));
54         $this->assertFalse($container->getDefinition('deprec_with_tag')->hasTag('container.hot_path'));
55         $this->assertFalse($container->getDefinition('deprec_ref_notag')->hasTag('container.hot_path'));
56     }
57 }