Nelmio\Alice\Generator\Resolver\Value\Chainable\FixturePropertyReferenceResolverTest::testReturnsSetWithResolvedValue PHP Method

testReturnsSetWithResolvedValue() public method

    public function testReturnsSetWithResolvedValue()
    {
        $value = new FixturePropertyValue($reference = new FakeValue(), $property = 'prop');
        $fixture = new FakeFixture();
        $set = ResolvedFixtureSetFactory::create(new ParameterBag(['foo' => 'bar']));
        $scope = ['val' => 'scopie'];
        $context = new GenerationContext();
        $context->markIsResolvingFixture('foo');
        $valueResolverContext = new GenerationContext();
        $valueResolverContext->markIsResolvingFixture('foo');
        $valueResolverContext->markAsNeedsCompleteGeneration();
        $valueResolverProphecy = $this->prophesize(ValueResolverInterface::class);
        $valueResolverProphecy->resolve($reference, $fixture, $set, $scope, $valueResolverContext)->willReturn(new ResolvedValueWithFixtureSet($instance = new \stdClass(), $newSet = ResolvedFixtureSetFactory::create(new ParameterBag(['ping' => 'pong']))));
        /** @var ValueResolverInterface $valueResolver */
        $valueResolver = $valueResolverProphecy->reveal();
        $propertyAccessorProphecy = $this->prophesize(PropertyAccessorInterface::class);
        $propertyAccessorProphecy->getValue($instance, $property)->willReturn('yo');
        /** @var PropertyAccessorInterface $propertyAccessor */
        $propertyAccessor = $propertyAccessorProphecy->reveal();
        $expected = new ResolvedValueWithFixtureSet('yo', $newSet);
        $resolver = new FixturePropertyReferenceResolver($propertyAccessor, $valueResolver);
        $actual = $resolver->resolve($value, $fixture, $set, $scope, $context);
        $this->assertEquals($expected, $actual);
        $valueResolverProphecy->resolve(Argument::cetera())->shouldHaveBeenCalledTimes(1);
        $propertyAccessorProphecy->getValue(Argument::cetera())->shouldHaveBeenCalledTimes(1);
    }