@@ -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