diff --git a/spec/Behat/Symfony2Extension/Context/Argument/ServiceArgumentResolverSpec.php b/spec/Behat/Symfony2Extension/Context/Argument/ServiceArgumentResolverSpec.php index 052d5e3..6b6556d 100644 --- a/spec/Behat/Symfony2Extension/Context/Argument/ServiceArgumentResolverSpec.php +++ b/spec/Behat/Symfony2Extension/Context/Argument/ServiceArgumentResolverSpec.php @@ -14,6 +14,7 @@ class ServiceArgumentResolverSpec extends ObjectBehavior function let(KernelInterface $kernel, ContainerInterface $container) { $kernel->getContainer()->willReturn($container); + $container->has('test.service_container')->willReturn(false); $this->beConstructedWith($kernel); } @@ -150,4 +151,20 @@ function it_resolves_arrays_of_strings_starting_with_at_sign( array('array' => array($service1, $service2)) ); } + + function it_uses_the_test_service_container( + ReflectionClass $reflectionClass, + ContainerInterface $container, + ContainerInterface $testContainer + ) { + $testContainer->getParameter('parameter')->willReturn('param_value'); + $testContainer->hasParameter('parameter')->willReturn(true); + + $container->has('test.service_container')->willReturn(true); + $container->get('test.service_container')->willReturn($testContainer); + + $this->resolveArguments($reflectionClass, array('parameter' => '%parameter%'))->shouldReturn( + array('parameter' => 'param_value') + ); + } } diff --git a/src/Behat/Symfony2Extension/Context/Argument/ServiceArgumentResolver.php b/src/Behat/Symfony2Extension/Context/Argument/ServiceArgumentResolver.php index d594743..f2de109 100644 --- a/src/Behat/Symfony2Extension/Context/Argument/ServiceArgumentResolver.php +++ b/src/Behat/Symfony2Extension/Context/Argument/ServiceArgumentResolver.php @@ -70,6 +70,7 @@ private function resolveArgument($argument) } $container = $this->kernel->getContainer(); + $container = $container->has('test.service_container') ? $container->get('test.service_container') : $container; if ($service = $this->getService($container, $argument)) { return $service;