|
16 | 16 | use ApiPlatform\Metadata\ApiProperty;
|
17 | 17 | use ApiPlatform\Metadata\ApiResource;
|
18 | 18 | use ApiPlatform\Metadata\Exception\InvalidArgumentException;
|
| 19 | +use ApiPlatform\Metadata\Exception\ItemNotFoundException; |
19 | 20 | use ApiPlatform\Metadata\Get;
|
20 | 21 | use ApiPlatform\Metadata\GetCollection;
|
21 | 22 | use ApiPlatform\Metadata\IriConverterInterface;
|
@@ -910,11 +911,13 @@ public function testDeserializationPathForNotDenormalizableRelations(): void
|
910 | 911 | $this->assertCount(1, $errors); // @phpstan-ignore-line method.impossibleType (false positive)
|
911 | 912 | $this->assertInstanceOf(NotNormalizableValueException::class, $errors[0]);
|
912 | 913 | $this->assertSame('relatedDummies[0]', $errors[0]->getPath());
|
| 914 | + $this->assertSame('Invalid IRI "wrong".', $errors[0]->getMessage()); |
913 | 915 | }
|
914 | 916 |
|
915 | 917 | public function testDeserializationPathForNotDenormalizableResource(): void
|
916 | 918 | {
|
917 | 919 | $this->expectException(NotNormalizableValueException::class);
|
| 920 | + $this->expectExceptionMessage('Invalid IRI "wrong IRI".'); |
918 | 921 |
|
919 | 922 | $propertyNameCollectionFactoryProphecy = $this->prophesize(PropertyNameCollectionFactoryInterface::class);
|
920 | 923 |
|
@@ -949,6 +952,44 @@ public function testDeserializationPathForNotDenormalizableResource(): void
|
949 | 952 | $normalizer->denormalize('wrong IRI', Dummy::class, null, ['not_normalizable_value_exceptions' => []]);
|
950 | 953 | }
|
951 | 954 |
|
| 955 | + public function testDeserializationPathForNotFoundResource(): void |
| 956 | + { |
| 957 | + $this->expectException(NotNormalizableValueException::class); |
| 958 | + $this->expectExceptionMessage('Some item not found exception.'); |
| 959 | + |
| 960 | + $propertyNameCollectionFactoryProphecy = $this->prophesize(PropertyNameCollectionFactoryInterface::class); |
| 961 | + |
| 962 | + $propertyMetadataFactoryProphecy = $this->prophesize(PropertyMetadataFactoryInterface::class); |
| 963 | + |
| 964 | + $iriConverterProphecy = $this->prophesize(IriConverterInterface::class); |
| 965 | + $iriConverterProphecy->getResourceFromIri(Argument::cetera())->willThrow(new ItemNotFoundException('Some item not found exception.')); |
| 966 | + |
| 967 | + $resourceClassResolverProphecy = $this->prophesize(ResourceClassResolverInterface::class); |
| 968 | + $resourceClassResolverProphecy->getResourceClass(null, Dummy::class)->willReturn(Dummy::class); |
| 969 | + $resourceClassResolverProphecy->isResourceClass(Dummy::class)->willReturn(true); |
| 970 | + |
| 971 | + $propertyAccessorProphecy = $this->prophesize(PropertyAccessorInterface::class); |
| 972 | + |
| 973 | + $serializerProphecy = $this->prophesize(SerializerInterface::class); |
| 974 | + $serializerProphecy->willImplement(DenormalizerInterface::class); |
| 975 | + |
| 976 | + $normalizer = $this->getMockForAbstractClass(AbstractItemNormalizer::class, [ |
| 977 | + $propertyNameCollectionFactoryProphecy->reveal(), |
| 978 | + $propertyMetadataFactoryProphecy->reveal(), |
| 979 | + $iriConverterProphecy->reveal(), |
| 980 | + $resourceClassResolverProphecy->reveal(), |
| 981 | + $propertyAccessorProphecy->reveal(), |
| 982 | + null, |
| 983 | + null, |
| 984 | + [], |
| 985 | + null, |
| 986 | + null, |
| 987 | + ]); |
| 988 | + $normalizer->setSerializer($serializerProphecy->reveal()); |
| 989 | + |
| 990 | + $normalizer->denormalize('/some-iri', Dummy::class, null, ['not_normalizable_value_exceptions' => []]); |
| 991 | + } |
| 992 | + |
952 | 993 | public function testInnerDocumentNotAllowed(): void
|
953 | 994 | {
|
954 | 995 | $this->expectException(UnexpectedValueException::class);
|
|
0 commit comments