Inheritance: implements Nelmio\Alice\Generator\Resolver\Value\ChainableValueResolverInterface, implements Nelmio\Alice\Generator\ValueResolverAwareInterface, use trait Nelmio\Alice\IsAServiceTrait
Example #1
0
 public function testThrowsIfLimitForGenerationOfUniqueValuesIsReached()
 {
     $uniqueId = 'uniqid';
     $realValue = new FakeValue();
     $value = new UniqueValue($uniqueId, $realValue);
     $fixture = new FakeFixture();
     $set = ResolvedFixtureSetFactory::create();
     $scope = ['scope' => 'epocs'];
     $context = new GenerationContext();
     $context->markIsResolvingFixture('foo');
     $pool = new UniqueValuesPool();
     $pool->add(new UniqueValue($uniqueId, 10));
     $pool->add(new UniqueValue($uniqueId, 11));
     $decoratedResolverProphecy = $this->prophesize(ValueResolverInterface::class);
     $decoratedResolverProphecy->resolve($realValue, $fixture, $set, $scope, $context)->willReturn(new ResolvedValueWithFixtureSet(10, $set));
     /** @var ValueResolverInterface $decoratedResolver */
     $decoratedResolver = $decoratedResolverProphecy->reveal();
     $resolver = new UniqueValueResolver($pool, $decoratedResolver);
     try {
         $resolver->resolve($value, $fixture, $set, $scope, $context);
         $this->fail('Expected exception to be thrown.');
     } catch (UniqueValueGenerationLimitReachedException $exception) {
         $decoratedResolverProphecy->resolve(Argument::cetera())->shouldHaveBeenCalledTimes(150);
     }
 }