@@ -586,20 +586,26 @@ public function testUnionTypeDeserializableWithoutAllowedExtraAttributes()
586
586
['json ' => new JsonEncoder ()]
587
587
);
588
588
589
- $ actual = $ serializer ->deserialize ('{ "v": { "a": 0 }} ' , DummyUnionWithAAndB ::class, 'json ' , [
589
+ $ actual = $ serializer ->deserialize ('{ "v": { "a": 0 }} ' , DummyUnionWithAAndCAndB ::class, 'json ' , [
590
590
AbstractNormalizer::ALLOW_EXTRA_ATTRIBUTES => false ,
591
591
]);
592
592
593
- $ this ->assertEquals (new DummyUnionWithAAndB (new DummyATypeForUnion ()), $ actual );
593
+ $ this ->assertEquals (new DummyUnionWithAAndCAndB (new DummyATypeForUnion ()), $ actual );
594
594
595
- $ actual = $ serializer ->deserialize ('{ "v": { "b": 1 }} ' , DummyUnionWithAAndB ::class, 'json ' , [
595
+ $ actual = $ serializer ->deserialize ('{ "v": { "b": 1 }} ' , DummyUnionWithAAndCAndB ::class, 'json ' , [
596
596
AbstractNormalizer::ALLOW_EXTRA_ATTRIBUTES => false ,
597
597
]);
598
598
599
- $ this ->assertEquals (new DummyUnionWithAAndB (new DummyBTypeForUnion ()), $ actual );
599
+ $ this ->assertEquals (new DummyUnionWithAAndCAndB (new DummyBTypeForUnion ()), $ actual );
600
+
601
+ $ actual = $ serializer ->deserialize ('{ "v": { "c": 3 }} ' , DummyUnionWithAAndCAndB::class, 'json ' , [
602
+ AbstractNormalizer::ALLOW_EXTRA_ATTRIBUTES => false ,
603
+ ]);
604
+
605
+ $ this ->assertEquals (new DummyUnionWithAAndCAndB (new DummyCTypeForUnion (3 )), $ actual );
600
606
601
607
$ this ->expectException (ExtraAttributesException::class);
602
- $ serializer ->deserialize ('{ "v": { "b": 1, "c ": "i am not allowed" }} ' , DummyUnionWithAAndB ::class, 'json ' , [
608
+ $ serializer ->deserialize ('{ "v": { "b": 1, "d ": "i am not allowed" }} ' , DummyUnionWithAAndCAndB ::class, 'json ' , [
603
609
AbstractNormalizer::ALLOW_EXTRA_ATTRIBUTES => false ,
604
610
]);
605
611
}
@@ -719,13 +725,23 @@ class DummyBTypeForUnion
719
725
public $ b = 1 ;
720
726
}
721
727
722
- class DummyUnionWithAAndB
728
+ class DummyCTypeForUnion
729
+ {
730
+ public $ c = 2 ;
731
+
732
+ public function __construct ($ c )
733
+ {
734
+ $ this ->c = $ c ;
735
+ }
736
+ }
737
+
738
+ class DummyUnionWithAAndCAndB
723
739
{
724
- /** @var DummyATypeForUnion|DummyBTypeForUnion */
740
+ /** @var DummyATypeForUnion|DummyCTypeForUnion| DummyBTypeForUnion */
725
741
public $ v ;
726
742
727
743
/**
728
- * @param DummyATypeForUnion|DummyBTypeForUnion $v
744
+ * @param DummyATypeForUnion|DummyCTypeForUnion| DummyBTypeForUnion $v
729
745
*/
730
746
public function __construct ($ v )
731
747
{
0 commit comments