Skip to content

Commit 4cf4792

Browse files
committed
test: legacy type
1 parent 0cc42d1 commit 4cf4792

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/Serializer/Tests/AbstractItemNormalizerTest.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,10 +1084,18 @@ public function testDenormalizeRelationNotFoundReturnsNull(): void
10841084
$propertyNameCollectionFactoryProphecy = $this->prophesize(PropertyNameCollectionFactoryInterface::class);
10851085
$propertyNameCollectionFactoryProphecy->create(Dummy::class, Argument::type('array'))->willReturn(new PropertyNameCollection(['relatedDummy']));
10861086

1087-
$relatedDummyType = new Type(Type::BUILTIN_TYPE_OBJECT, false, RelatedDummy::class);
1087+
// BC layer for api-platform/metadata < 4.1
1088+
if (!method_exists(PropertyInfoExtractor::class, 'getType')) {
1089+
$relatedDummyType = new LegacyType(LegacyType::BUILTIN_TYPE_OBJECT, false, RelatedDummy::class);
10881090

1089-
$propertyMetadataFactoryProphecy = $this->prophesize(PropertyMetadataFactoryInterface::class);
1090-
$propertyMetadataFactoryProphecy->create(Dummy::class, 'relatedDummy', Argument::type('array'))->willReturn((new ApiProperty())->withBuiltinTypes([$relatedDummyType])->withReadable(false)->withWritable(true)->withReadableLink(false)->withWritableLink(false));
1091+
$propertyMetadataFactoryProphecy = $this->prophesize(PropertyMetadataFactoryInterface::class);
1092+
$propertyMetadataFactoryProphecy->create(Dummy::class, 'relatedDummy', Argument::type('array'))->willReturn((new ApiProperty())->withBuiltinTypes([$relatedDummyType])->withReadable(false)->withWritable(true)->withReadableLink(false)->withWritableLink(false));
1093+
} else {
1094+
$relatedDummyType = Type::object(RelatedDummy::class);
1095+
1096+
$propertyMetadataFactoryProphecy = $this->prophesize(PropertyMetadataFactoryInterface::class);
1097+
$propertyMetadataFactoryProphecy->create(Dummy::class, 'relatedDummy', Argument::type('array'))->willReturn((new ApiProperty())->withNativeType($relatedDummyType)->withReadable(false)->withWritable(true)->withReadableLink(false)->withWritableLink(false));
1098+
}
10911099

10921100
$iriConverterProphecy = $this->prophesize(IriConverterInterface::class);
10931101
$iriConverterProphecy->getResourceFromIri('/dummies/not_found', Argument::type('array'))->willThrow(new ItemNotFoundException());

0 commit comments

Comments
 (0)