123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- /*
- * This file is part of the Symfony framework.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * This source file is subject to the MIT license that is bundled
- * with this source code in the file LICENSE.
- */
- namespace Symfony\Tests\Component\DependencyInjection\Compiler;
- use Symfony\Component\DependencyInjection\Compiler\CheckDefinitionValidityPass;
- use Symfony\Component\DependencyInjection\ContainerInterface;
- use Symfony\Component\DependencyInjection\ContainerBuilder;
- class CheckDefinitionValidityPassTest extends \PHPUnit_Framework_TestCase
- {
- /**
- * @expectedException \RuntimeException
- */
- public function testProcessDetectsSyntheticNonPublicDefinitions()
- {
- $container = new ContainerBuilder();
- $container->register('a')->setSynthetic(true)->setPublic(false);
- $this->process($container);
- }
- /**
- * @expectedException \RuntimeException
- */
- public function testProcessDetectsSyntheticPrototypeDefinitions()
- {
- $container = new ContainerBuilder();
- $container->register('a')->setSynthetic(true)->setScope(ContainerInterface::SCOPE_PROTOTYPE);
- $this->process($container);
- }
- /**
- * @expectedException \RuntimeException
- */
- public function testProcessDetectsNonSyntheticNonAbstractDefinitionWithoutClass()
- {
- $container = new ContainerBuilder();
- $container->register('a')->setSynthetic(false)->setAbstract(false);
- $this->process($container);
- }
- public function testProcess()
- {
- $container = new ContainerBuilder();
- $container->register('a', 'class');
- $container->register('b', 'class')->setSynthetic(true)->setPublic(true);
- $container->register('c', 'class')->setAbstract(true);
- $container->register('d', 'class')->setSynthetic(true);
- $this->process($container);
- }
- protected function process(ContainerBuilder $container)
- {
- $pass = new CheckDefinitionValidityPass();
- $pass->process($container);
- }
- }
|