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\DependencyInjection\Tests\Compiler;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\DependencyInjection\Compiler\CheckReferenceValidityPass;
16 use Symfony\Component\DependencyInjection\ContainerBuilder;
17 use Symfony\Component\DependencyInjection\Reference;
19 class CheckReferenceValidityPassTest extends TestCase
22 * @expectedException \RuntimeException
24 public function testProcessDetectsReferenceToAbstractDefinition()
26 $container = new ContainerBuilder();
28 $container->register('a')->setAbstract(true);
29 $container->register('b')->addArgument(new Reference('a'));
31 $this->process($container);
34 public function testProcess()
36 $container = new ContainerBuilder();
37 $container->register('a')->addArgument(new Reference('b'));
38 $container->register('b');
40 $this->process($container);
42 $this->addToAssertionCount(1);
45 protected function process(ContainerBuilder $container)
47 $pass = new CheckReferenceValidityPass();
48 $pass->process($container);