public function testResolvesReferenceBeforeHandingOverTheResolutionToTheDecoratedResolver()
{
$idValue = new FakeValue();
$value = new FixtureReferenceValue($idValue);
$expectedObject = new \stdClass();
$expectedObject->foo = 'bar';
$set = ResolvedFixtureSetFactory::create(null, $fixtureBag = (new FixtureBag())->with($dummyFixture = new SimpleFixture('dummy', 'Dummy', SpecificationBagFactory::create()))->with($anotherDummyFixture = new SimpleFixture('another_dummy', 'Dummy', SpecificationBagFactory::create())), $objectBag = new ObjectBag(['dummy' => $expectedObject]));
$scope = ['injected' => true];
$context = new GenerationContext();
$context->markIsResolvingFixture('bar');
$valueResolverProphecy = $this->prophesize(ValueResolverInterface::class);
$valueResolverProphecy->resolve($idValue, $dummyFixture, $set, $scope, $context)->willReturn(new ResolvedValueWithFixtureSet('alice', $newSet = ResolvedFixtureSetFactory::create(null, $fixtureBag->with(new SimpleFixture('value_resolver_fixture', 'Dummy', SpecificationBagFactory::create())), $newObjectBag = $objectBag->with(new SimpleObject('value_resolver_fixture', new \stdClass())))));
/** @var ValueResolverInterface $valueResolver */
$valueResolver = $valueResolverProphecy->reveal();
$decoratedResolverProphecy = $this->prophesize(ChainableValueResolverInterface::class);
$decoratedResolverProphecy->resolve(new FixtureReferenceValue('alice'), $dummyFixture, $newSet, $scope, $context)->willReturn($expected = new ResolvedValueWithFixtureSet($expectedObject, ResolvedFixtureSetFactory::create(null, $fixtureBag, $newObjectBag->with(new SimpleObject('alice', $expectedObject)))));
/** @var ChainableValueResolverInterface $decoratedResolver */
$decoratedResolver = $decoratedResolverProphecy->reveal();
$resolver = new UnresolvedFixtureReferenceIdResolver($decoratedResolver, $valueResolver);
$actual = $resolver->resolve($value, $dummyFixture, $set, $scope, $context);
$this->assertEquals($expected, $actual);
$valueResolverProphecy->resolve(Argument::cetera())->shouldHaveBeenCalledTimes(1);
$decoratedResolverProphecy->resolve(Argument::cetera())->shouldHaveBeenCalledTimes(1);
}