@@ -878,21 +878,27 @@ public function testDenormalizeWritableLinks(): void
878
878
'name ' => 'foo ' ,
879
879
'relatedDummy ' => ['foo ' => 'bar ' ],
880
880
'relatedDummies ' => [['bar ' => 'baz ' ]],
881
+ 'relatedDummiesWithUnionTypes ' => [0 => ['bar ' => 'qux ' ], 1. => ['bar ' => 'quux ' ]],
881
882
];
882
883
883
884
$ relatedDummy1 = new RelatedDummy ();
884
885
$ relatedDummy2 = new RelatedDummy ();
886
+ $ relatedDummy3 = new RelatedDummy ();
887
+ $ relatedDummy4 = new RelatedDummy ();
885
888
886
889
$ propertyNameCollectionFactoryProphecy = $ this ->prophesize (PropertyNameCollectionFactoryInterface::class);
887
- $ propertyNameCollectionFactoryProphecy ->create (Dummy::class, [])->willReturn (new PropertyNameCollection (['name ' , 'relatedDummy ' , 'relatedDummies ' ]));
890
+ $ propertyNameCollectionFactoryProphecy ->create (Dummy::class, [])->willReturn (new PropertyNameCollection (['name ' , 'relatedDummy ' , 'relatedDummies ' , ' relatedDummiesWithUnionTypes ' ]));
888
891
889
892
$ relatedDummyType = new Type (Type::BUILTIN_TYPE_OBJECT , false , RelatedDummy::class);
890
893
$ relatedDummiesType = new Type (Type::BUILTIN_TYPE_OBJECT , false , ArrayCollection::class, true , new Type (Type::BUILTIN_TYPE_INT ), $ relatedDummyType );
894
+ $ relatedDummiesWithUnionTypesIntType = new Type (Type::BUILTIN_TYPE_OBJECT , false , ArrayCollection::class, true , new Type (Type::BUILTIN_TYPE_INT ), $ relatedDummyType );
895
+ $ relatedDummiesWithUnionTypesFloatType = new Type (Type::BUILTIN_TYPE_OBJECT , false , ArrayCollection::class, true , new Type (Type::BUILTIN_TYPE_FLOAT ), $ relatedDummyType );
891
896
892
897
$ propertyMetadataFactoryProphecy = $ this ->prophesize (PropertyMetadataFactoryInterface::class);
893
898
$ propertyMetadataFactoryProphecy ->create (Dummy::class, 'name ' , [])->willReturn ((new ApiProperty ())->withBuiltinTypes ([new Type (Type::BUILTIN_TYPE_STRING )])->withDescription ('' )->withReadable (false )->withWritable (true ));
894
899
$ propertyMetadataFactoryProphecy ->create (Dummy::class, 'relatedDummy ' , [])->willReturn ((new ApiProperty ())->withBuiltinTypes ([$ relatedDummyType ])->withReadable (false )->withWritable (true )->withReadableLink (false )->withWritableLink (true ));
895
900
$ propertyMetadataFactoryProphecy ->create (Dummy::class, 'relatedDummies ' , [])->willReturn ((new ApiProperty ())->withBuiltinTypes ([$ relatedDummiesType ])->withReadable (false )->withWritable (true )->withReadableLink (false )->withWritableLink (true ));
901
+ $ propertyMetadataFactoryProphecy ->create (Dummy::class, 'relatedDummiesWithUnionTypes ' , [])->willReturn ((new ApiProperty ())->withBuiltinTypes ([$ relatedDummiesWithUnionTypesIntType , $ relatedDummiesWithUnionTypesFloatType ])->withReadable (false )->withWritable (true )->withReadableLink (false )->withWritableLink (true ));
896
902
897
903
$ iriConverterProphecy = $ this ->prophesize (IriConverterInterface::class);
898
904
@@ -908,6 +914,8 @@ public function testDenormalizeWritableLinks(): void
908
914
$ serializerProphecy ->willImplement (DenormalizerInterface::class);
909
915
$ serializerProphecy ->denormalize (['foo ' => 'bar ' ], RelatedDummy::class, null , Argument::type ('array ' ))->willReturn ($ relatedDummy1 );
910
916
$ serializerProphecy ->denormalize (['bar ' => 'baz ' ], RelatedDummy::class, null , Argument::type ('array ' ))->willReturn ($ relatedDummy2 );
917
+ $ serializerProphecy ->denormalize (['bar ' => 'qux ' ], RelatedDummy::class, null , Argument::type ('array ' ))->willReturn ($ relatedDummy3 );
918
+ $ serializerProphecy ->denormalize (['bar ' => 'quux ' ], RelatedDummy::class, null , Argument::type ('array ' ))->willReturn ($ relatedDummy4 );
911
919
912
920
$ normalizer = $ this ->getMockForAbstractClass (AbstractItemNormalizer::class, [
913
921
$ propertyNameCollectionFactoryProphecy ->reveal (),
@@ -930,6 +938,7 @@ public function testDenormalizeWritableLinks(): void
930
938
$ propertyAccessorProphecy ->setValue ($ actual , 'name ' , 'foo ' )->shouldHaveBeenCalled ();
931
939
$ propertyAccessorProphecy ->setValue ($ actual , 'relatedDummy ' , $ relatedDummy1 )->shouldHaveBeenCalled ();
932
940
$ propertyAccessorProphecy ->setValue ($ actual , 'relatedDummies ' , [$ relatedDummy2 ])->shouldHaveBeenCalled ();
941
+ $ propertyAccessorProphecy ->setValue ($ actual , 'relatedDummiesWithUnionTypes ' , [0 => $ relatedDummy3 , 1. => $ relatedDummy4 ])->shouldHaveBeenCalled ();
933
942
}
934
943
935
944
public function testBadRelationType (): void
@@ -1220,6 +1229,11 @@ public function testDenormalizeBadKeyType(): void
1220
1229
'bar ' => 'baz ' ,
1221
1230
],
1222
1231
],
1232
+ 'relatedDummiesWithUnionTypes ' => [
1233
+ 'a ' => [
1234
+ 'bar ' => 'baz ' ,
1235
+ ],
1236
+ ],
1223
1237
];
1224
1238
1225
1239
$ propertyNameCollectionFactoryProphecy = $ this ->prophesize (PropertyNameCollectionFactoryInterface::class);
0 commit comments