@@ -155,6 +155,61 @@ public function testSerializeUnknownExceptionJsonWithoutDebugUsingErrorRenderer(
155155 $ this ->assertEquals ('{"code":500,"message":"Internal Server Error"} ' , $ client ->getResponse ()->getContent ());
156156 }
157157
158+ /**
159+ * @dataProvider serializeExceptionCodeMappedToResponseStatusCodeJsonProvider
160+ */
161+ public function testSerializeExceptionCodeMappedToResponseStatusCodeJsonUsingErrorRenderer (string $ testCase , array $ expectedJson )
162+ {
163+ if (!class_exists (SerializerErrorRenderer::class)) {
164+ $ this ->markTestSkipped ();
165+ }
166+
167+ $ this ->iniSet ('error_log ' , file_exists ('/dev/null ' ) ? '/dev/null ' : 'nul ' );
168+
169+ $ client = $ this ->createClient (array ('test_case ' => $ testCase , 'debug ' => false ));
170+ $ client ->request ('GET ' , '/serializer-error/invalid-argument-exception.json ' );
171+
172+ $ this ->assertEquals (json_encode ($ expectedJson ), $ client ->getResponse ()->getContent ());
173+ }
174+
175+ public function serializeExceptionCodeMappedToResponseStatusCodeJsonProvider (): array
176+ {
177+ return [
178+ [
179+ 'FlattenExceptionHandlerLegacyFormat ' ,
180+ [
181+ 'code ' => 400 ,
182+ 'message ' => 'Invalid argument given. ' ,
183+ ],
184+ ],
185+ [
186+ 'FlattenExceptionHandlerRfc7807Format ' ,
187+ [
188+ 'type ' => 'https://tools.ietf.org/html/rfc2616#section-10 ' ,
189+ 'title ' => 'An error occurred ' ,
190+ 'status ' => 400 ,
191+ 'detail ' => 'Invalid argument given. ' ,
192+ ],
193+ ],
194+ [
195+ 'FlattenExceptionNormalizerLegacyFormat ' ,
196+ [
197+ 'code ' => 400 ,
198+ 'message ' => 'Invalid argument given. ' ,
199+ ],
200+ ],
201+ [
202+ 'FlattenExceptionNormalizerRfc7807Format ' ,
203+ [
204+ 'type ' => 'https://tools.ietf.org/html/rfc2616#section-10 ' ,
205+ 'title ' => 'An error occurred ' ,
206+ 'status ' => 400 ,
207+ 'detail ' => 'Invalid argument given. ' ,
208+ ],
209+ ],
210+ ];
211+ }
212+
158213 /**
159214 * @group legacy
160215 *
0 commit comments