Nelmio\Alice\Generator\Hydrator\Property\SymfonyPropertyAccessorHydratorTest::testCatchesAnySymfonyPropertyAccessorToThrowAnHydratorException PHP Метод

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

    public function testCatchesAnySymfonyPropertyAccessorToThrowAnHydratorException()
    {
        try {
            $object = new SimpleObject('dummy', new DummyWithDate());
            $property = new Property('foo', 'bar');
            $accessorProphecy = $this->prophesize(PropertyAccessorInterface::class);
            $accessorProphecy->setValue(Argument::cetera())->willThrow(GenericPropertyAccessException::class);
            /** @var PropertyAccessorInterface $accessor */
            $accessor = $accessorProphecy->reveal();
            $hydrator = new SymfonyPropertyAccessorHydrator($accessor);
            $hydrator->hydrate($object, $property, new GenerationContext());
            $this->fail('Expected exception to be thrown.');
        } catch (HydrationException $exception) {
            $this->assertEquals('Could not hydrate the property "foo" of the object "dummy" (class: Nelmio\\Alice\\Entity\\DummyWithDate).', $exception->getMessage());
            $this->assertEquals(0, $exception->getCode());
            $this->assertNotNull($exception->getPrevious());
        }
    }