Nelmio\Alice\Generator\Resolver\Value\Chainable\UnresolvedFixtureReferenceIdResolver::resolve PHP Method

resolve() public method

public resolve ( Nelmio\Alice\Definition\ValueInterface $value, Nelmio\Alice\FixtureInterface $fixture, ResolvedFixtureSet $fixtureSet, array $scope, GenerationContext $context ) : ResolvedValueWithFixtureSet
$value Nelmio\Alice\Definition\ValueInterface
$fixture Nelmio\Alice\FixtureInterface
$fixtureSet Nelmio\Alice\Generator\ResolvedFixtureSet
$scope array
$context Nelmio\Alice\Generator\GenerationContext
return Nelmio\Alice\Generator\ResolvedValueWithFixtureSet
    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);
    }

Usage Example

 /**
  * @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);
 }