* * 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:----paGqZwiJTQQUv3chgo5JB1RrH7o0d+1+txGhd4zPY55zH5P56LELJGDZlgRLB0Zg7tGaL8Rf1qdURorXhSgkwOIgWseFjR2S5Tila0iqJ6Wp49uRXx8XusRaX7oQ5SYhnxA9tqplt0aAfOTmN8AEMo7tZXxKims6gNu6pYQn8uLraxWyH+lTLjBY1Je91T5vdoJWAaRlbi60X4tQgV1FyMk2mRe924OOHbtOVjnMc0wnVR1jvDnsKCZws+PxjWsVHPH0QVXhRpF8HJluvvaWt0lb/xQtn9LUCY7WH+DMBrzJ56+mvb1WHGEG0jgM2ItYDTANyKP1yIsvLq5LIhNtVaiaWp73SKtfFy5kY0m/CvL4IznHmZ8qFmLighbQez/iL+II61SjcBYYWmObGDial+lSe6F6A8bO58y7KksPPrxVATBL6DcWToK4kI3L1THl0TqnzTlaNFo0ei4kmyFpKvQdx5pXz701yccToJzUn/HNxnHYefQeOUbNjtqvFWAMuZKLZLbckpEWEeeiuWyJkW+WlkBqSV0lvEV8kVrSsDKfvZNY5PHWj0uXVqNGjDDltjHPnAfrkVT/ZmW7iaQGB8rxLeuTaoIULkh1EdUC2X8dlOfkpr3Vv6ieZ7nnuIsb70MnKx4C6Bq5XZVlApicXk5t13+50MREQAUa+eRa8sI=----ATTACHMENT:----NzE4ODIxMDEyODgyNjQ0NSA4MDc1NDA5NTc2NzUwMzg2IDU1MzMxOTI3NjIwOTU0ODU=