231520cd70c079edaa2bb6441f55ea57907d037c
[yaffs-website] / vendor / symfony / dependency-injection / Tests / Compiler / CheckReferenceValidityPassTest.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\Compiler\CheckReferenceValidityPass;
16 use Symfony\Component\DependencyInjection\Reference;
17 use Symfony\Component\DependencyInjection\ContainerBuilder;
18
19 class CheckReferenceValidityPassTest extends TestCase
20 {
21     /**
22      * @expectedException \RuntimeException
23      */
24     public function testProcessDetectsReferenceToAbstractDefinition()
25     {
26         $container = new ContainerBuilder();
27
28         $container->register('a')->setAbstract(true);
29         $container->register('b')->addArgument(new Reference('a'));
30
31         $this->process($container);
32     }
33
34     public function testProcess()
35     {
36         $container = new ContainerBuilder();
37         $container->register('a')->addArgument(new Reference('b'));
38         $container->register('b');
39
40         $this->process($container);
41
42         $this->addToAssertionCount(1);
43     }
44
45     protected function process(ContainerBuilder $container)
46     {
47         $pass = new CheckReferenceValidityPass();
48         $pass->process($container);
49     }
50 }