@@ -22,15 +22,24 @@ class HttpExceptionTraitTest extends TestCase
2222{
2323 public function provideParseError (): iterable
2424 {
25- yield ['application/ld+json ' , '{"hydra:title": "An error occurred", "hydra:description": "Some details"} ' ];
26- yield ['application/problem+json ' , '{"title": "An error occurred", "detail": "Some details"} ' ];
27- yield ['application/vnd.api+json ' , '{"title": "An error occurred", "detail": "Some details"} ' ];
25+ $ errorWithoutMessage = 'HTTP/1.1 400 Bad Request returned for "http://example.com". ' ;
26+
27+ $ errorWithMessage = <<<ERROR
28+ An error occurred
29+
30+ Some details
31+ ERROR ;
32+
33+ yield ['application/ld+json ' , '{"hydra:title": "An error occurred", "hydra:description": "Some details"} ' , $ errorWithMessage ];
34+ yield ['application/problem+json ' , '{"title": "An error occurred", "detail": "Some details"} ' , $ errorWithMessage ];
35+ yield ['application/vnd.api+json ' , '{"title": "An error occurred", "detail": "Some details"} ' , $ errorWithMessage ];
36+ yield ['application/json ' , '{"title": "An error occurred", "detail": {"field_name": ["Some details"]}} ' , $ errorWithoutMessage ];
2837 }
2938
3039 /**
3140 * @dataProvider provideParseError
3241 */
33- public function testParseError (string $ mimeType , string $ json ): void
42+ public function testParseError (string $ mimeType , string $ json, string $ expectedMessage ): void
3443 {
3544 $ response = $ this ->createMock (ResponseInterface::class);
3645 $ response
@@ -47,12 +56,7 @@ public function testParseError(string $mimeType, string $json): void
4756
4857 $ e = new TestException ($ response );
4958 $ this ->assertSame (400 , $ e ->getCode ());
50- $ this ->assertSame (<<<ERROR
51- An error occurred
52-
53- Some details
54- ERROR
55- , $ e ->getMessage ());
59+ $ this ->assertSame ($ expectedMessage , $ e ->getMessage ());
5660 }
5761}
5862
0 commit comments