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__);
}
$possibleIds = $this->getSuitableIds($value, $fixtureSet);
$id = Base::randomElement($possibleIds);
if (null === $id) {
throw UnresolvableValueExceptionFactory::createForNoFixtureOrObjectMatchingThePattern($value);
}
return $this->resolver->resolve(new FixtureReferenceValue($id), $fixture, $fixtureSet, $scope, $context);
}
/** * @expectedException \Nelmio\Alice\Throwable\Exception\Generator\Resolver\UnresolvableValueException * @expectedExceptionMessage Could not find a fixture or object ID matching the pattern */ public function testThrowsAnExceptionIfNotMathcingIdFound() { $value = FixtureMatchReferenceValue::createWildcardReference('dummy'); $fixture = new DummyFixture('injected_fixture'); $set = ResolvedFixtureSetFactory::create(); $scope = []; $context = new GenerationContext(); $resolver = new FixtureWildcardReferenceResolver(new FakeValueResolver()); $resolver->resolve($value, $fixture, $set, $scope, $context); }