public resolve ( |
||
$unresolvedParameters | ||
$injectedParameters | ||
Résultat |
public function testResolvesBagWithInjectedParameters() { $unresolvedParameters = new ParameterBag(['foo' => '(unresolved) bar', 'ping' => '(unresolved) pong']); $injectedParameters = new ParameterBag(['other_param' => 'oï']); $decoratedResolverProphecy = $this->prophesize(ParameterResolverInterface::class); $decoratedResolverProphecy->resolve(new Parameter('foo', '(unresolved) bar'), $unresolvedParameters, $injectedParameters, new ResolvingContext('foo'))->willReturn(new ParameterBag(['other_param' => 'yo', 'foo' => 'bar'])); $decoratedResolverProphecy->resolve(new Parameter('ping', '(unresolved) pong'), $unresolvedParameters, new ParameterBag(['other_param' => 'yo', 'foo' => 'bar']), new ResolvingContext('ping'))->willReturn(new ParameterBag(['other_param' => 'yo', 'foo' => 'bar', 'ping' => 'pong'])); /* @var ParameterResolverInterface $decoratedResolver */ $decoratedResolver = $decoratedResolverProphecy->reveal(); $resolver = new SimpleParameterBagResolver($decoratedResolver); $result = $resolver->resolve($unresolvedParameters, $injectedParameters); $this->assertEquals(new ParameterBag(['other_param' => 'yo', 'foo' => 'bar', 'ping' => 'pong']), $result); }
/** * @expectedException \Nelmio\Alice\Throwable\Exception\ParameterNotFoundException */ public function testThrowExceptionWhenResolvingNonExistentParameter() { $this->resolver->resolve(new ParameterBag(['param1' => '<{inexisting_param}>'])); }