@@ -764,20 +764,26 @@ public function testUnionTypeDeserializableWithoutAllowedExtraAttributes()
764
764
['json ' => new JsonEncoder ()]
765
765
);
766
766
767
- $ actual = $ serializer ->deserialize ('{ "v": { "a": 0 }} ' , DummyUnionWithAAndB ::class, 'json ' , [
767
+ $ actual = $ serializer ->deserialize ('{ "v": { "a": 0 }} ' , DummyUnionWithAAndCAndB ::class, 'json ' , [
768
768
AbstractNormalizer::ALLOW_EXTRA_ATTRIBUTES => false ,
769
769
]);
770
770
771
- $ this ->assertEquals (new DummyUnionWithAAndB (new DummyATypeForUnion ()), $ actual );
771
+ $ this ->assertEquals (new DummyUnionWithAAndCAndB (new DummyATypeForUnion ()), $ actual );
772
772
773
- $ actual = $ serializer ->deserialize ('{ "v": { "b": 1 }} ' , DummyUnionWithAAndB ::class, 'json ' , [
773
+ $ actual = $ serializer ->deserialize ('{ "v": { "b": 1 }} ' , DummyUnionWithAAndCAndB ::class, 'json ' , [
774
774
AbstractNormalizer::ALLOW_EXTRA_ATTRIBUTES => false ,
775
775
]);
776
776
777
- $ this ->assertEquals (new DummyUnionWithAAndB (new DummyBTypeForUnion ()), $ actual );
777
+ $ this ->assertEquals (new DummyUnionWithAAndCAndB (new DummyBTypeForUnion ()), $ actual );
778
+
779
+ $ actual = $ serializer ->deserialize ('{ "v": { "c": 3 }} ' , DummyUnionWithAAndCAndB::class, 'json ' , [
780
+ AbstractNormalizer::ALLOW_EXTRA_ATTRIBUTES => false ,
781
+ ]);
782
+
783
+ $ this ->assertEquals (new DummyUnionWithAAndCAndB (new DummyCTypeForUnion (3 )), $ actual );
778
784
779
785
$ this ->expectException (ExtraAttributesException::class);
780
- $ serializer ->deserialize ('{ "v": { "b": 1, "c ": "i am not allowed" }} ' , DummyUnionWithAAndB ::class, 'json ' , [
786
+ $ serializer ->deserialize ('{ "v": { "b": 1, "d ": "i am not allowed" }} ' , DummyUnionWithAAndCAndB ::class, 'json ' , [
781
787
AbstractNormalizer::ALLOW_EXTRA_ATTRIBUTES => false ,
782
788
]);
783
789
}
@@ -1256,13 +1262,23 @@ class DummyBTypeForUnion
1256
1262
public $ b = 1 ;
1257
1263
}
1258
1264
1259
- class DummyUnionWithAAndB
1265
+ class DummyCTypeForUnion
1266
+ {
1267
+ public $ c = 2 ;
1268
+
1269
+ public function __construct ($ c )
1270
+ {
1271
+ $ this ->c = $ c ;
1272
+ }
1273
+ }
1274
+
1275
+ class DummyUnionWithAAndCAndB
1260
1276
{
1261
- /** @var DummyATypeForUnion|DummyBTypeForUnion */
1277
+ /** @var DummyATypeForUnion|DummyCTypeForUnion| DummyBTypeForUnion */
1262
1278
public $ v ;
1263
1279
1264
1280
/**
1265
- * @param DummyATypeForUnion|DummyBTypeForUnion $v
1281
+ * @param DummyATypeForUnion|DummyCTypeForUnion| DummyBTypeForUnion $v
1266
1282
*/
1267
1283
public function __construct ($ v )
1268
1284
{
0 commit comments