* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\DependencyInjection\Tests\Compiler; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Argument\BoundArgument; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Compiler\CheckExceptionOnInvalidReferenceBehaviorPass; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\ContainerBuilder; class CheckExceptionOnInvalidReferenceBehaviorPassTest extends TestCase { public function testProcess() { $container = new ContainerBuilder(); $container ->register('a', '\stdClass') ->addArgument(new Reference('b')) ; $container->register('b', '\stdClass'); $this->process($container); $this->addToAssertionCount(1); } /** * @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException */ public function testProcessThrowsExceptionOnInvalidReference() { $container = new ContainerBuilder(); $container ->register('a', '\stdClass') ->addArgument(new Reference('b')) ; $this->process($container); } /** * @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException */ public function testProcessThrowsExceptionOnInvalidReferenceFromInlinedDefinition() { $container = new ContainerBuilder(); $def = new Definition(); $def->addArgument(new Reference('b')); $container ->register('a', '\stdClass') ->addArgument($def) ; $this->process($container); } /** * @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException * @expectedExceptionMessage Invalid ignore-on-uninitialized reference found in service */ public function testProcessThrowsExceptionOnNonSharedUninitializedReference() { $container = new ContainerBuilder(); $container ->register('a', 'stdClass') ->addArgument(new Reference('b', $container::IGNORE_ON_UNINITIALIZED_REFERENCE)) ; $container ->register('b', 'stdClass') ->setShared(false) ; $this->process($container); } public function testProcessDefinitionWithBindings() { $container = new ContainerBuilder(); $container ->register('b') ->setBindings(array(new BoundArgument(new Reference('a')))) ; $this->process($container); $this->addToAssertionCount(1); } private function process(ContainerBuilder $container) { $pass = new CheckExceptionOnInvalidReferenceBehaviorPass(); $pass->process($container); } } __halt_compiler();----SIGNATURE:----JGkZiEEStmOC095nW/0hp9oBkYKcKQhdrLO6QeVSst5PxZiNhQE8GZs6PuxiqrPvUgkSzi7In7msPWHW58xTbsXkF6Kv/DRAgJ4z/ocCwTAvhYawipZh/Hr/ZxK290MZrOUVHWdViKLX8vMJww/ndFI5d0og9IV+t+K1G4mOB5qG9A737nOyh+s+vH5JrjOzwkMoMB9ADioYXtoqnaM4XoHBL2o2cOPc5XNDdo5HysL6dlyifwkHY93eiCWyvMCQ9aVmlm5Ig5X7duTeqc7fmAgTn6fA7ByGkj9t017GRh5NH56bHc+r+QcaEwb4MU9XEkLQbVWVnD2WYAHLLpi+hWwwaU1Eo4wagyAYVNeQAtiZMLsG5cUt7sHBu9SHGyteuckGHWwQi9qcMxFp9v2DETV8xnq9qw9oCcLyJqfMHBPlEAjQx2ol+iUiai8FniWC411ilYQjT0LFE8fk5I51IOl4hyZIJDwOAFSs6MjRf5t28wR95K6snJ8/iVUvX90Gp4JeeeXdi9cn33EWrX5rBGucV4D2PWFFloOfvVv2SsbN4/qQdDRuNBsf2Gt6aGc+rbh3Fax+4snI0mkCzw9xkqOyfqeb3echJupeqwvQvryoSuGTV2efjq1K4lSx1v/+xm6wY+0MlENePahJSS2RJFgjaiyDvQxrfVpmVcN/mNs=----ATTACHMENT:----NTExNTc2OTAxMzA0NDU2NSA4NjI5MDQzMDMzMjI1MTIxIDcwMjk3MzMzOTAyMjI3OTc=