@@ -66,7 +66,7 @@ final class GraphControllerTest extends TestCase
66
66
*/
67
67
public function testEndpointAction (string $ uri ): void
68
68
{
69
- $ client = static ::createClient (['test_case ' => 'connectionWithCORS ' ]);
69
+ $ client = self ::createClient (['test_case ' => 'connectionWithCORS ' ]);
70
70
$ this ->disableCatchExceptions ($ client );
71
71
72
72
$ client ->request ('GET ' , $ uri , ['query ' => $ this ->friendsQuery ], [], ['CONTENT_TYPE ' => 'application/graphql;charset=utf8 ' , 'HTTP_Origin ' => 'http://example.com ' ]);
@@ -87,7 +87,7 @@ public function testEndpointWithEmptyQuery(): void
87
87
{
88
88
$ this ->expectException (BadRequestHttpException::class);
89
89
$ this ->expectExceptionMessage ('Must provide query parameter ' );
90
- $ client = static ::createClient ();
90
+ $ client = self ::createClient ();
91
91
$ this ->disableCatchExceptions ($ client );
92
92
$ client ->request ('GET ' , '/ ' , []);
93
93
$ client ->getResponse ()->getContent ();
@@ -97,14 +97,14 @@ public function testEndpointWithEmptyPostJsonBodyQuery(): void
97
97
{
98
98
$ this ->expectException (BadRequestHttpException::class);
99
99
$ this ->expectExceptionMessage ('The request content body must not be empty when using json content type request. ' );
100
- $ client = static ::createClient ();
100
+ $ client = self ::createClient ();
101
101
$ this ->disableCatchExceptions ($ client );
102
102
$ client ->request ('POST ' , '/ ' , [], [], ['CONTENT_TYPE ' => 'application/json ' ]);
103
103
}
104
104
105
105
public function testEndpointWithJsonContentTypeAndGetQuery (): void
106
106
{
107
- $ client = static ::createClient (['test_case ' => 'connectionWithCORS ' ]);
107
+ $ client = self ::createClient (['test_case ' => 'connectionWithCORS ' ]);
108
108
$ this ->disableCatchExceptions ($ client );
109
109
$ client ->request ('GET ' , '/ ' , ['query ' => $ this ->friendsQuery ], [], ['CONTENT_TYPE ' => 'application/json ' ]);
110
110
$ result = $ client ->getResponse ()->getContent ();
@@ -115,15 +115,15 @@ public function testEndpointWithInvalidBodyQuery(): void
115
115
{
116
116
$ this ->expectException (BadRequestHttpException::class);
117
117
$ this ->expectExceptionMessage ('POST body sent invalid JSON ' );
118
- $ client = static ::createClient ();
118
+ $ client = self ::createClient ();
119
119
$ this ->disableCatchExceptions ($ client );
120
120
$ client ->request ('GET ' , '/ ' , [], [], ['CONTENT_TYPE ' => 'application/json ' ], '{ ' );
121
121
$ client ->getResponse ()->getContent ();
122
122
}
123
123
124
124
public function testEndpointActionWithVariables (): void
125
125
{
126
- $ client = static ::createClient (['test_case ' => 'connection ' ]);
126
+ $ client = self ::createClient (['test_case ' => 'connection ' ]);
127
127
$ this ->disableCatchExceptions ($ client );
128
128
129
129
$ query = <<<'EOF'
@@ -151,7 +151,7 @@ public function testEndpointActionWithInvalidVariables(): void
151
151
{
152
152
$ this ->expectException (BadRequestHttpException::class);
153
153
$ this ->expectExceptionMessage ('Variables are invalid JSON ' );
154
- $ client = static ::createClient (['test_case ' => 'connection ' ]);
154
+ $ client = self ::createClient (['test_case ' => 'connection ' ]);
155
155
$ this ->disableCatchExceptions ($ client );
156
156
157
157
$ query = <<<'EOF'
@@ -167,7 +167,7 @@ public function testMultipleEndpointActionWithUnknownSchemaName(): void
167
167
{
168
168
$ this ->expectException (NotFoundHttpException::class);
169
169
$ this ->expectExceptionMessage ('Could not find "fake" schema. ' );
170
- $ client = static ::createClient (['test_case ' => 'connection ' ]);
170
+ $ client = self ::createClient (['test_case ' => 'connection ' ]);
171
171
$ this ->disableCatchExceptions ($ client );
172
172
173
173
$ query = <<<'EOF'
@@ -181,7 +181,7 @@ public function testMultipleEndpointActionWithUnknownSchemaName(): void
181
181
182
182
public function testEndpointActionWithOperationName (): void
183
183
{
184
- $ client = static ::createClient (['test_case ' => 'connection ' ]);
184
+ $ client = self ::createClient (['test_case ' => 'connection ' ]);
185
185
$ this ->disableCatchExceptions ($ client );
186
186
187
187
$ query = $ this ->friendsQuery ."\n" .$ this ->friendsTotalCountQuery ;
@@ -196,7 +196,7 @@ public function testEndpointActionWithOperationName(): void
196
196
*/
197
197
public function testBatchEndpointAction (string $ uri ): void
198
198
{
199
- $ client = static ::createClient (['test_case ' => 'connection ' ]);
199
+ $ client = self ::createClient (['test_case ' => 'connection ' ]);
200
200
$ this ->disableCatchExceptions ($ client );
201
201
202
202
$ data = [
@@ -233,7 +233,7 @@ public function testBatchEndpointWithEmptyQuery(): void
233
233
{
234
234
$ this ->expectException (BadRequestHttpException::class);
235
235
$ this ->expectExceptionMessage ('Must provide at least one valid query. ' );
236
- $ client = static ::createClient ();
236
+ $ client = self ::createClient ();
237
237
$ this ->disableCatchExceptions ($ client );
238
238
$ client ->request ('GET ' , '/batch ' , [], [], ['CONTENT_TYPE ' => 'application/json ' ], '{} ' );
239
239
$ client ->getResponse ()->getContent ();
@@ -243,7 +243,7 @@ public function testBatchEndpointWrongContentType(): void
243
243
{
244
244
$ this ->expectException (BadRequestHttpException::class);
245
245
$ this ->expectExceptionMessage ('Batching parser only accepts "application/json" or "multipart/form-data" content-type but got "". ' );
246
- $ client = static ::createClient ();
246
+ $ client = self ::createClient ();
247
247
$ this ->disableCatchExceptions ($ client );
248
248
$ client ->request ('GET ' , '/batch ' );
249
249
$ client ->getResponse ()->getContent ();
@@ -253,7 +253,7 @@ public function testBatchEndpointWithInvalidJson(): void
253
253
{
254
254
$ this ->expectException (BadRequestHttpException::class);
255
255
$ this ->expectExceptionMessage ('POST body sent invalid JSON ' );
256
- $ client = static ::createClient ();
256
+ $ client = self ::createClient ();
257
257
$ this ->disableCatchExceptions ($ client );
258
258
$ client ->request ('GET ' , '/batch ' , [], [], ['CONTENT_TYPE ' => 'application/json ' ], '{ ' );
259
259
$ client ->getResponse ()->getContent ();
@@ -263,15 +263,15 @@ public function testBatchEndpointWithInvalidQuery(): void
263
263
{
264
264
$ this ->expectException (BadRequestHttpException::class);
265
265
$ this ->expectExceptionMessage ('1 is not a valid query ' );
266
- $ client = static ::createClient ();
266
+ $ client = self ::createClient ();
267
267
$ this ->disableCatchExceptions ($ client );
268
268
$ client ->request ('GET ' , '/batch ' , [], [], ['CONTENT_TYPE ' => 'application/json ' ], '{"test" : {"query": 1}} ' );
269
269
$ client ->getResponse ()->getContent ();
270
270
}
271
271
272
272
public function testPreflightedRequestWhenDisabled (): void
273
273
{
274
- $ client = static ::createClient (['test_case ' => 'connection ' ]);
274
+ $ client = self ::createClient (['test_case ' => 'connection ' ]);
275
275
$ this ->disableCatchExceptions ($ client );
276
276
$ client ->request ('OPTIONS ' , '/ ' , [], [], ['HTTP_Origin ' => 'http://example.com ' ]);
277
277
$ response = $ client ->getResponse ();
@@ -281,34 +281,31 @@ public function testPreflightedRequestWhenDisabled(): void
281
281
282
282
public function testUnAuthorizedMethod (): void
283
283
{
284
- $ client = static ::createClient (['test_case ' => 'connection ' ]);
284
+ $ client = self ::createClient (['test_case ' => 'connection ' ]);
285
285
$ this ->disableCatchExceptions ($ client );
286
286
$ client ->request ('PUT ' , '/ ' , [], [], ['HTTP_Origin ' => 'http://example.com ' ]);
287
287
$ this ->assertSame (405 , $ client ->getResponse ()->getStatusCode ());
288
288
}
289
289
290
290
public function testPreflightedRequestWhenEnabled (): void
291
291
{
292
- $ client = static ::createClient (['test_case ' => 'connectionWithCORS ' ]);
292
+ $ client = self ::createClient (['test_case ' => 'connectionWithCORS ' ]);
293
293
$ this ->disableCatchExceptions ($ client );
294
294
$ client ->request ('OPTIONS ' , '/batch ' , [], [], ['HTTP_Origin ' => 'http://example.com ' ]);
295
295
$ this ->assertCORSHeadersExists ($ client );
296
296
}
297
297
298
298
public function testNoCORSHeadersIfOriginHeaderNotExists (): void
299
299
{
300
- $ client = static ::createClient (['test_case ' => 'connectionWithCORS ' ]);
300
+ $ client = self ::createClient (['test_case ' => 'connectionWithCORS ' ]);
301
301
$ this ->disableCatchExceptions ($ client );
302
302
$ client ->request ('GET ' , '/ ' , ['query ' => $ this ->friendsQuery ], [], ['CONTENT_TYPE ' => 'application/graphql ' ]);
303
303
$ result = $ client ->getResponse ()->getContent ();
304
304
$ this ->assertSame (['data ' => $ this ->expectedData ], json_decode ($ result , true ), $ result );
305
305
$ this ->assertCORSHeadersNotExists ($ client );
306
306
}
307
307
308
- /**
309
- * @param KernelBrowser $client
310
- */
311
- private function assertCORSHeadersNotExists ($ client ): void
308
+ private function assertCORSHeadersNotExists (KernelBrowser $ client ): void
312
309
{
313
310
$ headers = $ client ->getResponse ()->headers ->all ();
314
311
$ this ->assertArrayNotHasKey ('access-control-allow-origin ' , $ headers );
@@ -318,10 +315,7 @@ private function assertCORSHeadersNotExists($client): void
318
315
$ this ->assertArrayNotHasKey ('access-control-max-age ' , $ headers );
319
316
}
320
317
321
- /**
322
- * @param KernelBrowser $client
323
- */
324
- private function assertCORSHeadersExists ($ client ): void
318
+ private function assertCORSHeadersExists (KernelBrowser $ client ): void
325
319
{
326
320
$ response = $ client ->getResponse ();
327
321
$ this ->assertSame (200 , $ response ->getStatusCode ());
0 commit comments