@@ -22,15 +22,24 @@ class HttpExceptionTraitTest extends TestCase
22
22
{
23
23
public function provideParseError (): iterable
24
24
{
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 ];
28
37
}
29
38
30
39
/**
31
40
* @dataProvider provideParseError
32
41
*/
33
- public function testParseError (string $ mimeType , string $ json ): void
42
+ public function testParseError (string $ mimeType , string $ json, string $ expectedMessage ): void
34
43
{
35
44
$ response = $ this ->createMock (ResponseInterface::class);
36
45
$ response
@@ -47,12 +56,7 @@ public function testParseError(string $mimeType, string $json): void
47
56
48
57
$ e = new TestException ($ response );
49
58
$ 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 ());
56
60
}
57
61
}
58
62
0 commit comments