Skip to content

Commit

Permalink
Merge pull request #139 from sroze/uses-test-container-if-exists
Browse files Browse the repository at this point in the history
Uses the test container if exists
  • Loading branch information
sroze authored Apr 20, 2018
2 parents 022ece0 + d9d389c commit d7c8344
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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')
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d7c8344

Please sign in to comment.