Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / symfony / dependency-injection / Tests / Compiler / CheckExceptionOnInvalidReferenceBehaviorPassTest.php
index 65a782a4a83fc96981641e2226c80aa631d9cd85..ac002d834d1c5dbd030b57adcd1841ca3246c23c 100644 (file)
@@ -12,6 +12,7 @@
 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;
@@ -67,6 +68,41 @@ class CheckExceptionOnInvalidReferenceBehaviorPassTest extends TestCase
         $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();