Nelmio\Alice\Generator\Resolver\Value\Chainable\FixturePropertyReferenceResolverTest::testCatchesAccessorExceptionsToThrowResolverException PHP Метод

testCatchesAccessorExceptionsToThrowResolverException() публичный Метод

    public function testCatchesAccessorExceptionsToThrowResolverException()
    {
        try {
            $value = new FixturePropertyValue($reference = new DummyValue('dummy'), $property = 'prop');
            $set = ResolvedFixtureSetFactory::create(new ParameterBag(['foo' => 'bar']));
            $valueResolverProphecy = $this->prophesize(ValueResolverInterface::class);
            $valueResolverProphecy->resolve(Argument::cetera())->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(Argument::cetera())->willThrow(\Exception::class);
            /** @var PropertyAccessorInterface $propertyAccessor */
            $propertyAccessor = $propertyAccessorProphecy->reveal();
            $resolver = new FixturePropertyReferenceResolver($propertyAccessor, $valueResolver);
            $resolver->resolve($value, new FakeFixture(), $set, [], new GenerationContext());
            $this->fail('Expected exception to be thrown.');
        } catch (UnresolvableValueException $exception) {
            $this->assertEquals('Could not resolve value "dummy->prop".', $exception->getMessage());
            $this->assertEquals(0, $exception->getCode());
            $this->assertNotNull($exception->getPrevious());
        }
    }