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;
$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();