@@ -1189,7 +1189,7 @@ public function testCollectDenormalizationErrorsWithEnumConstructor()
1189
1189
);
1190
1190
1191
1191
try {
1192
- $ serializer ->deserialize ('{"invalid": "get "} ' , DummyObjectWithEnumConstructor::class, 'json ' , [
1192
+ $ serializer ->deserialize ('{"invalid": "GET "} ' , DummyObjectWithEnumConstructor::class, 'json ' , [
1193
1193
DenormalizerInterface::COLLECT_DENORMALIZATION_ERRORS => true ,
1194
1194
]);
1195
1195
} catch (\Throwable $ th ) {
@@ -1215,6 +1215,29 @@ public function testCollectDenormalizationErrorsWithEnumConstructor()
1215
1215
$ this ->assertSame ($ expected , $ exceptionsAsArray );
1216
1216
}
1217
1217
1218
+ /**
1219
+ * @requires PHP 8.1
1220
+ */
1221
+ public function testNoCollectDenormalizationErrorsWithWrongEnum ()
1222
+ {
1223
+ $ serializer = new Serializer (
1224
+ [
1225
+ new BackedEnumNormalizer (),
1226
+ new ObjectNormalizer (),
1227
+ ],
1228
+ ['json ' => new JsonEncoder ()]
1229
+ );
1230
+
1231
+ try {
1232
+ $ serializer ->deserialize ('{"get": "invalid"} ' , DummyObjectWithEnumConstructor::class, 'json ' , [
1233
+ DenormalizerInterface::COLLECT_DENORMALIZATION_ERRORS => true ,
1234
+ ]);
1235
+ } catch (\Throwable $ th ) {
1236
+ $ this ->assertNotInstanceOf (PartialDenormalizationException::class, $ th );
1237
+ $ this ->assertInstanceOf (InvalidArgumentException::class, $ th );
1238
+ }
1239
+ }
1240
+
1218
1241
public function provideCollectDenormalizationErrors ()
1219
1242
{
1220
1243
return [
0 commit comments