@@ -60,7 +60,7 @@ public function serializeExceptionJsonProvider()
6060 /**
6161 * @dataProvider serializeExceptionJsonUsingErrorRendererProvider
6262 */
63- public function testSerializeExceptionJsonUsingErrorRenderer (string $ testCase , array $ expectedJson )
63+ public function testSerializeExceptionJsonUsingErrorRenderer (string $ testCase , array $ expectedJson, string $ expectedContentType )
6464 {
6565 if (!class_exists (SerializerErrorRenderer::class)) {
6666 $ this ->markTestSkipped ();
@@ -71,6 +71,7 @@ public function testSerializeExceptionJsonUsingErrorRenderer(string $testCase, a
7171 $ client = $ this ->createClient (['test_case ' => $ testCase , 'debug ' => false ]);
7272 $ client ->request ('GET ' , '/serializer-error/exception.json ' );
7373
74+ $ this ->assertStringStartsWith ($ expectedContentType , $ client ->getResponse ()->headers ->get ('Content-Type ' ));
7475 $ this ->assertEquals (json_encode ($ expectedJson ), $ client ->getResponse ()->getContent ());
7576 }
7677
@@ -80,23 +81,23 @@ public function serializeExceptionJsonUsingErrorRendererProvider(): array
8081 ['FlattenExceptionNormalizerLegacyFormat ' , [
8182 'code ' => 500 ,
8283 'message ' => 'Something bad happened. ' ,
83- ]],
84+ ], ' application/json ' ],
8485 ['FlattenExceptionNormalizerRfc7807Format ' , [
8586 'type ' => 'https://tools.ietf.org/html/rfc2616#section-10 ' ,
8687 'title ' => 'An error occurred ' ,
8788 'status ' => 500 ,
8889 'detail ' => 'Something bad happened. ' ,
89- ]],
90+ ], ' application/problem+json ' ],
9091 ['FlattenExceptionHandlerLegacyFormat ' , [
9192 'code ' => 500 ,
9293 'message ' => 'Something bad happened. ' ,
93- ]],
94+ ], ' application/json ' ],
9495 ['FlattenExceptionHandlerRfc7807Format ' , [
9596 'type ' => 'https://tools.ietf.org/html/rfc2616#section-10 ' ,
9697 'title ' => 'An error occurred ' ,
9798 'status ' => 500 ,
9899 'detail ' => 'Something bad happened. ' ,
99- ]],
100+ ], ' application/problem+json ' ],
100101 ];
101102 }
102103
@@ -195,7 +196,7 @@ public function serializeExceptionXmlProvider()
195196 /**
196197 * @dataProvider serializeExceptionXmlUsingErrorRendererProvider
197198 */
198- public function testSerializeExceptionXmlUsingErrorRenderer (string $ testCase , string $ expectedContent )
199+ public function testSerializeExceptionXmlUsingErrorRenderer (string $ testCase , string $ expectedContent, string $ expectedContentType )
199200 {
200201 if (!class_exists (SerializerErrorRenderer::class)) {
201202 $ this ->markTestSkipped ();
@@ -206,6 +207,7 @@ public function testSerializeExceptionXmlUsingErrorRenderer(string $testCase, st
206207 $ client = $ this ->createClient (['test_case ' => $ testCase , 'debug ' => false ]);
207208 $ client ->request ('GET ' , '/serializer-error/exception.xml ' );
208209
210+ $ this ->assertStringStartsWith ($ expectedContentType , $ client ->getResponse ()->headers ->get ('Content-Type ' ));
209211 $ this ->assertXmlStringEqualsXmlString ($ expectedContent , $ client ->getResponse ()->getContent ());
210212 }
211213
@@ -236,10 +238,10 @@ public function serializeExceptionXmlUsingErrorRendererProvider(): array
236238XML;
237239
238240 return [
239- ['FlattenExceptionNormalizerLegacyFormat ' , $ expectedLegacyContent ],
240- ['FlattenExceptionNormalizerRfc7807Format ' , $ expectedRfc7807Content ],
241- ['FlattenExceptionHandlerLegacyFormat ' , $ expectedLegacyJmsContent ],
242- ['FlattenExceptionHandlerRfc7807Format ' , $ expectedRfc7807Content ],
241+ ['FlattenExceptionNormalizerLegacyFormat ' , $ expectedLegacyContent, ' text/xml ' ],
242+ ['FlattenExceptionNormalizerRfc7807Format ' , $ expectedRfc7807Content, ' application/problem+xml ' ],
243+ ['FlattenExceptionHandlerLegacyFormat ' , $ expectedLegacyJmsContent, ' text/xml ' ],
244+ ['FlattenExceptionHandlerRfc7807Format ' , $ expectedRfc7807Content, ' application/problem+xml ' ],
243245 ];
244246 }
245247
0 commit comments