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
{
$variableName = $value->getValue();
if (array_key_exists($variableName, $scope)) {
return new ResolvedValueWithFixtureSet($scope[$variableName], $fixtureSet);
}
throw UnresolvableValueExceptionFactory::createForCouldNotFindVariable($value);
}
/** * @expectedException \Nelmio\Alice\Throwable\Exception\Generator\Resolver\UnresolvableValueException * @expectedExceptionMessage Could not find a variable "foo". */ public function testThrowsAnExceptionIfTheVariableCannotBeFoundInTheScope() { $value = new VariableValue('foo'); $set = ResolvedFixtureSetFactory::create(); $resolver = new VariableValueResolver(); $resolver->resolve($value, new FakeFixture(), $set, [], new GenerationContext()); }