Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / symfony / http-kernel / Tests / DependencyInjection / RegisterControllerArgumentLocatorsPassTest.php
index 4016deb4ab294f78d2d3e269a63d2b8bdb234859..ca121c732711e51aaa2c412c8c10d72ef1c8e550 100644 (file)
@@ -13,13 +13,14 @@ namespace Symfony\Component\HttpKernel\Tests\DependencyInjection;
 
 use PHPUnit\Framework\TestCase;
 use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
+use Symfony\Component\DependencyInjection\ChildDefinition;
 use Symfony\Component\DependencyInjection\ContainerAwareInterface;
 use Symfony\Component\DependencyInjection\ContainerAwareTrait;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\ContainerInterface;
+use Symfony\Component\DependencyInjection\Reference;
 use Symfony\Component\DependencyInjection\ServiceLocator;
 use Symfony\Component\DependencyInjection\TypedReference;
-use Symfony\Component\DependencyInjection\Reference;
 use Symfony\Component\HttpKernel\DependencyInjection\RegisterControllerArgumentLocatorsPass;
 
 class RegisterControllerArgumentLocatorsPassTest extends TestCase
@@ -326,6 +327,29 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
         $locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0);
         $this->assertEmpty($locator);
     }
+
+    public function testBindingsOnChildDefinitions()
+    {
+        $container = new ContainerBuilder();
+        $resolver = $container->register('argument_resolver.service')->addArgument(array());
+
+        $container->register('parent', ArgumentWithoutTypeController::class);
+
+        $container->setDefinition('child', (new ChildDefinition('parent'))
+            ->setBindings(array('$someArg' => new Reference('parent')))
+            ->addTag('controller.service_arguments')
+        );
+
+        $pass = new RegisterControllerArgumentLocatorsPass();
+        $pass->process($container);
+
+        $locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0);
+        $this->assertInstanceOf(ServiceClosureArgument::class, $locator['child:fooAction']);
+
+        $locator = $container->getDefinition((string) $locator['child:fooAction']->getValues()[0])->getArgument(0);
+        $this->assertInstanceOf(ServiceClosureArgument::class, $locator['someArg']);
+        $this->assertEquals(new Reference('parent'), $locator['someArg']->getValues()[0]);
+    }
 }
 
 class RegisterTestController