@@ -15,7 +15,7 @@ public function testBuildMalformedResponse()
15
15
->willReturn ('malformed response ' );
16
16
17
17
$ this ->expectException (\UnexpectedValueException::class);
18
- $ this ->expectExceptionMessage ('Invalid JSON response. ' );
18
+ $ this ->expectExceptionMessage ('Invalid JSON response. Response body: ' );
19
19
20
20
$ builder = new ResponseBuilder ();
21
21
$ builder ->build ($ mockHttpResponse );
@@ -45,7 +45,7 @@ public function testBuildInvalidGraphqlJsonResponse(string $body)
45
45
->willReturn ($ body );
46
46
47
47
$ this ->expectException (\UnexpectedValueException::class);
48
- $ this ->expectExceptionMessage ('Invalid GraphQL JSON response. ' );
48
+ $ this ->expectExceptionMessage ('Invalid GraphQL JSON response. Response body: ' );
49
49
50
50
$ builder = new ResponseBuilder ();
51
51
$ builder ->build ($ mockHttpResponse );
@@ -68,13 +68,28 @@ public function testBuildValidGraphqlJsonWithoutErrors()
68
68
);
69
69
}
70
70
71
- public function testBuildValidGraphqlJsonWithErrors ()
71
+ public function buildValidGraphqlJsonWithErrorsProvider ()
72
+ {
73
+ return [
74
+ 'Response with null data ' => [
75
+ 'body ' => '{"data": null, "errors": [{"foo": "bar"}]} ' ,
76
+ ],
77
+ 'Response without data ' => [
78
+ 'body ' => '{"errors": [{"foo": "bar"}]} ' ,
79
+ ],
80
+ ];
81
+ }
82
+
83
+ /**
84
+ * @dataProvider buildValidGraphqlJsonWithErrorsProvider
85
+ */
86
+ public function testBuildValidGraphqlJsonWithErrors (string $ body )
72
87
{
73
88
$ mockHttpResponse = $ this ->createMock (\Psr \Http \Message \ResponseInterface::class);
74
89
75
90
$ mockHttpResponse ->expects ($ this ->once ())
76
91
->method ('getBody ' )
77
- ->willReturn (' {"data": null, "errors": [{"foo": "bar"}]} ' );
92
+ ->willReturn ($ body );
78
93
79
94
$ builder = new ResponseBuilder ();
80
95
$ response = $ builder ->build ($ mockHttpResponse );
0 commit comments