public resolve ( Nelmio\Alice\Definition\ValueInterface $value, Nelmio\Alice\FixtureInterface $fixture, |
||
$value | Nelmio\Alice\Definition\ValueInterface | |
$fixture | Nelmio\Alice\FixtureInterface | |
$fixtureSet | ||
$scope | array | |
$context | ||
return |
public function resolve(ValueInterface $value, FixtureInterface $fixture, ResolvedFixtureSet $fixtureSet, array $scope, GenerationContext $context) : ResolvedValueWithFixtureSet
{
if (null === $this->resolver) {
throw ResolverNotFoundExceptionFactory::createUnexpectedCall(__METHOD__);
}
list($referredFixtureId, $fixtureSet) = $this->getReferredFixtureId($this->resolver, $value, $fixture, $fixtureSet, $scope, $context);
return $this->decoratedResolver->resolve(new FixtureReferenceValue($referredFixtureId), $fixture, $fixtureSet, $scope, $context);
}
/** * @expectedException \Nelmio\Alice\Throwable\Exception\Generator\Resolver\UnresolvableValueException * @expectedExceptionMessage Expected fixture reference value "@bob" to be resolved into a string. Got "(integer) 200" instead. */ public function testThrowsAnExceptionIfResolvedIdIsInvalid() { $idValue = new DummyValue('bob'); $value = new FixtureReferenceValue($idValue); $dummyFixture = new SimpleFixture('dummy', 'Dummy', SpecificationBagFactory::create()); $set = ResolvedFixtureSetFactory::create(); $scope = []; $context = new GenerationContext(); $valueResolverProphecy = $this->prophesize(ValueResolverInterface::class); $valueResolverProphecy->resolve(Argument::cetera())->willReturn(new ResolvedValueWithFixtureSet(200, ResolvedFixtureSetFactory::create())); /** @var ValueResolverInterface $valueResolver */ $valueResolver = $valueResolverProphecy->reveal(); $resolver = new UnresolvedFixtureReferenceIdResolver(new FakeChainableValueResolver(), $valueResolver); $resolver->resolve($value, $dummyFixture, $set, $scope, $context); }