@@ -35,7 +35,7 @@ public static function tearDownAfterClass()
3535 /**
3636 * @dataProvider serializeExceptionJsonUsingErrorRendererProvider
3737 */
38- public function testSerializeExceptionJsonUsingErrorRenderer (string $ testCase , array $ expectedJson )
38+ public function testSerializeExceptionJsonUsingErrorRenderer (string $ testCase , array $ expectedJson, string $ expectedContentType )
3939 {
4040 if (!class_exists (SerializerErrorRenderer::class)) {
4141 $ this ->markTestSkipped ();
@@ -46,6 +46,7 @@ public function testSerializeExceptionJsonUsingErrorRenderer(string $testCase, a
4646 $ client = $ this ->createClient (['test_case ' => $ testCase , 'debug ' => false ]);
4747 $ client ->request ('GET ' , '/serializer-error/exception.json ' );
4848
49+ $ this ->assertStringStartsWith ($ expectedContentType , $ client ->getResponse ()->headers ->get ('Content-Type ' ));
4950 $ this ->assertEquals (json_encode ($ expectedJson ), $ client ->getResponse ()->getContent ());
5051 }
5152
@@ -55,23 +56,23 @@ public function serializeExceptionJsonUsingErrorRendererProvider(): array
5556 ['FlattenExceptionNormalizerLegacyFormat ' , [
5657 'code ' => 500 ,
5758 'message ' => 'Something bad happened. ' ,
58- ]],
59+ ], ' application/json ' ],
5960 ['FlattenExceptionNormalizerRfc7807Format ' , [
6061 'type ' => 'https://tools.ietf.org/html/rfc2616#section-10 ' ,
6162 'title ' => 'An error occurred ' ,
6263 'status ' => 500 ,
6364 'detail ' => 'Something bad happened. ' ,
64- ]],
65+ ], ' application/problem+json ' ],
6566 ['FlattenExceptionHandlerLegacyFormat ' , [
6667 'code ' => 500 ,
6768 'message ' => 'Something bad happened. ' ,
68- ]],
69+ ], ' application/json ' ],
6970 ['FlattenExceptionHandlerRfc7807Format ' , [
7071 'type ' => 'https://tools.ietf.org/html/rfc2616#section-10 ' ,
7172 'title ' => 'An error occurred ' ,
7273 'status ' => 500 ,
7374 'detail ' => 'Something bad happened. ' ,
74- ]],
75+ ], ' application/problem+json ' ],
7576 ];
7677 }
7778
@@ -106,7 +107,7 @@ public function testSerializeUnknownExceptionJsonWithoutDebugUsingErrorRenderer(
106107 /**
107108 * @dataProvider serializeExceptionXmlUsingErrorRendererProvider
108109 */
109- public function testSerializeExceptionXmlUsingErrorRenderer (string $ testCase , string $ expectedContent )
110+ public function testSerializeExceptionXmlUsingErrorRenderer (string $ testCase , string $ expectedContent, string $ expectedContentType )
110111 {
111112 if (!class_exists (SerializerErrorRenderer::class)) {
112113 $ this ->markTestSkipped ();
@@ -117,6 +118,7 @@ public function testSerializeExceptionXmlUsingErrorRenderer(string $testCase, st
117118 $ client = $ this ->createClient (['test_case ' => $ testCase , 'debug ' => false ]);
118119 $ client ->request ('GET ' , '/serializer-error/exception.xml ' );
119120
121+ $ this ->assertStringStartsWith ($ expectedContentType , $ client ->getResponse ()->headers ->get ('Content-Type ' ));
120122 $ this ->assertXmlStringEqualsXmlString ($ expectedContent , $ client ->getResponse ()->getContent ());
121123 }
122124
@@ -147,10 +149,10 @@ public function serializeExceptionXmlUsingErrorRendererProvider(): array
147149XML;
148150
149151 return [
150- ['FlattenExceptionNormalizerLegacyFormat ' , $ expectedLegacyContent ],
151- ['FlattenExceptionNormalizerRfc7807Format ' , $ expectedRfc7807Content ],
152- ['FlattenExceptionHandlerLegacyFormat ' , $ expectedLegacyJmsContent ],
153- ['FlattenExceptionHandlerRfc7807Format ' , $ expectedRfc7807Content ],
152+ ['FlattenExceptionNormalizerLegacyFormat ' , $ expectedLegacyContent, ' text/xml ' ],
153+ ['FlattenExceptionNormalizerRfc7807Format ' , $ expectedRfc7807Content, ' application/problem+xml ' ],
154+ ['FlattenExceptionHandlerLegacyFormat ' , $ expectedLegacyJmsContent, ' text/xml ' ],
155+ ['FlattenExceptionHandlerRfc7807Format ' , $ expectedRfc7807Content, ' application/problem+xml ' ],
154156 ];
155157 }
156158
0 commit comments