Security update for Core, with self-updated composer
[yaffs-website] / vendor / symfony / dependency-injection / Tests / Compiler / ResolveInvalidReferencesPassTest.php
index ad698d2bff48328105ef004c4eccfe9d717ec6fa..8cf4e5186cd1c7f719e68145ac8e094df2cb89c4 100644 (file)
@@ -24,59 +24,88 @@ class ResolveInvalidReferencesPassTest extends TestCase
         $container = new ContainerBuilder();
         $def = $container
             ->register('foo')
-            ->setArguments(array(new Reference('bar', ContainerInterface::NULL_ON_INVALID_REFERENCE)))
+            ->setArguments(array(
+                new Reference('bar', ContainerInterface::NULL_ON_INVALID_REFERENCE),
+                new Reference('baz', ContainerInterface::IGNORE_ON_INVALID_REFERENCE),
+            ))
             ->addMethodCall('foo', array(new Reference('moo', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)))
         ;
 
         $this->process($container);
 
         $arguments = $def->getArguments();
-        $this->assertNull($arguments[0]);
+        $this->assertSame(array(null, null), $arguments);
         $this->assertCount(0, $def->getMethodCalls());
     }
 
-    public function testProcessIgnoreNonExistentServices()
+    public function testProcessIgnoreInvalidArgumentInCollectionArgument()
     {
         $container = new ContainerBuilder();
+        $container->register('baz');
         $def = $container
             ->register('foo')
-            ->setArguments(array(new Reference('bar')))
+            ->setArguments(array(
+                array(
+                    new Reference('bar', ContainerInterface::IGNORE_ON_INVALID_REFERENCE),
+                    $baz = new Reference('baz', ContainerInterface::IGNORE_ON_INVALID_REFERENCE),
+                    new Reference('moo', ContainerInterface::NULL_ON_INVALID_REFERENCE),
+                ),
+            ))
         ;
 
         $this->process($container);
 
         $arguments = $def->getArguments();
-        $this->assertEquals('bar', (string) $arguments[0]);
+        $this->assertSame(array($baz, null), $arguments[0]);
     }
 
-    public function testProcessRemovesPropertiesOnInvalid()
+    public function testProcessKeepMethodCallOnInvalidArgumentInCollectionArgument()
     {
         $container = new ContainerBuilder();
+        $container->register('baz');
         $def = $container
             ->register('foo')
-            ->setProperty('foo', new Reference('bar', ContainerInterface::IGNORE_ON_INVALID_REFERENCE))
+            ->addMethodCall('foo', array(
+                array(
+                    new Reference('bar', ContainerInterface::IGNORE_ON_INVALID_REFERENCE),
+                    $baz = new Reference('baz', ContainerInterface::IGNORE_ON_INVALID_REFERENCE),
+                    new Reference('moo', ContainerInterface::NULL_ON_INVALID_REFERENCE),
+                ),
+            ))
         ;
 
         $this->process($container);
 
-        $this->assertEquals(array(), $def->getProperties());
+        $calls = $def->getMethodCalls();
+        $this->assertCount(1, $def->getMethodCalls());
+        $this->assertSame(array($baz, null), $calls[0][1][0]);
     }
 
-    /**
-     * @group legacy
-     */
-    public function testStrictFlagIsPreserved()
+    public function testProcessIgnoreNonExistentServices()
     {
         $container = new ContainerBuilder();
-        $container->register('bar');
         $def = $container
             ->register('foo')
-            ->addArgument(new Reference('bar', ContainerInterface::NULL_ON_INVALID_REFERENCE, false))
+            ->setArguments(array(new Reference('bar')))
         ;
 
         $this->process($container);
 
-        $this->assertFalse($def->getArgument(0)->isStrict());
+        $arguments = $def->getArguments();
+        $this->assertEquals('bar', (string) $arguments[0]);
+    }
+
+    public function testProcessRemovesPropertiesOnInvalid()
+    {
+        $container = new ContainerBuilder();
+        $def = $container
+            ->register('foo')
+            ->setProperty('foo', new Reference('bar', ContainerInterface::IGNORE_ON_INVALID_REFERENCE))
+        ;
+
+        $this->process($container);
+
+        $this->assertEquals(array(), $def->getProperties());
     }
 
     protected function process(ContainerBuilder $container)