Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Test Failed
Push — 0.14 ( 43b99b...a77a31 )
by Jérémiah
01:55 queued 11s
created
src/Config/Processor/InheritanceProcessor.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
     private static function removedDecorators(array $configs): array
41 41
     {
42
-        return array_filter($configs, fn ($config) => !isset($config['decorator']) || true !== $config['decorator']);
42
+        return array_filter($configs, fn($config) => !isset($config['decorator']) || true !== $config['decorator']);
43 43
     }
44 44
 
45 45
     private static function processConfigsHeirs(array $configs): array
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
         $parentTypes = array_intersect_key($configs, array_flip($parents));
102 102
 
103 103
         // Restore initial order
104
-        uksort($parentTypes, fn ($a, $b) => (int) (array_search($a, $parents, true) > array_search($b, $parents, true)));
104
+        uksort($parentTypes, fn($a, $b) => (int) (array_search($a, $parents, true) > array_search($b, $parents, true)));
105 105
 
106 106
         $mergedParentsConfig = self::mergeConfigs(...array_column($parentTypes, 'config'));
107 107
         $childType = $configs[$child];
Please login to merge, or discard this patch.
tests/Functional/Exception/ExceptionTest.php 5 patches
Indentation   -26 removed lines patch added patch discarded remove patch
@@ -18,29 +18,3 @@
 block discarded – undo
18 18
     public function testExceptionIsMappedToAWarning(): void
19 19
     {
20 20
         $query = <<<'EOF'
21
-            query ExceptionQuery {
22
-                test
23
-            }
24
-            EOF;
25
-
26
-        $expectedData = [
27
-            'test' => null,
28
-        ];
29
-
30
-        $expectedErrors = [
31
-            [
32
-                'message' => 'Invalid argument exception',
33
-                'extensions' => ['category' => 'user'],
34
-                'locations' => [
35
-                    [
36
-                        'line' => 2,
37
-                        'column' => 5,
38
-                    ],
39
-                ],
40
-                'path' => ['test'],
41
-            ],
42
-        ];
43
-
44
-        $this->assertGraphQL($query, $expectedData, $expectedErrors);
45
-    }
46
-}
Please login to merge, or discard this patch.
Switch Indentation   -26 removed lines patch added patch discarded remove patch
@@ -18,29 +18,3 @@
 block discarded – undo
18 18
     public function testExceptionIsMappedToAWarning(): void
19 19
     {
20 20
         $query = <<<'EOF'
21
-            query ExceptionQuery {
22
-                test
23
-            }
24
-            EOF;
25
-
26
-        $expectedData = [
27
-            'test' => null,
28
-        ];
29
-
30
-        $expectedErrors = [
31
-            [
32
-                'message' => 'Invalid argument exception',
33
-                'extensions' => ['category' => 'user'],
34
-                'locations' => [
35
-                    [
36
-                        'line' => 2,
37
-                        'column' => 5,
38
-                    ],
39
-                ],
40
-                'path' => ['test'],
41
-            ],
42
-        ];
43
-
44
-        $this->assertGraphQL($query, $expectedData, $expectedErrors);
45
-    }
46
-}
Please login to merge, or discard this patch.
Spacing   -26 removed lines patch added patch discarded remove patch
@@ -18,29 +18,3 @@
 block discarded – undo
18 18
     public function testExceptionIsMappedToAWarning(): void
19 19
     {
20 20
         $query = <<<'EOF'
21
-            query ExceptionQuery {
22
-                test
23
-            }
24
-            EOF;
25
-
26
-        $expectedData = [
27
-            'test' => null,
28
-        ];
29
-
30
-        $expectedErrors = [
31
-            [
32
-                'message' => 'Invalid argument exception',
33
-                'extensions' => ['category' => 'user'],
34
-                'locations' => [
35
-                    [
36
-                        'line' => 2,
37
-                        'column' => 5,
38
-                    ],
39
-                ],
40
-                'path' => ['test'],
41
-            ],
42
-        ];
43
-
44
-        $this->assertGraphQL($query, $expectedData, $expectedErrors);
45
-    }
46
-}
Please login to merge, or discard this patch.
Braces   -26 removed lines patch added patch discarded remove patch
@@ -18,29 +18,3 @@
 block discarded – undo
18 18
     public function testExceptionIsMappedToAWarning(): void
19 19
     {
20 20
         $query = <<<'EOF'
21
-            query ExceptionQuery {
22
-                test
23
-            }
24
-            EOF;
25
-
26
-        $expectedData = [
27
-            'test' => null,
28
-        ];
29
-
30
-        $expectedErrors = [
31
-            [
32
-                'message' => 'Invalid argument exception',
33
-                'extensions' => ['category' => 'user'],
34
-                'locations' => [
35
-                    [
36
-                        'line' => 2,
37
-                        'column' => 5,
38
-                    ],
39
-                ],
40
-                'path' => ['test'],
41
-            ],
42
-        ];
43
-
44
-        $this->assertGraphQL($query, $expectedData, $expectedErrors);
45
-    }
46
-}
Please login to merge, or discard this patch.
Upper-Lower-Casing   -26 removed lines patch added patch discarded remove patch
@@ -18,29 +18,3 @@
 block discarded – undo
18 18
     public function testExceptionIsMappedToAWarning(): void
19 19
     {
20 20
         $query = <<<'EOF'
21
-            query ExceptionQuery {
22
-                test
23
-            }
24
-            EOF;
25
-
26
-        $expectedData = [
27
-            'test' => null,
28
-        ];
29
-
30
-        $expectedErrors = [
31
-            [
32
-                'message' => 'Invalid argument exception',
33
-                'extensions' => ['category' => 'user'],
34
-                'locations' => [
35
-                    [
36
-                        'line' => 2,
37
-                        'column' => 5,
38
-                    ],
39
-                ],
40
-                'path' => ['test'],
41
-            ],
42
-        ];
43
-
44
-        $this->assertGraphQL($query, $expectedData, $expectedErrors);
45
-    }
46
-}
Please login to merge, or discard this patch.
tests/Functional/Controller/GraphControllerTest.php 5 patches
Indentation   -318 removed lines patch added patch discarded remove patch
@@ -14,321 +14,3 @@
 block discarded – undo
14 14
 class GraphControllerTest extends TestCase
15 15
 {
16 16
     private string $friendsQuery = <<<'EOF'
17
-        query FriendsQuery {
18
-          user {
19
-            friends(first: 2) {
20
-              totalCount
21
-              edges {
22
-                friendshipTime
23
-                node {
24
-                  name
25
-                }
26
-              }
27
-            }
28
-          }
29
-        }
30
-        EOF;
31
-
32
-    private string $friendsTotalCountQuery = <<<'EOF'
33
-        query FriendsTotalCountQuery {
34
-          user {
35
-            friends {
36
-              totalCount
37
-            }
38
-          }
39
-        }
40
-        EOF;
41
-
42
-    private array $expectedData = [
43
-        'user' => [
44
-            'friends' => [
45
-                'totalCount' => 4,
46
-                'edges' => [
47
-                    [
48
-                        'friendshipTime' => 'Yesterday',
49
-                        'node' => [
50
-                            'name' => 'Nick',
51
-                        ],
52
-                    ],
53
-                    [
54
-                        'friendshipTime' => 'Yesterday',
55
-                        'node' => [
56
-                            'name' => 'Lee',
57
-                        ],
58
-                    ],
59
-                ],
60
-            ],
61
-        ],
62
-    ];
63
-
64
-    /**
65
-     * @dataProvider graphQLEndpointUriProvider
66
-     */
67
-    public function testEndpointAction(string $uri): void
68
-    {
69
-        $client = static::createClient(['test_case' => 'connectionWithCORS']);
70
-        $this->disableCatchExceptions($client);
71
-
72
-        $client->request('GET', $uri, ['query' => $this->friendsQuery], [], ['CONTENT_TYPE' => 'application/graphql;charset=utf8', 'HTTP_Origin' => 'http://example.com']);
73
-        $result = $client->getResponse()->getContent();
74
-        $this->assertSame(['data' => $this->expectedData], json_decode($result, true), $result);
75
-        $this->assertCORSHeadersExists($client);
76
-    }
77
-
78
-    public function graphQLEndpointUriProvider(): array
79
-    {
80
-        return [
81
-            ['/'],
82
-            ['/graphql/default'],
83
-        ];
84
-    }
85
-
86
-    public function testEndpointWithEmptyQuery(): void
87
-    {
88
-        $this->expectException(BadRequestHttpException::class);
89
-        $this->expectExceptionMessage('Must provide query parameter');
90
-        $client = static::createClient();
91
-        $this->disableCatchExceptions($client);
92
-        $client->request('GET', '/', []);
93
-        $client->getResponse()->getContent();
94
-    }
95
-
96
-    public function testEndpointWithEmptyPostJsonBodyQuery(): void
97
-    {
98
-        $this->expectException(BadRequestHttpException::class);
99
-        $this->expectExceptionMessage('The request content body must not be empty when using json content type request.');
100
-        $client = static::createClient();
101
-        $this->disableCatchExceptions($client);
102
-        $client->request('POST', '/', [], [], ['CONTENT_TYPE' => 'application/json']);
103
-    }
104
-
105
-    public function testEndpointWithJsonContentTypeAndGetQuery(): void
106
-    {
107
-        $client = static::createClient(['test_case' => 'connectionWithCORS']);
108
-        $this->disableCatchExceptions($client);
109
-        $client->request('GET', '/', ['query' => $this->friendsQuery], [], ['CONTENT_TYPE' => 'application/json']);
110
-        $result = $client->getResponse()->getContent();
111
-        $this->assertSame(['data' => $this->expectedData], json_decode($result, true), $result);
112
-    }
113
-
114
-    public function testEndpointWithInvalidBodyQuery(): void
115
-    {
116
-        $this->expectException(BadRequestHttpException::class);
117
-        $this->expectExceptionMessage('POST body sent invalid JSON');
118
-        $client = static::createClient();
119
-        $this->disableCatchExceptions($client);
120
-        $client->request('GET', '/', [], [], ['CONTENT_TYPE' => 'application/json'], '{');
121
-        $client->getResponse()->getContent();
122
-    }
123
-
124
-    public function testEndpointActionWithVariables(): void
125
-    {
126
-        $client = static::createClient(['test_case' => 'connection']);
127
-        $this->disableCatchExceptions($client);
128
-
129
-        $query = <<<'EOF'
130
-            query FriendsQuery($firstFriends: Int) {
131
-              user {
132
-                friends(first: $firstFriends) {
133
-                  totalCount
134
-                  edges {
135
-                    friendshipTime
136
-                    node {
137
-                      name
138
-                    }
139
-                  }
140
-                }
141
-              }
142
-            }
143
-            EOF;
144
-
145
-        $content = json_encode(['query' => $query, 'variables' => '{"firstFriends": 2}']) ?: null;
146
-        $client->request('GET', '/', [], [], ['CONTENT_TYPE' => 'application/json'], $content);
147
-        $this->assertSame(200, $client->getResponse()->getStatusCode());
148
-    }
149
-
150
-    public function testEndpointActionWithInvalidVariables(): void
151
-    {
152
-        $this->expectException(BadRequestHttpException::class);
153
-        $this->expectExceptionMessage('Variables are invalid JSON');
154
-        $client = static::createClient(['test_case' => 'connection']);
155
-        $this->disableCatchExceptions($client);
156
-
157
-        $query = <<<'EOF'
158
-            query {
159
-              user
160
-            }
161
-            EOF;
162
-
163
-        $client->request('GET', '/', ['query' => $query, 'variables' => '"firstFriends": 2}']);
164
-    }
165
-
166
-    public function testMultipleEndpointActionWithUnknownSchemaName(): void
167
-    {
168
-        $this->expectException(NotFoundHttpException::class);
169
-        $this->expectExceptionMessage('Could not found "fake" schema.');
170
-        $client = static::createClient(['test_case' => 'connection']);
171
-        $this->disableCatchExceptions($client);
172
-
173
-        $query = <<<'EOF'
174
-            query {
175
-              user
176
-            }
177
-            EOF;
178
-
179
-        $client->request('GET', '/graphql/fake', ['query' => $query]);
180
-    }
181
-
182
-    public function testEndpointActionWithOperationName(): void
183
-    {
184
-        $client = static::createClient(['test_case' => 'connection']);
185
-        $this->disableCatchExceptions($client);
186
-
187
-        $query = $this->friendsQuery."\n".$this->friendsTotalCountQuery;
188
-
189
-        $client->request('POST', '/', ['query' => $query, 'operationName' => 'FriendsQuery'], [], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
190
-        $result = $client->getResponse()->getContent();
191
-        $this->assertSame(['data' => $this->expectedData], json_decode($result, true), $result);
192
-    }
193
-
194
-    /**
195
-     * @dataProvider graphQLBatchEndpointUriProvider
196
-     */
197
-    public function testBatchEndpointAction(string $uri): void
198
-    {
199
-        $client = static::createClient(['test_case' => 'connection']);
200
-        $this->disableCatchExceptions($client);
201
-
202
-        $data = [
203
-            [
204
-                'id' => 'friends',
205
-                'query' => $this->friendsQuery,
206
-            ],
207
-            [
208
-                'id' => 'friendsTotalCount',
209
-                'query' => $this->friendsTotalCountQuery,
210
-            ],
211
-        ];
212
-
213
-        $content = json_encode($data) ?: null;
214
-        $client->request('POST', $uri, [], [], ['CONTENT_TYPE' => 'application/json'], $content);
215
-        $result = $client->getResponse()->getContent();
216
-
217
-        $expected = [
218
-            ['id' => 'friends', 'payload' => ['data' => $this->expectedData]],
219
-            ['id' => 'friendsTotalCount', 'payload' => ['data' => ['user' => ['friends' => ['totalCount' => 4]]]]],
220
-        ];
221
-        $this->assertSame($expected, json_decode($result, true), $result);
222
-    }
223
-
224
-    public function graphQLBatchEndpointUriProvider(): array
225
-    {
226
-        return [
227
-            ['/batch'],
228
-            ['/graphql/default/batch'],
229
-        ];
230
-    }
231
-
232
-    public function testBatchEndpointWithEmptyQuery(): void
233
-    {
234
-        $this->expectException(BadRequestHttpException::class);
235
-        $this->expectExceptionMessage('Must provide at least one valid query.');
236
-        $client = static::createClient();
237
-        $this->disableCatchExceptions($client);
238
-        $client->request('GET', '/batch', [], [], ['CONTENT_TYPE' => 'application/json'], '{}');
239
-        $client->getResponse()->getContent();
240
-    }
241
-
242
-    public function testBatchEndpointWrongContentType(): void
243
-    {
244
-        $this->expectException(BadRequestHttpException::class);
245
-        $this->expectExceptionMessage('Batching parser only accepts "application/json" or "multipart/form-data" content-type but got "".');
246
-        $client = static::createClient();
247
-        $this->disableCatchExceptions($client);
248
-        $client->request('GET', '/batch');
249
-        $client->getResponse()->getContent();
250
-    }
251
-
252
-    public function testBatchEndpointWithInvalidJson(): void
253
-    {
254
-        $this->expectException(BadRequestHttpException::class);
255
-        $this->expectExceptionMessage('POST body sent invalid JSON');
256
-        $client = static::createClient();
257
-        $this->disableCatchExceptions($client);
258
-        $client->request('GET', '/batch', [], [], ['CONTENT_TYPE' => 'application/json'], '{');
259
-        $client->getResponse()->getContent();
260
-    }
261
-
262
-    public function testBatchEndpointWithInvalidQuery(): void
263
-    {
264
-        $this->expectException(BadRequestHttpException::class);
265
-        $this->expectExceptionMessage('1 is not a valid query');
266
-        $client = static::createClient();
267
-        $this->disableCatchExceptions($client);
268
-        $client->request('GET', '/batch', [], [], ['CONTENT_TYPE' => 'application/json'], '{"test" : {"query": 1}}');
269
-        $client->getResponse()->getContent();
270
-    }
271
-
272
-    public function testPreflightedRequestWhenDisabled(): void
273
-    {
274
-        $client = static::createClient(['test_case' => 'connection']);
275
-        $this->disableCatchExceptions($client);
276
-        $client->request('OPTIONS', '/', [], [], ['HTTP_Origin' => 'http://example.com']);
277
-        $response = $client->getResponse();
278
-        $this->assertSame(200, $response->getStatusCode());
279
-        $this->assertCORSHeadersNotExists($client);
280
-    }
281
-
282
-    public function testUnAuthorizedMethod(): void
283
-    {
284
-        $client = static::createClient(['test_case' => 'connection']);
285
-        $this->disableCatchExceptions($client);
286
-        $client->request('PUT', '/', [], [], ['HTTP_Origin' => 'http://example.com']);
287
-        $this->assertSame(405, $client->getResponse()->getStatusCode());
288
-    }
289
-
290
-    public function testPreflightedRequestWhenEnabled(): void
291
-    {
292
-        $client = static::createClient(['test_case' => 'connectionWithCORS']);
293
-        $this->disableCatchExceptions($client);
294
-        $client->request('OPTIONS', '/batch', [], [], ['HTTP_Origin' => 'http://example.com']);
295
-        $this->assertCORSHeadersExists($client);
296
-    }
297
-
298
-    public function testNoCORSHeadersIfOriginHeaderNotExists(): void
299
-    {
300
-        $client = static::createClient(['test_case' => 'connectionWithCORS']);
301
-        $this->disableCatchExceptions($client);
302
-        $client->request('GET', '/', ['query' => $this->friendsQuery], [], ['CONTENT_TYPE' => 'application/graphql']);
303
-        $result = $client->getResponse()->getContent();
304
-        $this->assertSame(['data' => $this->expectedData], json_decode($result, true), $result);
305
-        $this->assertCORSHeadersNotExists($client);
306
-    }
307
-
308
-    /**
309
-     * @param KernelBrowser $client
310
-     */
311
-    private function assertCORSHeadersNotExists($client): void
312
-    {
313
-        $headers = $client->getResponse()->headers->all();
314
-        $this->assertArrayNotHasKey('access-control-allow-origin', $headers);
315
-        $this->assertArrayNotHasKey('access-control-allow-methods', $headers);
316
-        $this->assertArrayNotHasKey('access-control-allow-credentials', $headers);
317
-        $this->assertArrayNotHasKey('access-control-allow-headers', $headers);
318
-        $this->assertArrayNotHasKey('access-control-max-age', $headers);
319
-    }
320
-
321
-    /**
322
-     * @param KernelBrowser $client
323
-     */
324
-    private function assertCORSHeadersExists($client): void
325
-    {
326
-        $response = $client->getResponse();
327
-        $this->assertSame(200, $response->getStatusCode());
328
-        $this->assertSame('http://example.com', $response->headers->get('Access-Control-Allow-Origin'));
329
-        $this->assertSame('OPTIONS, GET, POST', $response->headers->get('Access-Control-Allow-Methods'));
330
-        $this->assertSame('true', $response->headers->get('Access-Control-Allow-Credentials'));
331
-        $this->assertSame('Content-Type, Authorization', $response->headers->get('Access-Control-Allow-Headers'));
332
-        $this->assertSame('3600', $response->headers->get('Access-Control-Max-Age'));
333
-    }
334
-}
Please login to merge, or discard this patch.
Switch Indentation   -318 removed lines patch added patch discarded remove patch
@@ -14,321 +14,3 @@
 block discarded – undo
14 14
 class GraphControllerTest extends TestCase
15 15
 {
16 16
     private string $friendsQuery = <<<'EOF'
17
-        query FriendsQuery {
18
-          user {
19
-            friends(first: 2) {
20
-              totalCount
21
-              edges {
22
-                friendshipTime
23
-                node {
24
-                  name
25
-                }
26
-              }
27
-            }
28
-          }
29
-        }
30
-        EOF;
31
-
32
-    private string $friendsTotalCountQuery = <<<'EOF'
33
-        query FriendsTotalCountQuery {
34
-          user {
35
-            friends {
36
-              totalCount
37
-            }
38
-          }
39
-        }
40
-        EOF;
41
-
42
-    private array $expectedData = [
43
-        'user' => [
44
-            'friends' => [
45
-                'totalCount' => 4,
46
-                'edges' => [
47
-                    [
48
-                        'friendshipTime' => 'Yesterday',
49
-                        'node' => [
50
-                            'name' => 'Nick',
51
-                        ],
52
-                    ],
53
-                    [
54
-                        'friendshipTime' => 'Yesterday',
55
-                        'node' => [
56
-                            'name' => 'Lee',
57
-                        ],
58
-                    ],
59
-                ],
60
-            ],
61
-        ],
62
-    ];
63
-
64
-    /**
65
-     * @dataProvider graphQLEndpointUriProvider
66
-     */
67
-    public function testEndpointAction(string $uri): void
68
-    {
69
-        $client = static::createClient(['test_case' => 'connectionWithCORS']);
70
-        $this->disableCatchExceptions($client);
71
-
72
-        $client->request('GET', $uri, ['query' => $this->friendsQuery], [], ['CONTENT_TYPE' => 'application/graphql;charset=utf8', 'HTTP_Origin' => 'http://example.com']);
73
-        $result = $client->getResponse()->getContent();
74
-        $this->assertSame(['data' => $this->expectedData], json_decode($result, true), $result);
75
-        $this->assertCORSHeadersExists($client);
76
-    }
77
-
78
-    public function graphQLEndpointUriProvider(): array
79
-    {
80
-        return [
81
-            ['/'],
82
-            ['/graphql/default'],
83
-        ];
84
-    }
85
-
86
-    public function testEndpointWithEmptyQuery(): void
87
-    {
88
-        $this->expectException(BadRequestHttpException::class);
89
-        $this->expectExceptionMessage('Must provide query parameter');
90
-        $client = static::createClient();
91
-        $this->disableCatchExceptions($client);
92
-        $client->request('GET', '/', []);
93
-        $client->getResponse()->getContent();
94
-    }
95
-
96
-    public function testEndpointWithEmptyPostJsonBodyQuery(): void
97
-    {
98
-        $this->expectException(BadRequestHttpException::class);
99
-        $this->expectExceptionMessage('The request content body must not be empty when using json content type request.');
100
-        $client = static::createClient();
101
-        $this->disableCatchExceptions($client);
102
-        $client->request('POST', '/', [], [], ['CONTENT_TYPE' => 'application/json']);
103
-    }
104
-
105
-    public function testEndpointWithJsonContentTypeAndGetQuery(): void
106
-    {
107
-        $client = static::createClient(['test_case' => 'connectionWithCORS']);
108
-        $this->disableCatchExceptions($client);
109
-        $client->request('GET', '/', ['query' => $this->friendsQuery], [], ['CONTENT_TYPE' => 'application/json']);
110
-        $result = $client->getResponse()->getContent();
111
-        $this->assertSame(['data' => $this->expectedData], json_decode($result, true), $result);
112
-    }
113
-
114
-    public function testEndpointWithInvalidBodyQuery(): void
115
-    {
116
-        $this->expectException(BadRequestHttpException::class);
117
-        $this->expectExceptionMessage('POST body sent invalid JSON');
118
-        $client = static::createClient();
119
-        $this->disableCatchExceptions($client);
120
-        $client->request('GET', '/', [], [], ['CONTENT_TYPE' => 'application/json'], '{');
121
-        $client->getResponse()->getContent();
122
-    }
123
-
124
-    public function testEndpointActionWithVariables(): void
125
-    {
126
-        $client = static::createClient(['test_case' => 'connection']);
127
-        $this->disableCatchExceptions($client);
128
-
129
-        $query = <<<'EOF'
130
-            query FriendsQuery($firstFriends: Int) {
131
-              user {
132
-                friends(first: $firstFriends) {
133
-                  totalCount
134
-                  edges {
135
-                    friendshipTime
136
-                    node {
137
-                      name
138
-                    }
139
-                  }
140
-                }
141
-              }
142
-            }
143
-            EOF;
144
-
145
-        $content = json_encode(['query' => $query, 'variables' => '{"firstFriends": 2}']) ?: null;
146
-        $client->request('GET', '/', [], [], ['CONTENT_TYPE' => 'application/json'], $content);
147
-        $this->assertSame(200, $client->getResponse()->getStatusCode());
148
-    }
149
-
150
-    public function testEndpointActionWithInvalidVariables(): void
151
-    {
152
-        $this->expectException(BadRequestHttpException::class);
153
-        $this->expectExceptionMessage('Variables are invalid JSON');
154
-        $client = static::createClient(['test_case' => 'connection']);
155
-        $this->disableCatchExceptions($client);
156
-
157
-        $query = <<<'EOF'
158
-            query {
159
-              user
160
-            }
161
-            EOF;
162
-
163
-        $client->request('GET', '/', ['query' => $query, 'variables' => '"firstFriends": 2}']);
164
-    }
165
-
166
-    public function testMultipleEndpointActionWithUnknownSchemaName(): void
167
-    {
168
-        $this->expectException(NotFoundHttpException::class);
169
-        $this->expectExceptionMessage('Could not found "fake" schema.');
170
-        $client = static::createClient(['test_case' => 'connection']);
171
-        $this->disableCatchExceptions($client);
172
-
173
-        $query = <<<'EOF'
174
-            query {
175
-              user
176
-            }
177
-            EOF;
178
-
179
-        $client->request('GET', '/graphql/fake', ['query' => $query]);
180
-    }
181
-
182
-    public function testEndpointActionWithOperationName(): void
183
-    {
184
-        $client = static::createClient(['test_case' => 'connection']);
185
-        $this->disableCatchExceptions($client);
186
-
187
-        $query = $this->friendsQuery."\n".$this->friendsTotalCountQuery;
188
-
189
-        $client->request('POST', '/', ['query' => $query, 'operationName' => 'FriendsQuery'], [], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
190
-        $result = $client->getResponse()->getContent();
191
-        $this->assertSame(['data' => $this->expectedData], json_decode($result, true), $result);
192
-    }
193
-
194
-    /**
195
-     * @dataProvider graphQLBatchEndpointUriProvider
196
-     */
197
-    public function testBatchEndpointAction(string $uri): void
198
-    {
199
-        $client = static::createClient(['test_case' => 'connection']);
200
-        $this->disableCatchExceptions($client);
201
-
202
-        $data = [
203
-            [
204
-                'id' => 'friends',
205
-                'query' => $this->friendsQuery,
206
-            ],
207
-            [
208
-                'id' => 'friendsTotalCount',
209
-                'query' => $this->friendsTotalCountQuery,
210
-            ],
211
-        ];
212
-
213
-        $content = json_encode($data) ?: null;
214
-        $client->request('POST', $uri, [], [], ['CONTENT_TYPE' => 'application/json'], $content);
215
-        $result = $client->getResponse()->getContent();
216
-
217
-        $expected = [
218
-            ['id' => 'friends', 'payload' => ['data' => $this->expectedData]],
219
-            ['id' => 'friendsTotalCount', 'payload' => ['data' => ['user' => ['friends' => ['totalCount' => 4]]]]],
220
-        ];
221
-        $this->assertSame($expected, json_decode($result, true), $result);
222
-    }
223
-
224
-    public function graphQLBatchEndpointUriProvider(): array
225
-    {
226
-        return [
227
-            ['/batch'],
228
-            ['/graphql/default/batch'],
229
-        ];
230
-    }
231
-
232
-    public function testBatchEndpointWithEmptyQuery(): void
233
-    {
234
-        $this->expectException(BadRequestHttpException::class);
235
-        $this->expectExceptionMessage('Must provide at least one valid query.');
236
-        $client = static::createClient();
237
-        $this->disableCatchExceptions($client);
238
-        $client->request('GET', '/batch', [], [], ['CONTENT_TYPE' => 'application/json'], '{}');
239
-        $client->getResponse()->getContent();
240
-    }
241
-
242
-    public function testBatchEndpointWrongContentType(): void
243
-    {
244
-        $this->expectException(BadRequestHttpException::class);
245
-        $this->expectExceptionMessage('Batching parser only accepts "application/json" or "multipart/form-data" content-type but got "".');
246
-        $client = static::createClient();
247
-        $this->disableCatchExceptions($client);
248
-        $client->request('GET', '/batch');
249
-        $client->getResponse()->getContent();
250
-    }
251
-
252
-    public function testBatchEndpointWithInvalidJson(): void
253
-    {
254
-        $this->expectException(BadRequestHttpException::class);
255
-        $this->expectExceptionMessage('POST body sent invalid JSON');
256
-        $client = static::createClient();
257
-        $this->disableCatchExceptions($client);
258
-        $client->request('GET', '/batch', [], [], ['CONTENT_TYPE' => 'application/json'], '{');
259
-        $client->getResponse()->getContent();
260
-    }
261
-
262
-    public function testBatchEndpointWithInvalidQuery(): void
263
-    {
264
-        $this->expectException(BadRequestHttpException::class);
265
-        $this->expectExceptionMessage('1 is not a valid query');
266
-        $client = static::createClient();
267
-        $this->disableCatchExceptions($client);
268
-        $client->request('GET', '/batch', [], [], ['CONTENT_TYPE' => 'application/json'], '{"test" : {"query": 1}}');
269
-        $client->getResponse()->getContent();
270
-    }
271
-
272
-    public function testPreflightedRequestWhenDisabled(): void
273
-    {
274
-        $client = static::createClient(['test_case' => 'connection']);
275
-        $this->disableCatchExceptions($client);
276
-        $client->request('OPTIONS', '/', [], [], ['HTTP_Origin' => 'http://example.com']);
277
-        $response = $client->getResponse();
278
-        $this->assertSame(200, $response->getStatusCode());
279
-        $this->assertCORSHeadersNotExists($client);
280
-    }
281
-
282
-    public function testUnAuthorizedMethod(): void
283
-    {
284
-        $client = static::createClient(['test_case' => 'connection']);
285
-        $this->disableCatchExceptions($client);
286
-        $client->request('PUT', '/', [], [], ['HTTP_Origin' => 'http://example.com']);
287
-        $this->assertSame(405, $client->getResponse()->getStatusCode());
288
-    }
289
-
290
-    public function testPreflightedRequestWhenEnabled(): void
291
-    {
292
-        $client = static::createClient(['test_case' => 'connectionWithCORS']);
293
-        $this->disableCatchExceptions($client);
294
-        $client->request('OPTIONS', '/batch', [], [], ['HTTP_Origin' => 'http://example.com']);
295
-        $this->assertCORSHeadersExists($client);
296
-    }
297
-
298
-    public function testNoCORSHeadersIfOriginHeaderNotExists(): void
299
-    {
300
-        $client = static::createClient(['test_case' => 'connectionWithCORS']);
301
-        $this->disableCatchExceptions($client);
302
-        $client->request('GET', '/', ['query' => $this->friendsQuery], [], ['CONTENT_TYPE' => 'application/graphql']);
303
-        $result = $client->getResponse()->getContent();
304
-        $this->assertSame(['data' => $this->expectedData], json_decode($result, true), $result);
305
-        $this->assertCORSHeadersNotExists($client);
306
-    }
307
-
308
-    /**
309
-     * @param KernelBrowser $client
310
-     */
311
-    private function assertCORSHeadersNotExists($client): void
312
-    {
313
-        $headers = $client->getResponse()->headers->all();
314
-        $this->assertArrayNotHasKey('access-control-allow-origin', $headers);
315
-        $this->assertArrayNotHasKey('access-control-allow-methods', $headers);
316
-        $this->assertArrayNotHasKey('access-control-allow-credentials', $headers);
317
-        $this->assertArrayNotHasKey('access-control-allow-headers', $headers);
318
-        $this->assertArrayNotHasKey('access-control-max-age', $headers);
319
-    }
320
-
321
-    /**
322
-     * @param KernelBrowser $client
323
-     */
324
-    private function assertCORSHeadersExists($client): void
325
-    {
326
-        $response = $client->getResponse();
327
-        $this->assertSame(200, $response->getStatusCode());
328
-        $this->assertSame('http://example.com', $response->headers->get('Access-Control-Allow-Origin'));
329
-        $this->assertSame('OPTIONS, GET, POST', $response->headers->get('Access-Control-Allow-Methods'));
330
-        $this->assertSame('true', $response->headers->get('Access-Control-Allow-Credentials'));
331
-        $this->assertSame('Content-Type, Authorization', $response->headers->get('Access-Control-Allow-Headers'));
332
-        $this->assertSame('3600', $response->headers->get('Access-Control-Max-Age'));
333
-    }
334
-}
Please login to merge, or discard this patch.
Spacing   -318 removed lines patch added patch discarded remove patch
@@ -14,321 +14,3 @@
 block discarded – undo
14 14
 class GraphControllerTest extends TestCase
15 15
 {
16 16
     private string $friendsQuery = <<<'EOF'
17
-        query FriendsQuery {
18
-          user {
19
-            friends(first: 2) {
20
-              totalCount
21
-              edges {
22
-                friendshipTime
23
-                node {
24
-                  name
25
-                }
26
-              }
27
-            }
28
-          }
29
-        }
30
-        EOF;
31
-
32
-    private string $friendsTotalCountQuery = <<<'EOF'
33
-        query FriendsTotalCountQuery {
34
-          user {
35
-            friends {
36
-              totalCount
37
-            }
38
-          }
39
-        }
40
-        EOF;
41
-
42
-    private array $expectedData = [
43
-        'user' => [
44
-            'friends' => [
45
-                'totalCount' => 4,
46
-                'edges' => [
47
-                    [
48
-                        'friendshipTime' => 'Yesterday',
49
-                        'node' => [
50
-                            'name' => 'Nick',
51
-                        ],
52
-                    ],
53
-                    [
54
-                        'friendshipTime' => 'Yesterday',
55
-                        'node' => [
56
-                            'name' => 'Lee',
57
-                        ],
58
-                    ],
59
-                ],
60
-            ],
61
-        ],
62
-    ];
63
-
64
-    /**
65
-     * @dataProvider graphQLEndpointUriProvider
66
-     */
67
-    public function testEndpointAction(string $uri): void
68
-    {
69
-        $client = static::createClient(['test_case' => 'connectionWithCORS']);
70
-        $this->disableCatchExceptions($client);
71
-
72
-        $client->request('GET', $uri, ['query' => $this->friendsQuery], [], ['CONTENT_TYPE' => 'application/graphql;charset=utf8', 'HTTP_Origin' => 'http://example.com']);
73
-        $result = $client->getResponse()->getContent();
74
-        $this->assertSame(['data' => $this->expectedData], json_decode($result, true), $result);
75
-        $this->assertCORSHeadersExists($client);
76
-    }
77
-
78
-    public function graphQLEndpointUriProvider(): array
79
-    {
80
-        return [
81
-            ['/'],
82
-            ['/graphql/default'],
83
-        ];
84
-    }
85
-
86
-    public function testEndpointWithEmptyQuery(): void
87
-    {
88
-        $this->expectException(BadRequestHttpException::class);
89
-        $this->expectExceptionMessage('Must provide query parameter');
90
-        $client = static::createClient();
91
-        $this->disableCatchExceptions($client);
92
-        $client->request('GET', '/', []);
93
-        $client->getResponse()->getContent();
94
-    }
95
-
96
-    public function testEndpointWithEmptyPostJsonBodyQuery(): void
97
-    {
98
-        $this->expectException(BadRequestHttpException::class);
99
-        $this->expectExceptionMessage('The request content body must not be empty when using json content type request.');
100
-        $client = static::createClient();
101
-        $this->disableCatchExceptions($client);
102
-        $client->request('POST', '/', [], [], ['CONTENT_TYPE' => 'application/json']);
103
-    }
104
-
105
-    public function testEndpointWithJsonContentTypeAndGetQuery(): void
106
-    {
107
-        $client = static::createClient(['test_case' => 'connectionWithCORS']);
108
-        $this->disableCatchExceptions($client);
109
-        $client->request('GET', '/', ['query' => $this->friendsQuery], [], ['CONTENT_TYPE' => 'application/json']);
110
-        $result = $client->getResponse()->getContent();
111
-        $this->assertSame(['data' => $this->expectedData], json_decode($result, true), $result);
112
-    }
113
-
114
-    public function testEndpointWithInvalidBodyQuery(): void
115
-    {
116
-        $this->expectException(BadRequestHttpException::class);
117
-        $this->expectExceptionMessage('POST body sent invalid JSON');
118
-        $client = static::createClient();
119
-        $this->disableCatchExceptions($client);
120
-        $client->request('GET', '/', [], [], ['CONTENT_TYPE' => 'application/json'], '{');
121
-        $client->getResponse()->getContent();
122
-    }
123
-
124
-    public function testEndpointActionWithVariables(): void
125
-    {
126
-        $client = static::createClient(['test_case' => 'connection']);
127
-        $this->disableCatchExceptions($client);
128
-
129
-        $query = <<<'EOF'
130
-            query FriendsQuery($firstFriends: Int) {
131
-              user {
132
-                friends(first: $firstFriends) {
133
-                  totalCount
134
-                  edges {
135
-                    friendshipTime
136
-                    node {
137
-                      name
138
-                    }
139
-                  }
140
-                }
141
-              }
142
-            }
143
-            EOF;
144
-
145
-        $content = json_encode(['query' => $query, 'variables' => '{"firstFriends": 2}']) ?: null;
146
-        $client->request('GET', '/', [], [], ['CONTENT_TYPE' => 'application/json'], $content);
147
-        $this->assertSame(200, $client->getResponse()->getStatusCode());
148
-    }
149
-
150
-    public function testEndpointActionWithInvalidVariables(): void
151
-    {
152
-        $this->expectException(BadRequestHttpException::class);
153
-        $this->expectExceptionMessage('Variables are invalid JSON');
154
-        $client = static::createClient(['test_case' => 'connection']);
155
-        $this->disableCatchExceptions($client);
156
-
157
-        $query = <<<'EOF'
158
-            query {
159
-              user
160
-            }
161
-            EOF;
162
-
163
-        $client->request('GET', '/', ['query' => $query, 'variables' => '"firstFriends": 2}']);
164
-    }
165
-
166
-    public function testMultipleEndpointActionWithUnknownSchemaName(): void
167
-    {
168
-        $this->expectException(NotFoundHttpException::class);
169
-        $this->expectExceptionMessage('Could not found "fake" schema.');
170
-        $client = static::createClient(['test_case' => 'connection']);
171
-        $this->disableCatchExceptions($client);
172
-
173
-        $query = <<<'EOF'
174
-            query {
175
-              user
176
-            }
177
-            EOF;
178
-
179
-        $client->request('GET', '/graphql/fake', ['query' => $query]);
180
-    }
181
-
182
-    public function testEndpointActionWithOperationName(): void
183
-    {
184
-        $client = static::createClient(['test_case' => 'connection']);
185
-        $this->disableCatchExceptions($client);
186
-
187
-        $query = $this->friendsQuery."\n".$this->friendsTotalCountQuery;
188
-
189
-        $client->request('POST', '/', ['query' => $query, 'operationName' => 'FriendsQuery'], [], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
190
-        $result = $client->getResponse()->getContent();
191
-        $this->assertSame(['data' => $this->expectedData], json_decode($result, true), $result);
192
-    }
193
-
194
-    /**
195
-     * @dataProvider graphQLBatchEndpointUriProvider
196
-     */
197
-    public function testBatchEndpointAction(string $uri): void
198
-    {
199
-        $client = static::createClient(['test_case' => 'connection']);
200
-        $this->disableCatchExceptions($client);
201
-
202
-        $data = [
203
-            [
204
-                'id' => 'friends',
205
-                'query' => $this->friendsQuery,
206
-            ],
207
-            [
208
-                'id' => 'friendsTotalCount',
209
-                'query' => $this->friendsTotalCountQuery,
210
-            ],
211
-        ];
212
-
213
-        $content = json_encode($data) ?: null;
214
-        $client->request('POST', $uri, [], [], ['CONTENT_TYPE' => 'application/json'], $content);
215
-        $result = $client->getResponse()->getContent();
216
-
217
-        $expected = [
218
-            ['id' => 'friends', 'payload' => ['data' => $this->expectedData]],
219
-            ['id' => 'friendsTotalCount', 'payload' => ['data' => ['user' => ['friends' => ['totalCount' => 4]]]]],
220
-        ];
221
-        $this->assertSame($expected, json_decode($result, true), $result);
222
-    }
223
-
224
-    public function graphQLBatchEndpointUriProvider(): array
225
-    {
226
-        return [
227
-            ['/batch'],
228
-            ['/graphql/default/batch'],
229
-        ];
230
-    }
231
-
232
-    public function testBatchEndpointWithEmptyQuery(): void
233
-    {
234
-        $this->expectException(BadRequestHttpException::class);
235
-        $this->expectExceptionMessage('Must provide at least one valid query.');
236
-        $client = static::createClient();
237
-        $this->disableCatchExceptions($client);
238
-        $client->request('GET', '/batch', [], [], ['CONTENT_TYPE' => 'application/json'], '{}');
239
-        $client->getResponse()->getContent();
240
-    }
241
-
242
-    public function testBatchEndpointWrongContentType(): void
243
-    {
244
-        $this->expectException(BadRequestHttpException::class);
245
-        $this->expectExceptionMessage('Batching parser only accepts "application/json" or "multipart/form-data" content-type but got "".');
246
-        $client = static::createClient();
247
-        $this->disableCatchExceptions($client);
248
-        $client->request('GET', '/batch');
249
-        $client->getResponse()->getContent();
250
-    }
251
-
252
-    public function testBatchEndpointWithInvalidJson(): void
253
-    {
254
-        $this->expectException(BadRequestHttpException::class);
255
-        $this->expectExceptionMessage('POST body sent invalid JSON');
256
-        $client = static::createClient();
257
-        $this->disableCatchExceptions($client);
258
-        $client->request('GET', '/batch', [], [], ['CONTENT_TYPE' => 'application/json'], '{');
259
-        $client->getResponse()->getContent();
260
-    }
261
-
262
-    public function testBatchEndpointWithInvalidQuery(): void
263
-    {
264
-        $this->expectException(BadRequestHttpException::class);
265
-        $this->expectExceptionMessage('1 is not a valid query');
266
-        $client = static::createClient();
267
-        $this->disableCatchExceptions($client);
268
-        $client->request('GET', '/batch', [], [], ['CONTENT_TYPE' => 'application/json'], '{"test" : {"query": 1}}');
269
-        $client->getResponse()->getContent();
270
-    }
271
-
272
-    public function testPreflightedRequestWhenDisabled(): void
273
-    {
274
-        $client = static::createClient(['test_case' => 'connection']);
275
-        $this->disableCatchExceptions($client);
276
-        $client->request('OPTIONS', '/', [], [], ['HTTP_Origin' => 'http://example.com']);
277
-        $response = $client->getResponse();
278
-        $this->assertSame(200, $response->getStatusCode());
279
-        $this->assertCORSHeadersNotExists($client);
280
-    }
281
-
282
-    public function testUnAuthorizedMethod(): void
283
-    {
284
-        $client = static::createClient(['test_case' => 'connection']);
285
-        $this->disableCatchExceptions($client);
286
-        $client->request('PUT', '/', [], [], ['HTTP_Origin' => 'http://example.com']);
287
-        $this->assertSame(405, $client->getResponse()->getStatusCode());
288
-    }
289
-
290
-    public function testPreflightedRequestWhenEnabled(): void
291
-    {
292
-        $client = static::createClient(['test_case' => 'connectionWithCORS']);
293
-        $this->disableCatchExceptions($client);
294
-        $client->request('OPTIONS', '/batch', [], [], ['HTTP_Origin' => 'http://example.com']);
295
-        $this->assertCORSHeadersExists($client);
296
-    }
297
-
298
-    public function testNoCORSHeadersIfOriginHeaderNotExists(): void
299
-    {
300
-        $client = static::createClient(['test_case' => 'connectionWithCORS']);
301
-        $this->disableCatchExceptions($client);
302
-        $client->request('GET', '/', ['query' => $this->friendsQuery], [], ['CONTENT_TYPE' => 'application/graphql']);
303
-        $result = $client->getResponse()->getContent();
304
-        $this->assertSame(['data' => $this->expectedData], json_decode($result, true), $result);
305
-        $this->assertCORSHeadersNotExists($client);
306
-    }
307
-
308
-    /**
309
-     * @param KernelBrowser $client
310
-     */
311
-    private function assertCORSHeadersNotExists($client): void
312
-    {
313
-        $headers = $client->getResponse()->headers->all();
314
-        $this->assertArrayNotHasKey('access-control-allow-origin', $headers);
315
-        $this->assertArrayNotHasKey('access-control-allow-methods', $headers);
316
-        $this->assertArrayNotHasKey('access-control-allow-credentials', $headers);
317
-        $this->assertArrayNotHasKey('access-control-allow-headers', $headers);
318
-        $this->assertArrayNotHasKey('access-control-max-age', $headers);
319
-    }
320
-
321
-    /**
322
-     * @param KernelBrowser $client
323
-     */
324
-    private function assertCORSHeadersExists($client): void
325
-    {
326
-        $response = $client->getResponse();
327
-        $this->assertSame(200, $response->getStatusCode());
328
-        $this->assertSame('http://example.com', $response->headers->get('Access-Control-Allow-Origin'));
329
-        $this->assertSame('OPTIONS, GET, POST', $response->headers->get('Access-Control-Allow-Methods'));
330
-        $this->assertSame('true', $response->headers->get('Access-Control-Allow-Credentials'));
331
-        $this->assertSame('Content-Type, Authorization', $response->headers->get('Access-Control-Allow-Headers'));
332
-        $this->assertSame('3600', $response->headers->get('Access-Control-Max-Age'));
333
-    }
334
-}
Please login to merge, or discard this patch.
Braces   -318 removed lines patch added patch discarded remove patch
@@ -14,321 +14,3 @@
 block discarded – undo
14 14
 class GraphControllerTest extends TestCase
15 15
 {
16 16
     private string $friendsQuery = <<<'EOF'
17
-        query FriendsQuery {
18
-          user {
19
-            friends(first: 2) {
20
-              totalCount
21
-              edges {
22
-                friendshipTime
23
-                node {
24
-                  name
25
-                }
26
-              }
27
-            }
28
-          }
29
-        }
30
-        EOF;
31
-
32
-    private string $friendsTotalCountQuery = <<<'EOF'
33
-        query FriendsTotalCountQuery {
34
-          user {
35
-            friends {
36
-              totalCount
37
-            }
38
-          }
39
-        }
40
-        EOF;
41
-
42
-    private array $expectedData = [
43
-        'user' => [
44
-            'friends' => [
45
-                'totalCount' => 4,
46
-                'edges' => [
47
-                    [
48
-                        'friendshipTime' => 'Yesterday',
49
-                        'node' => [
50
-                            'name' => 'Nick',
51
-                        ],
52
-                    ],
53
-                    [
54
-                        'friendshipTime' => 'Yesterday',
55
-                        'node' => [
56
-                            'name' => 'Lee',
57
-                        ],
58
-                    ],
59
-                ],
60
-            ],
61
-        ],
62
-    ];
63
-
64
-    /**
65
-     * @dataProvider graphQLEndpointUriProvider
66
-     */
67
-    public function testEndpointAction(string $uri): void
68
-    {
69
-        $client = static::createClient(['test_case' => 'connectionWithCORS']);
70
-        $this->disableCatchExceptions($client);
71
-
72
-        $client->request('GET', $uri, ['query' => $this->friendsQuery], [], ['CONTENT_TYPE' => 'application/graphql;charset=utf8', 'HTTP_Origin' => 'http://example.com']);
73
-        $result = $client->getResponse()->getContent();
74
-        $this->assertSame(['data' => $this->expectedData], json_decode($result, true), $result);
75
-        $this->assertCORSHeadersExists($client);
76
-    }
77
-
78
-    public function graphQLEndpointUriProvider(): array
79
-    {
80
-        return [
81
-            ['/'],
82
-            ['/graphql/default'],
83
-        ];
84
-    }
85
-
86
-    public function testEndpointWithEmptyQuery(): void
87
-    {
88
-        $this->expectException(BadRequestHttpException::class);
89
-        $this->expectExceptionMessage('Must provide query parameter');
90
-        $client = static::createClient();
91
-        $this->disableCatchExceptions($client);
92
-        $client->request('GET', '/', []);
93
-        $client->getResponse()->getContent();
94
-    }
95
-
96
-    public function testEndpointWithEmptyPostJsonBodyQuery(): void
97
-    {
98
-        $this->expectException(BadRequestHttpException::class);
99
-        $this->expectExceptionMessage('The request content body must not be empty when using json content type request.');
100
-        $client = static::createClient();
101
-        $this->disableCatchExceptions($client);
102
-        $client->request('POST', '/', [], [], ['CONTENT_TYPE' => 'application/json']);
103
-    }
104
-
105
-    public function testEndpointWithJsonContentTypeAndGetQuery(): void
106
-    {
107
-        $client = static::createClient(['test_case' => 'connectionWithCORS']);
108
-        $this->disableCatchExceptions($client);
109
-        $client->request('GET', '/', ['query' => $this->friendsQuery], [], ['CONTENT_TYPE' => 'application/json']);
110
-        $result = $client->getResponse()->getContent();
111
-        $this->assertSame(['data' => $this->expectedData], json_decode($result, true), $result);
112
-    }
113
-
114
-    public function testEndpointWithInvalidBodyQuery(): void
115
-    {
116
-        $this->expectException(BadRequestHttpException::class);
117
-        $this->expectExceptionMessage('POST body sent invalid JSON');
118
-        $client = static::createClient();
119
-        $this->disableCatchExceptions($client);
120
-        $client->request('GET', '/', [], [], ['CONTENT_TYPE' => 'application/json'], '{');
121
-        $client->getResponse()->getContent();
122
-    }
123
-
124
-    public function testEndpointActionWithVariables(): void
125
-    {
126
-        $client = static::createClient(['test_case' => 'connection']);
127
-        $this->disableCatchExceptions($client);
128
-
129
-        $query = <<<'EOF'
130
-            query FriendsQuery($firstFriends: Int) {
131
-              user {
132
-                friends(first: $firstFriends) {
133
-                  totalCount
134
-                  edges {
135
-                    friendshipTime
136
-                    node {
137
-                      name
138
-                    }
139
-                  }
140
-                }
141
-              }
142
-            }
143
-            EOF;
144
-
145
-        $content = json_encode(['query' => $query, 'variables' => '{"firstFriends": 2}']) ?: null;
146
-        $client->request('GET', '/', [], [], ['CONTENT_TYPE' => 'application/json'], $content);
147
-        $this->assertSame(200, $client->getResponse()->getStatusCode());
148
-    }
149
-
150
-    public function testEndpointActionWithInvalidVariables(): void
151
-    {
152
-        $this->expectException(BadRequestHttpException::class);
153
-        $this->expectExceptionMessage('Variables are invalid JSON');
154
-        $client = static::createClient(['test_case' => 'connection']);
155
-        $this->disableCatchExceptions($client);
156
-
157
-        $query = <<<'EOF'
158
-            query {
159
-              user
160
-            }
161
-            EOF;
162
-
163
-        $client->request('GET', '/', ['query' => $query, 'variables' => '"firstFriends": 2}']);
164
-    }
165
-
166
-    public function testMultipleEndpointActionWithUnknownSchemaName(): void
167
-    {
168
-        $this->expectException(NotFoundHttpException::class);
169
-        $this->expectExceptionMessage('Could not found "fake" schema.');
170
-        $client = static::createClient(['test_case' => 'connection']);
171
-        $this->disableCatchExceptions($client);
172
-
173
-        $query = <<<'EOF'
174
-            query {
175
-              user
176
-            }
177
-            EOF;
178
-
179
-        $client->request('GET', '/graphql/fake', ['query' => $query]);
180
-    }
181
-
182
-    public function testEndpointActionWithOperationName(): void
183
-    {
184
-        $client = static::createClient(['test_case' => 'connection']);
185
-        $this->disableCatchExceptions($client);
186
-
187
-        $query = $this->friendsQuery."\n".$this->friendsTotalCountQuery;
188
-
189
-        $client->request('POST', '/', ['query' => $query, 'operationName' => 'FriendsQuery'], [], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
190
-        $result = $client->getResponse()->getContent();
191
-        $this->assertSame(['data' => $this->expectedData], json_decode($result, true), $result);
192
-    }
193
-
194
-    /**
195
-     * @dataProvider graphQLBatchEndpointUriProvider
196
-     */
197
-    public function testBatchEndpointAction(string $uri): void
198
-    {
199
-        $client = static::createClient(['test_case' => 'connection']);
200
-        $this->disableCatchExceptions($client);
201
-
202
-        $data = [
203
-            [
204
-                'id' => 'friends',
205
-                'query' => $this->friendsQuery,
206
-            ],
207
-            [
208
-                'id' => 'friendsTotalCount',
209
-                'query' => $this->friendsTotalCountQuery,
210
-            ],
211
-        ];
212
-
213
-        $content = json_encode($data) ?: null;
214
-        $client->request('POST', $uri, [], [], ['CONTENT_TYPE' => 'application/json'], $content);
215
-        $result = $client->getResponse()->getContent();
216
-
217
-        $expected = [
218
-            ['id' => 'friends', 'payload' => ['data' => $this->expectedData]],
219
-            ['id' => 'friendsTotalCount', 'payload' => ['data' => ['user' => ['friends' => ['totalCount' => 4]]]]],
220
-        ];
221
-        $this->assertSame($expected, json_decode($result, true), $result);
222
-    }
223
-
224
-    public function graphQLBatchEndpointUriProvider(): array
225
-    {
226
-        return [
227
-            ['/batch'],
228
-            ['/graphql/default/batch'],
229
-        ];
230
-    }
231
-
232
-    public function testBatchEndpointWithEmptyQuery(): void
233
-    {
234
-        $this->expectException(BadRequestHttpException::class);
235
-        $this->expectExceptionMessage('Must provide at least one valid query.');
236
-        $client = static::createClient();
237
-        $this->disableCatchExceptions($client);
238
-        $client->request('GET', '/batch', [], [], ['CONTENT_TYPE' => 'application/json'], '{}');
239
-        $client->getResponse()->getContent();
240
-    }
241
-
242
-    public function testBatchEndpointWrongContentType(): void
243
-    {
244
-        $this->expectException(BadRequestHttpException::class);
245
-        $this->expectExceptionMessage('Batching parser only accepts "application/json" or "multipart/form-data" content-type but got "".');
246
-        $client = static::createClient();
247
-        $this->disableCatchExceptions($client);
248
-        $client->request('GET', '/batch');
249
-        $client->getResponse()->getContent();
250
-    }
251
-
252
-    public function testBatchEndpointWithInvalidJson(): void
253
-    {
254
-        $this->expectException(BadRequestHttpException::class);
255
-        $this->expectExceptionMessage('POST body sent invalid JSON');
256
-        $client = static::createClient();
257
-        $this->disableCatchExceptions($client);
258
-        $client->request('GET', '/batch', [], [], ['CONTENT_TYPE' => 'application/json'], '{');
259
-        $client->getResponse()->getContent();
260
-    }
261
-
262
-    public function testBatchEndpointWithInvalidQuery(): void
263
-    {
264
-        $this->expectException(BadRequestHttpException::class);
265
-        $this->expectExceptionMessage('1 is not a valid query');
266
-        $client = static::createClient();
267
-        $this->disableCatchExceptions($client);
268
-        $client->request('GET', '/batch', [], [], ['CONTENT_TYPE' => 'application/json'], '{"test" : {"query": 1}}');
269
-        $client->getResponse()->getContent();
270
-    }
271
-
272
-    public function testPreflightedRequestWhenDisabled(): void
273
-    {
274
-        $client = static::createClient(['test_case' => 'connection']);
275
-        $this->disableCatchExceptions($client);
276
-        $client->request('OPTIONS', '/', [], [], ['HTTP_Origin' => 'http://example.com']);
277
-        $response = $client->getResponse();
278
-        $this->assertSame(200, $response->getStatusCode());
279
-        $this->assertCORSHeadersNotExists($client);
280
-    }
281
-
282
-    public function testUnAuthorizedMethod(): void
283
-    {
284
-        $client = static::createClient(['test_case' => 'connection']);
285
-        $this->disableCatchExceptions($client);
286
-        $client->request('PUT', '/', [], [], ['HTTP_Origin' => 'http://example.com']);
287
-        $this->assertSame(405, $client->getResponse()->getStatusCode());
288
-    }
289
-
290
-    public function testPreflightedRequestWhenEnabled(): void
291
-    {
292
-        $client = static::createClient(['test_case' => 'connectionWithCORS']);
293
-        $this->disableCatchExceptions($client);
294
-        $client->request('OPTIONS', '/batch', [], [], ['HTTP_Origin' => 'http://example.com']);
295
-        $this->assertCORSHeadersExists($client);
296
-    }
297
-
298
-    public function testNoCORSHeadersIfOriginHeaderNotExists(): void
299
-    {
300
-        $client = static::createClient(['test_case' => 'connectionWithCORS']);
301
-        $this->disableCatchExceptions($client);
302
-        $client->request('GET', '/', ['query' => $this->friendsQuery], [], ['CONTENT_TYPE' => 'application/graphql']);
303
-        $result = $client->getResponse()->getContent();
304
-        $this->assertSame(['data' => $this->expectedData], json_decode($result, true), $result);
305
-        $this->assertCORSHeadersNotExists($client);
306
-    }
307
-
308
-    /**
309
-     * @param KernelBrowser $client
310
-     */
311
-    private function assertCORSHeadersNotExists($client): void
312
-    {
313
-        $headers = $client->getResponse()->headers->all();
314
-        $this->assertArrayNotHasKey('access-control-allow-origin', $headers);
315
-        $this->assertArrayNotHasKey('access-control-allow-methods', $headers);
316
-        $this->assertArrayNotHasKey('access-control-allow-credentials', $headers);
317
-        $this->assertArrayNotHasKey('access-control-allow-headers', $headers);
318
-        $this->assertArrayNotHasKey('access-control-max-age', $headers);
319
-    }
320
-
321
-    /**
322
-     * @param KernelBrowser $client
323
-     */
324
-    private function assertCORSHeadersExists($client): void
325
-    {
326
-        $response = $client->getResponse();
327
-        $this->assertSame(200, $response->getStatusCode());
328
-        $this->assertSame('http://example.com', $response->headers->get('Access-Control-Allow-Origin'));
329
-        $this->assertSame('OPTIONS, GET, POST', $response->headers->get('Access-Control-Allow-Methods'));
330
-        $this->assertSame('true', $response->headers->get('Access-Control-Allow-Credentials'));
331
-        $this->assertSame('Content-Type, Authorization', $response->headers->get('Access-Control-Allow-Headers'));
332
-        $this->assertSame('3600', $response->headers->get('Access-Control-Max-Age'));
333
-    }
334
-}
Please login to merge, or discard this patch.
Upper-Lower-Casing   -318 removed lines patch added patch discarded remove patch
@@ -14,321 +14,3 @@
 block discarded – undo
14 14
 class GraphControllerTest extends TestCase
15 15
 {
16 16
     private string $friendsQuery = <<<'EOF'
17
-        query FriendsQuery {
18
-          user {
19
-            friends(first: 2) {
20
-              totalCount
21
-              edges {
22
-                friendshipTime
23
-                node {
24
-                  name
25
-                }
26
-              }
27
-            }
28
-          }
29
-        }
30
-        EOF;
31
-
32
-    private string $friendsTotalCountQuery = <<<'EOF'
33
-        query FriendsTotalCountQuery {
34
-          user {
35
-            friends {
36
-              totalCount
37
-            }
38
-          }
39
-        }
40
-        EOF;
41
-
42
-    private array $expectedData = [
43
-        'user' => [
44
-            'friends' => [
45
-                'totalCount' => 4,
46
-                'edges' => [
47
-                    [
48
-                        'friendshipTime' => 'Yesterday',
49
-                        'node' => [
50
-                            'name' => 'Nick',
51
-                        ],
52
-                    ],
53
-                    [
54
-                        'friendshipTime' => 'Yesterday',
55
-                        'node' => [
56
-                            'name' => 'Lee',
57
-                        ],
58
-                    ],
59
-                ],
60
-            ],
61
-        ],
62
-    ];
63
-
64
-    /**
65
-     * @dataProvider graphQLEndpointUriProvider
66
-     */
67
-    public function testEndpointAction(string $uri): void
68
-    {
69
-        $client = static::createClient(['test_case' => 'connectionWithCORS']);
70
-        $this->disableCatchExceptions($client);
71
-
72
-        $client->request('GET', $uri, ['query' => $this->friendsQuery], [], ['CONTENT_TYPE' => 'application/graphql;charset=utf8', 'HTTP_Origin' => 'http://example.com']);
73
-        $result = $client->getResponse()->getContent();
74
-        $this->assertSame(['data' => $this->expectedData], json_decode($result, true), $result);
75
-        $this->assertCORSHeadersExists($client);
76
-    }
77
-
78
-    public function graphQLEndpointUriProvider(): array
79
-    {
80
-        return [
81
-            ['/'],
82
-            ['/graphql/default'],
83
-        ];
84
-    }
85
-
86
-    public function testEndpointWithEmptyQuery(): void
87
-    {
88
-        $this->expectException(BadRequestHttpException::class);
89
-        $this->expectExceptionMessage('Must provide query parameter');
90
-        $client = static::createClient();
91
-        $this->disableCatchExceptions($client);
92
-        $client->request('GET', '/', []);
93
-        $client->getResponse()->getContent();
94
-    }
95
-
96
-    public function testEndpointWithEmptyPostJsonBodyQuery(): void
97
-    {
98
-        $this->expectException(BadRequestHttpException::class);
99
-        $this->expectExceptionMessage('The request content body must not be empty when using json content type request.');
100
-        $client = static::createClient();
101
-        $this->disableCatchExceptions($client);
102
-        $client->request('POST', '/', [], [], ['CONTENT_TYPE' => 'application/json']);
103
-    }
104
-
105
-    public function testEndpointWithJsonContentTypeAndGetQuery(): void
106
-    {
107
-        $client = static::createClient(['test_case' => 'connectionWithCORS']);
108
-        $this->disableCatchExceptions($client);
109
-        $client->request('GET', '/', ['query' => $this->friendsQuery], [], ['CONTENT_TYPE' => 'application/json']);
110
-        $result = $client->getResponse()->getContent();
111
-        $this->assertSame(['data' => $this->expectedData], json_decode($result, true), $result);
112
-    }
113
-
114
-    public function testEndpointWithInvalidBodyQuery(): void
115
-    {
116
-        $this->expectException(BadRequestHttpException::class);
117
-        $this->expectExceptionMessage('POST body sent invalid JSON');
118
-        $client = static::createClient();
119
-        $this->disableCatchExceptions($client);
120
-        $client->request('GET', '/', [], [], ['CONTENT_TYPE' => 'application/json'], '{');
121
-        $client->getResponse()->getContent();
122
-    }
123
-
124
-    public function testEndpointActionWithVariables(): void
125
-    {
126
-        $client = static::createClient(['test_case' => 'connection']);
127
-        $this->disableCatchExceptions($client);
128
-
129
-        $query = <<<'EOF'
130
-            query FriendsQuery($firstFriends: Int) {
131
-              user {
132
-                friends(first: $firstFriends) {
133
-                  totalCount
134
-                  edges {
135
-                    friendshipTime
136
-                    node {
137
-                      name
138
-                    }
139
-                  }
140
-                }
141
-              }
142
-            }
143
-            EOF;
144
-
145
-        $content = json_encode(['query' => $query, 'variables' => '{"firstFriends": 2}']) ?: null;
146
-        $client->request('GET', '/', [], [], ['CONTENT_TYPE' => 'application/json'], $content);
147
-        $this->assertSame(200, $client->getResponse()->getStatusCode());
148
-    }
149
-
150
-    public function testEndpointActionWithInvalidVariables(): void
151
-    {
152
-        $this->expectException(BadRequestHttpException::class);
153
-        $this->expectExceptionMessage('Variables are invalid JSON');
154
-        $client = static::createClient(['test_case' => 'connection']);
155
-        $this->disableCatchExceptions($client);
156
-
157
-        $query = <<<'EOF'
158
-            query {
159
-              user
160
-            }
161
-            EOF;
162
-
163
-        $client->request('GET', '/', ['query' => $query, 'variables' => '"firstFriends": 2}']);
164
-    }
165
-
166
-    public function testMultipleEndpointActionWithUnknownSchemaName(): void
167
-    {
168
-        $this->expectException(NotFoundHttpException::class);
169
-        $this->expectExceptionMessage('Could not found "fake" schema.');
170
-        $client = static::createClient(['test_case' => 'connection']);
171
-        $this->disableCatchExceptions($client);
172
-
173
-        $query = <<<'EOF'
174
-            query {
175
-              user
176
-            }
177
-            EOF;
178
-
179
-        $client->request('GET', '/graphql/fake', ['query' => $query]);
180
-    }
181
-
182
-    public function testEndpointActionWithOperationName(): void
183
-    {
184
-        $client = static::createClient(['test_case' => 'connection']);
185
-        $this->disableCatchExceptions($client);
186
-
187
-        $query = $this->friendsQuery."\n".$this->friendsTotalCountQuery;
188
-
189
-        $client->request('POST', '/', ['query' => $query, 'operationName' => 'FriendsQuery'], [], ['CONTENT_TYPE' => 'application/x-www-form-urlencoded']);
190
-        $result = $client->getResponse()->getContent();
191
-        $this->assertSame(['data' => $this->expectedData], json_decode($result, true), $result);
192
-    }
193
-
194
-    /**
195
-     * @dataProvider graphQLBatchEndpointUriProvider
196
-     */
197
-    public function testBatchEndpointAction(string $uri): void
198
-    {
199
-        $client = static::createClient(['test_case' => 'connection']);
200
-        $this->disableCatchExceptions($client);
201
-
202
-        $data = [
203
-            [
204
-                'id' => 'friends',
205
-                'query' => $this->friendsQuery,
206
-            ],
207
-            [
208
-                'id' => 'friendsTotalCount',
209
-                'query' => $this->friendsTotalCountQuery,
210
-            ],
211
-        ];
212
-
213
-        $content = json_encode($data) ?: null;
214
-        $client->request('POST', $uri, [], [], ['CONTENT_TYPE' => 'application/json'], $content);
215
-        $result = $client->getResponse()->getContent();
216
-
217
-        $expected = [
218
-            ['id' => 'friends', 'payload' => ['data' => $this->expectedData]],
219
-            ['id' => 'friendsTotalCount', 'payload' => ['data' => ['user' => ['friends' => ['totalCount' => 4]]]]],
220
-        ];
221
-        $this->assertSame($expected, json_decode($result, true), $result);
222
-    }
223
-
224
-    public function graphQLBatchEndpointUriProvider(): array
225
-    {
226
-        return [
227
-            ['/batch'],
228
-            ['/graphql/default/batch'],
229
-        ];
230
-    }
231
-
232
-    public function testBatchEndpointWithEmptyQuery(): void
233
-    {
234
-        $this->expectException(BadRequestHttpException::class);
235
-        $this->expectExceptionMessage('Must provide at least one valid query.');
236
-        $client = static::createClient();
237
-        $this->disableCatchExceptions($client);
238
-        $client->request('GET', '/batch', [], [], ['CONTENT_TYPE' => 'application/json'], '{}');
239
-        $client->getResponse()->getContent();
240
-    }
241
-
242
-    public function testBatchEndpointWrongContentType(): void
243
-    {
244
-        $this->expectException(BadRequestHttpException::class);
245
-        $this->expectExceptionMessage('Batching parser only accepts "application/json" or "multipart/form-data" content-type but got "".');
246
-        $client = static::createClient();
247
-        $this->disableCatchExceptions($client);
248
-        $client->request('GET', '/batch');
249
-        $client->getResponse()->getContent();
250
-    }
251
-
252
-    public function testBatchEndpointWithInvalidJson(): void
253
-    {
254
-        $this->expectException(BadRequestHttpException::class);
255
-        $this->expectExceptionMessage('POST body sent invalid JSON');
256
-        $client = static::createClient();
257
-        $this->disableCatchExceptions($client);
258
-        $client->request('GET', '/batch', [], [], ['CONTENT_TYPE' => 'application/json'], '{');
259
-        $client->getResponse()->getContent();
260
-    }
261
-
262
-    public function testBatchEndpointWithInvalidQuery(): void
263
-    {
264
-        $this->expectException(BadRequestHttpException::class);
265
-        $this->expectExceptionMessage('1 is not a valid query');
266
-        $client = static::createClient();
267
-        $this->disableCatchExceptions($client);
268
-        $client->request('GET', '/batch', [], [], ['CONTENT_TYPE' => 'application/json'], '{"test" : {"query": 1}}');
269
-        $client->getResponse()->getContent();
270
-    }
271
-
272
-    public function testPreflightedRequestWhenDisabled(): void
273
-    {
274
-        $client = static::createClient(['test_case' => 'connection']);
275
-        $this->disableCatchExceptions($client);
276
-        $client->request('OPTIONS', '/', [], [], ['HTTP_Origin' => 'http://example.com']);
277
-        $response = $client->getResponse();
278
-        $this->assertSame(200, $response->getStatusCode());
279
-        $this->assertCORSHeadersNotExists($client);
280
-    }
281
-
282
-    public function testUnAuthorizedMethod(): void
283
-    {
284
-        $client = static::createClient(['test_case' => 'connection']);
285
-        $this->disableCatchExceptions($client);
286
-        $client->request('PUT', '/', [], [], ['HTTP_Origin' => 'http://example.com']);
287
-        $this->assertSame(405, $client->getResponse()->getStatusCode());
288
-    }
289
-
290
-    public function testPreflightedRequestWhenEnabled(): void
291
-    {
292
-        $client = static::createClient(['test_case' => 'connectionWithCORS']);
293
-        $this->disableCatchExceptions($client);
294
-        $client->request('OPTIONS', '/batch', [], [], ['HTTP_Origin' => 'http://example.com']);
295
-        $this->assertCORSHeadersExists($client);
296
-    }
297
-
298
-    public function testNoCORSHeadersIfOriginHeaderNotExists(): void
299
-    {
300
-        $client = static::createClient(['test_case' => 'connectionWithCORS']);
301
-        $this->disableCatchExceptions($client);
302
-        $client->request('GET', '/', ['query' => $this->friendsQuery], [], ['CONTENT_TYPE' => 'application/graphql']);
303
-        $result = $client->getResponse()->getContent();
304
-        $this->assertSame(['data' => $this->expectedData], json_decode($result, true), $result);
305
-        $this->assertCORSHeadersNotExists($client);
306
-    }
307
-
308
-    /**
309
-     * @param KernelBrowser $client
310
-     */
311
-    private function assertCORSHeadersNotExists($client): void
312
-    {
313
-        $headers = $client->getResponse()->headers->all();
314
-        $this->assertArrayNotHasKey('access-control-allow-origin', $headers);
315
-        $this->assertArrayNotHasKey('access-control-allow-methods', $headers);
316
-        $this->assertArrayNotHasKey('access-control-allow-credentials', $headers);
317
-        $this->assertArrayNotHasKey('access-control-allow-headers', $headers);
318
-        $this->assertArrayNotHasKey('access-control-max-age', $headers);
319
-    }
320
-
321
-    /**
322
-     * @param KernelBrowser $client
323
-     */
324
-    private function assertCORSHeadersExists($client): void
325
-    {
326
-        $response = $client->getResponse();
327
-        $this->assertSame(200, $response->getStatusCode());
328
-        $this->assertSame('http://example.com', $response->headers->get('Access-Control-Allow-Origin'));
329
-        $this->assertSame('OPTIONS, GET, POST', $response->headers->get('Access-Control-Allow-Methods'));
330
-        $this->assertSame('true', $response->headers->get('Access-Control-Allow-Credentials'));
331
-        $this->assertSame('Content-Type, Authorization', $response->headers->get('Access-Control-Allow-Headers'));
332
-        $this->assertSame('3600', $response->headers->get('Access-Control-Max-Age'));
333
-    }
334
-}
Please login to merge, or discard this patch.
tests/Functional/MultipleQueries/MultipleQueriesTest.php 5 patches
Indentation   -47 removed lines patch added patch discarded remove patch
@@ -56,50 +56,3 @@
 block discarded – undo
56 56
     public function testRequiredFails(): void
57 57
     {
58 58
         $query = <<<'EOF'
59
-            {
60
-              fail: failRequire
61
-              success: success
62
-            }
63
-            EOF;
64
-        $result = $this->executeGraphQLRequest($query);
65
-        $this->assertSame(self::REQUIRED_FAILS_ERRORS, $result['errors']);
66
-        $this->assertTrue(empty($result['data']));
67
-    }
68
-
69
-    public function testOptionalFails(): void
70
-    {
71
-        $query = <<<'EOF'
72
-            {
73
-              fail: failOptional
74
-              success: success
75
-            }
76
-            EOF;
77
-        $result = $this->executeGraphQLRequest($query);
78
-        $this->assertSame(self::OPTIONAL_FAILS, $result);
79
-    }
80
-
81
-    public function testMutationRequiredFails(): void
82
-    {
83
-        $query = <<<'EOF'
84
-            mutation {
85
-              fail: failRequire
86
-              success: success
87
-            }
88
-            EOF;
89
-        $result = $this->executeGraphQLRequest($query);
90
-        $this->assertSame(self::REQUIRED_FAILS_ERRORS, $result['errors']);
91
-        $this->assertTrue(empty($result['data']));
92
-    }
93
-
94
-    public function testMutationOptionalFails(): void
95
-    {
96
-        $query = <<<'EOF'
97
-            mutation {
98
-              fail: failOptional
99
-              success: success
100
-            }
101
-            EOF;
102
-        $result = $this->executeGraphQLRequest($query);
103
-        $this->assertSame(self::OPTIONAL_FAILS, $result);
104
-    }
105
-}
Please login to merge, or discard this patch.
Switch Indentation   -47 removed lines patch added patch discarded remove patch
@@ -56,50 +56,3 @@
 block discarded – undo
56 56
     public function testRequiredFails(): void
57 57
     {
58 58
         $query = <<<'EOF'
59
-            {
60
-              fail: failRequire
61
-              success: success
62
-            }
63
-            EOF;
64
-        $result = $this->executeGraphQLRequest($query);
65
-        $this->assertSame(self::REQUIRED_FAILS_ERRORS, $result['errors']);
66
-        $this->assertTrue(empty($result['data']));
67
-    }
68
-
69
-    public function testOptionalFails(): void
70
-    {
71
-        $query = <<<'EOF'
72
-            {
73
-              fail: failOptional
74
-              success: success
75
-            }
76
-            EOF;
77
-        $result = $this->executeGraphQLRequest($query);
78
-        $this->assertSame(self::OPTIONAL_FAILS, $result);
79
-    }
80
-
81
-    public function testMutationRequiredFails(): void
82
-    {
83
-        $query = <<<'EOF'
84
-            mutation {
85
-              fail: failRequire
86
-              success: success
87
-            }
88
-            EOF;
89
-        $result = $this->executeGraphQLRequest($query);
90
-        $this->assertSame(self::REQUIRED_FAILS_ERRORS, $result['errors']);
91
-        $this->assertTrue(empty($result['data']));
92
-    }
93
-
94
-    public function testMutationOptionalFails(): void
95
-    {
96
-        $query = <<<'EOF'
97
-            mutation {
98
-              fail: failOptional
99
-              success: success
100
-            }
101
-            EOF;
102
-        $result = $this->executeGraphQLRequest($query);
103
-        $this->assertSame(self::OPTIONAL_FAILS, $result);
104
-    }
105
-}
Please login to merge, or discard this patch.
Spacing   -47 removed lines patch added patch discarded remove patch
@@ -56,50 +56,3 @@
 block discarded – undo
56 56
     public function testRequiredFails(): void
57 57
     {
58 58
         $query = <<<'EOF'
59
-            {
60
-              fail: failRequire
61
-              success: success
62
-            }
63
-            EOF;
64
-        $result = $this->executeGraphQLRequest($query);
65
-        $this->assertSame(self::REQUIRED_FAILS_ERRORS, $result['errors']);
66
-        $this->assertTrue(empty($result['data']));
67
-    }
68
-
69
-    public function testOptionalFails(): void
70
-    {
71
-        $query = <<<'EOF'
72
-            {
73
-              fail: failOptional
74
-              success: success
75
-            }
76
-            EOF;
77
-        $result = $this->executeGraphQLRequest($query);
78
-        $this->assertSame(self::OPTIONAL_FAILS, $result);
79
-    }
80
-
81
-    public function testMutationRequiredFails(): void
82
-    {
83
-        $query = <<<'EOF'
84
-            mutation {
85
-              fail: failRequire
86
-              success: success
87
-            }
88
-            EOF;
89
-        $result = $this->executeGraphQLRequest($query);
90
-        $this->assertSame(self::REQUIRED_FAILS_ERRORS, $result['errors']);
91
-        $this->assertTrue(empty($result['data']));
92
-    }
93
-
94
-    public function testMutationOptionalFails(): void
95
-    {
96
-        $query = <<<'EOF'
97
-            mutation {
98
-              fail: failOptional
99
-              success: success
100
-            }
101
-            EOF;
102
-        $result = $this->executeGraphQLRequest($query);
103
-        $this->assertSame(self::OPTIONAL_FAILS, $result);
104
-    }
105
-}
Please login to merge, or discard this patch.
Braces   -47 removed lines patch added patch discarded remove patch
@@ -56,50 +56,3 @@
 block discarded – undo
56 56
     public function testRequiredFails(): void
57 57
     {
58 58
         $query = <<<'EOF'
59
-            {
60
-              fail: failRequire
61
-              success: success
62
-            }
63
-            EOF;
64
-        $result = $this->executeGraphQLRequest($query);
65
-        $this->assertSame(self::REQUIRED_FAILS_ERRORS, $result['errors']);
66
-        $this->assertTrue(empty($result['data']));
67
-    }
68
-
69
-    public function testOptionalFails(): void
70
-    {
71
-        $query = <<<'EOF'
72
-            {
73
-              fail: failOptional
74
-              success: success
75
-            }
76
-            EOF;
77
-        $result = $this->executeGraphQLRequest($query);
78
-        $this->assertSame(self::OPTIONAL_FAILS, $result);
79
-    }
80
-
81
-    public function testMutationRequiredFails(): void
82
-    {
83
-        $query = <<<'EOF'
84
-            mutation {
85
-              fail: failRequire
86
-              success: success
87
-            }
88
-            EOF;
89
-        $result = $this->executeGraphQLRequest($query);
90
-        $this->assertSame(self::REQUIRED_FAILS_ERRORS, $result['errors']);
91
-        $this->assertTrue(empty($result['data']));
92
-    }
93
-
94
-    public function testMutationOptionalFails(): void
95
-    {
96
-        $query = <<<'EOF'
97
-            mutation {
98
-              fail: failOptional
99
-              success: success
100
-            }
101
-            EOF;
102
-        $result = $this->executeGraphQLRequest($query);
103
-        $this->assertSame(self::OPTIONAL_FAILS, $result);
104
-    }
105
-}
Please login to merge, or discard this patch.
Upper-Lower-Casing   -47 removed lines patch added patch discarded remove patch
@@ -56,50 +56,3 @@
 block discarded – undo
56 56
     public function testRequiredFails(): void
57 57
     {
58 58
         $query = <<<'EOF'
59
-            {
60
-              fail: failRequire
61
-              success: success
62
-            }
63
-            EOF;
64
-        $result = $this->executeGraphQLRequest($query);
65
-        $this->assertSame(self::REQUIRED_FAILS_ERRORS, $result['errors']);
66
-        $this->assertTrue(empty($result['data']));
67
-    }
68
-
69
-    public function testOptionalFails(): void
70
-    {
71
-        $query = <<<'EOF'
72
-            {
73
-              fail: failOptional
74
-              success: success
75
-            }
76
-            EOF;
77
-        $result = $this->executeGraphQLRequest($query);
78
-        $this->assertSame(self::OPTIONAL_FAILS, $result);
79
-    }
80
-
81
-    public function testMutationRequiredFails(): void
82
-    {
83
-        $query = <<<'EOF'
84
-            mutation {
85
-              fail: failRequire
86
-              success: success
87
-            }
88
-            EOF;
89
-        $result = $this->executeGraphQLRequest($query);
90
-        $this->assertSame(self::REQUIRED_FAILS_ERRORS, $result['errors']);
91
-        $this->assertTrue(empty($result['data']));
92
-    }
93
-
94
-    public function testMutationOptionalFails(): void
95
-    {
96
-        $query = <<<'EOF'
97
-            mutation {
98
-              fail: failOptional
99
-              success: success
100
-            }
101
-            EOF;
102
-        $result = $this->executeGraphQLRequest($query);
103
-        $this->assertSame(self::OPTIONAL_FAILS, $result);
104
-    }
105
-}
Please login to merge, or discard this patch.
tests/Functional/MultipleSchema/MultipleSchemaTest.php 5 patches
Indentation   -64 removed lines patch added patch discarded remove patch
@@ -26,67 +26,3 @@
 block discarded – undo
26 26
         $this->assertSame([['node' => ['username' => 'user1']]], $result['data']['users']['edges']);
27 27
 
28 28
         $query = <<<'EOF'
29
-            mutation M {
30
-              addUser(input: {username: "user1"}) {
31
-                user {
32
-                  username
33
-                }
34
-              }
35
-            }
36
-            EOF;
37
-
38
-        $expectedData = [
39
-            'addUser' => [
40
-                'user' => ['username' => 'user1'],
41
-            ],
42
-        ];
43
-
44
-        $this->assertGraphQL($query, $expectedData, null, [], 'public');
45
-    }
46
-
47
-    public function testInternalSchema(): void
48
-    {
49
-        $result = $this->executeGraphQLRequest('{bar foo}', [], 'internal');
50
-        $this->assertSame('bar', $result['data']['bar']);
51
-        $this->assertSame('foo', $result['data']['foo']);
52
-        $this->assertSchemaQueryTypeName('InternalQuery');
53
-
54
-        $result = $this->executeGraphQLRequest('{users{edges{node{username email}}}}', [], 'internal');
55
-        $this->assertSame([['node' => ['username' => 'user1', 'email' => 'topsecret']]], $result['data']['users']['edges']);
56
-
57
-        $query = <<<'EOF'
58
-            mutation M {
59
-              addUser(input: {username: "user1"}) {
60
-                user {
61
-                  username
62
-                  email
63
-                }
64
-              }
65
-            }
66
-            EOF;
67
-
68
-        $expectedData = [
69
-            'addUser' => [
70
-                'user' => ['username' => 'user1', 'email' => 'email1'],
71
-            ],
72
-        ];
73
-
74
-        $this->assertGraphQL($query, $expectedData, null, [], 'internal');
75
-    }
76
-
77
-    public function testUnknownTypeShouldNotInfinityLoop(): void
78
-    {
79
-        // @phpstan-ignore-next-line
80
-        $schema = $this->getContainer()->get('overblog_graphql.request_executor')->getSchema('public');
81
-        $this->expectException(InvariantViolation::class);
82
-        $this->expectExceptionMessage('Type loader is expected to return a callable or valid type "unknown", but it returned null');
83
-        $schema->getType('unknown');
84
-    }
85
-
86
-    private function assertSchemaQueryTypeName(string $typeName): void
87
-    {
88
-        // @phpstan-ignore-next-line
89
-        $query = $this->getContainer()->get('overblog_graphql.type_resolver')->resolve($typeName);
90
-        $this->assertSame('Query', $query->name);
91
-    }
92
-}
Please login to merge, or discard this patch.
Switch Indentation   -64 removed lines patch added patch discarded remove patch
@@ -26,67 +26,3 @@
 block discarded – undo
26 26
         $this->assertSame([['node' => ['username' => 'user1']]], $result['data']['users']['edges']);
27 27
 
28 28
         $query = <<<'EOF'
29
-            mutation M {
30
-              addUser(input: {username: "user1"}) {
31
-                user {
32
-                  username
33
-                }
34
-              }
35
-            }
36
-            EOF;
37
-
38
-        $expectedData = [
39
-            'addUser' => [
40
-                'user' => ['username' => 'user1'],
41
-            ],
42
-        ];
43
-
44
-        $this->assertGraphQL($query, $expectedData, null, [], 'public');
45
-    }
46
-
47
-    public function testInternalSchema(): void
48
-    {
49
-        $result = $this->executeGraphQLRequest('{bar foo}', [], 'internal');
50
-        $this->assertSame('bar', $result['data']['bar']);
51
-        $this->assertSame('foo', $result['data']['foo']);
52
-        $this->assertSchemaQueryTypeName('InternalQuery');
53
-
54
-        $result = $this->executeGraphQLRequest('{users{edges{node{username email}}}}', [], 'internal');
55
-        $this->assertSame([['node' => ['username' => 'user1', 'email' => 'topsecret']]], $result['data']['users']['edges']);
56
-
57
-        $query = <<<'EOF'
58
-            mutation M {
59
-              addUser(input: {username: "user1"}) {
60
-                user {
61
-                  username
62
-                  email
63
-                }
64
-              }
65
-            }
66
-            EOF;
67
-
68
-        $expectedData = [
69
-            'addUser' => [
70
-                'user' => ['username' => 'user1', 'email' => 'email1'],
71
-            ],
72
-        ];
73
-
74
-        $this->assertGraphQL($query, $expectedData, null, [], 'internal');
75
-    }
76
-
77
-    public function testUnknownTypeShouldNotInfinityLoop(): void
78
-    {
79
-        // @phpstan-ignore-next-line
80
-        $schema = $this->getContainer()->get('overblog_graphql.request_executor')->getSchema('public');
81
-        $this->expectException(InvariantViolation::class);
82
-        $this->expectExceptionMessage('Type loader is expected to return a callable or valid type "unknown", but it returned null');
83
-        $schema->getType('unknown');
84
-    }
85
-
86
-    private function assertSchemaQueryTypeName(string $typeName): void
87
-    {
88
-        // @phpstan-ignore-next-line
89
-        $query = $this->getContainer()->get('overblog_graphql.type_resolver')->resolve($typeName);
90
-        $this->assertSame('Query', $query->name);
91
-    }
92
-}
Please login to merge, or discard this patch.
Spacing   -64 removed lines patch added patch discarded remove patch
@@ -26,67 +26,3 @@
 block discarded – undo
26 26
         $this->assertSame([['node' => ['username' => 'user1']]], $result['data']['users']['edges']);
27 27
 
28 28
         $query = <<<'EOF'
29
-            mutation M {
30
-              addUser(input: {username: "user1"}) {
31
-                user {
32
-                  username
33
-                }
34
-              }
35
-            }
36
-            EOF;
37
-
38
-        $expectedData = [
39
-            'addUser' => [
40
-                'user' => ['username' => 'user1'],
41
-            ],
42
-        ];
43
-
44
-        $this->assertGraphQL($query, $expectedData, null, [], 'public');
45
-    }
46
-
47
-    public function testInternalSchema(): void
48
-    {
49
-        $result = $this->executeGraphQLRequest('{bar foo}', [], 'internal');
50
-        $this->assertSame('bar', $result['data']['bar']);
51
-        $this->assertSame('foo', $result['data']['foo']);
52
-        $this->assertSchemaQueryTypeName('InternalQuery');
53
-
54
-        $result = $this->executeGraphQLRequest('{users{edges{node{username email}}}}', [], 'internal');
55
-        $this->assertSame([['node' => ['username' => 'user1', 'email' => 'topsecret']]], $result['data']['users']['edges']);
56
-
57
-        $query = <<<'EOF'
58
-            mutation M {
59
-              addUser(input: {username: "user1"}) {
60
-                user {
61
-                  username
62
-                  email
63
-                }
64
-              }
65
-            }
66
-            EOF;
67
-
68
-        $expectedData = [
69
-            'addUser' => [
70
-                'user' => ['username' => 'user1', 'email' => 'email1'],
71
-            ],
72
-        ];
73
-
74
-        $this->assertGraphQL($query, $expectedData, null, [], 'internal');
75
-    }
76
-
77
-    public function testUnknownTypeShouldNotInfinityLoop(): void
78
-    {
79
-        // @phpstan-ignore-next-line
80
-        $schema = $this->getContainer()->get('overblog_graphql.request_executor')->getSchema('public');
81
-        $this->expectException(InvariantViolation::class);
82
-        $this->expectExceptionMessage('Type loader is expected to return a callable or valid type "unknown", but it returned null');
83
-        $schema->getType('unknown');
84
-    }
85
-
86
-    private function assertSchemaQueryTypeName(string $typeName): void
87
-    {
88
-        // @phpstan-ignore-next-line
89
-        $query = $this->getContainer()->get('overblog_graphql.type_resolver')->resolve($typeName);
90
-        $this->assertSame('Query', $query->name);
91
-    }
92
-}
Please login to merge, or discard this patch.
Braces   -64 removed lines patch added patch discarded remove patch
@@ -26,67 +26,3 @@
 block discarded – undo
26 26
         $this->assertSame([['node' => ['username' => 'user1']]], $result['data']['users']['edges']);
27 27
 
28 28
         $query = <<<'EOF'
29
-            mutation M {
30
-              addUser(input: {username: "user1"}) {
31
-                user {
32
-                  username
33
-                }
34
-              }
35
-            }
36
-            EOF;
37
-
38
-        $expectedData = [
39
-            'addUser' => [
40
-                'user' => ['username' => 'user1'],
41
-            ],
42
-        ];
43
-
44
-        $this->assertGraphQL($query, $expectedData, null, [], 'public');
45
-    }
46
-
47
-    public function testInternalSchema(): void
48
-    {
49
-        $result = $this->executeGraphQLRequest('{bar foo}', [], 'internal');
50
-        $this->assertSame('bar', $result['data']['bar']);
51
-        $this->assertSame('foo', $result['data']['foo']);
52
-        $this->assertSchemaQueryTypeName('InternalQuery');
53
-
54
-        $result = $this->executeGraphQLRequest('{users{edges{node{username email}}}}', [], 'internal');
55
-        $this->assertSame([['node' => ['username' => 'user1', 'email' => 'topsecret']]], $result['data']['users']['edges']);
56
-
57
-        $query = <<<'EOF'
58
-            mutation M {
59
-              addUser(input: {username: "user1"}) {
60
-                user {
61
-                  username
62
-                  email
63
-                }
64
-              }
65
-            }
66
-            EOF;
67
-
68
-        $expectedData = [
69
-            'addUser' => [
70
-                'user' => ['username' => 'user1', 'email' => 'email1'],
71
-            ],
72
-        ];
73
-
74
-        $this->assertGraphQL($query, $expectedData, null, [], 'internal');
75
-    }
76
-
77
-    public function testUnknownTypeShouldNotInfinityLoop(): void
78
-    {
79
-        // @phpstan-ignore-next-line
80
-        $schema = $this->getContainer()->get('overblog_graphql.request_executor')->getSchema('public');
81
-        $this->expectException(InvariantViolation::class);
82
-        $this->expectExceptionMessage('Type loader is expected to return a callable or valid type "unknown", but it returned null');
83
-        $schema->getType('unknown');
84
-    }
85
-
86
-    private function assertSchemaQueryTypeName(string $typeName): void
87
-    {
88
-        // @phpstan-ignore-next-line
89
-        $query = $this->getContainer()->get('overblog_graphql.type_resolver')->resolve($typeName);
90
-        $this->assertSame('Query', $query->name);
91
-    }
92
-}
Please login to merge, or discard this patch.
Upper-Lower-Casing   -64 removed lines patch added patch discarded remove patch
@@ -26,67 +26,3 @@
 block discarded – undo
26 26
         $this->assertSame([['node' => ['username' => 'user1']]], $result['data']['users']['edges']);
27 27
 
28 28
         $query = <<<'EOF'
29
-            mutation M {
30
-              addUser(input: {username: "user1"}) {
31
-                user {
32
-                  username
33
-                }
34
-              }
35
-            }
36
-            EOF;
37
-
38
-        $expectedData = [
39
-            'addUser' => [
40
-                'user' => ['username' => 'user1'],
41
-            ],
42
-        ];
43
-
44
-        $this->assertGraphQL($query, $expectedData, null, [], 'public');
45
-    }
46
-
47
-    public function testInternalSchema(): void
48
-    {
49
-        $result = $this->executeGraphQLRequest('{bar foo}', [], 'internal');
50
-        $this->assertSame('bar', $result['data']['bar']);
51
-        $this->assertSame('foo', $result['data']['foo']);
52
-        $this->assertSchemaQueryTypeName('InternalQuery');
53
-
54
-        $result = $this->executeGraphQLRequest('{users{edges{node{username email}}}}', [], 'internal');
55
-        $this->assertSame([['node' => ['username' => 'user1', 'email' => 'topsecret']]], $result['data']['users']['edges']);
56
-
57
-        $query = <<<'EOF'
58
-            mutation M {
59
-              addUser(input: {username: "user1"}) {
60
-                user {
61
-                  username
62
-                  email
63
-                }
64
-              }
65
-            }
66
-            EOF;
67
-
68
-        $expectedData = [
69
-            'addUser' => [
70
-                'user' => ['username' => 'user1', 'email' => 'email1'],
71
-            ],
72
-        ];
73
-
74
-        $this->assertGraphQL($query, $expectedData, null, [], 'internal');
75
-    }
76
-
77
-    public function testUnknownTypeShouldNotInfinityLoop(): void
78
-    {
79
-        // @phpstan-ignore-next-line
80
-        $schema = $this->getContainer()->get('overblog_graphql.request_executor')->getSchema('public');
81
-        $this->expectException(InvariantViolation::class);
82
-        $this->expectExceptionMessage('Type loader is expected to return a callable or valid type "unknown", but it returned null');
83
-        $schema->getType('unknown');
84
-    }
85
-
86
-    private function assertSchemaQueryTypeName(string $typeName): void
87
-    {
88
-        // @phpstan-ignore-next-line
89
-        $query = $this->getContainer()->get('overblog_graphql.type_resolver')->resolve($typeName);
90
-        $this->assertSame('Query', $query->name);
91
-    }
92
-}
Please login to merge, or discard this patch.
tests/Functional/Security/DisableIntrospectionTest.php 5 patches
Indentation   -30 removed lines patch added patch discarded remove patch
@@ -9,33 +9,3 @@
 block discarded – undo
9 9
 class DisableIntrospectionTest extends TestCase
10 10
 {
11 11
     private string $introspectionQuery = <<<'EOF'
12
-        query {
13
-          __schema {
14
-            types {
15
-              name
16
-              description
17
-            }
18
-          }
19
-        }
20
-        EOF;
21
-
22
-    public function testIntrospectionDisabled(): void
23
-    {
24
-        $expected = [
25
-            'errors' => [
26
-                [
27
-                    'message' => 'GraphQL introspection is not allowed, but the query contained __schema or __type',
28
-                    'extensions' => ['category' => 'graphql'],
29
-                    'locations' => [
30
-                        [
31
-                            'line' => 2,
32
-                            'column' => 3,
33
-                        ],
34
-                    ],
35
-                ],
36
-            ],
37
-        ];
38
-
39
-        $this->assertResponse($this->introspectionQuery, $expected, self::ANONYMOUS_USER, 'disableIntrospection');
40
-    }
41
-}
Please login to merge, or discard this patch.
Switch Indentation   -30 removed lines patch added patch discarded remove patch
@@ -9,33 +9,3 @@
 block discarded – undo
9 9
 class DisableIntrospectionTest extends TestCase
10 10
 {
11 11
     private string $introspectionQuery = <<<'EOF'
12
-        query {
13
-          __schema {
14
-            types {
15
-              name
16
-              description
17
-            }
18
-          }
19
-        }
20
-        EOF;
21
-
22
-    public function testIntrospectionDisabled(): void
23
-    {
24
-        $expected = [
25
-            'errors' => [
26
-                [
27
-                    'message' => 'GraphQL introspection is not allowed, but the query contained __schema or __type',
28
-                    'extensions' => ['category' => 'graphql'],
29
-                    'locations' => [
30
-                        [
31
-                            'line' => 2,
32
-                            'column' => 3,
33
-                        ],
34
-                    ],
35
-                ],
36
-            ],
37
-        ];
38
-
39
-        $this->assertResponse($this->introspectionQuery, $expected, self::ANONYMOUS_USER, 'disableIntrospection');
40
-    }
41
-}
Please login to merge, or discard this patch.
Spacing   -30 removed lines patch added patch discarded remove patch
@@ -9,33 +9,3 @@
 block discarded – undo
9 9
 class DisableIntrospectionTest extends TestCase
10 10
 {
11 11
     private string $introspectionQuery = <<<'EOF'
12
-        query {
13
-          __schema {
14
-            types {
15
-              name
16
-              description
17
-            }
18
-          }
19
-        }
20
-        EOF;
21
-
22
-    public function testIntrospectionDisabled(): void
23
-    {
24
-        $expected = [
25
-            'errors' => [
26
-                [
27
-                    'message' => 'GraphQL introspection is not allowed, but the query contained __schema or __type',
28
-                    'extensions' => ['category' => 'graphql'],
29
-                    'locations' => [
30
-                        [
31
-                            'line' => 2,
32
-                            'column' => 3,
33
-                        ],
34
-                    ],
35
-                ],
36
-            ],
37
-        ];
38
-
39
-        $this->assertResponse($this->introspectionQuery, $expected, self::ANONYMOUS_USER, 'disableIntrospection');
40
-    }
41
-}
Please login to merge, or discard this patch.
Braces   -30 removed lines patch added patch discarded remove patch
@@ -9,33 +9,3 @@
 block discarded – undo
9 9
 class DisableIntrospectionTest extends TestCase
10 10
 {
11 11
     private string $introspectionQuery = <<<'EOF'
12
-        query {
13
-          __schema {
14
-            types {
15
-              name
16
-              description
17
-            }
18
-          }
19
-        }
20
-        EOF;
21
-
22
-    public function testIntrospectionDisabled(): void
23
-    {
24
-        $expected = [
25
-            'errors' => [
26
-                [
27
-                    'message' => 'GraphQL introspection is not allowed, but the query contained __schema or __type',
28
-                    'extensions' => ['category' => 'graphql'],
29
-                    'locations' => [
30
-                        [
31
-                            'line' => 2,
32
-                            'column' => 3,
33
-                        ],
34
-                    ],
35
-                ],
36
-            ],
37
-        ];
38
-
39
-        $this->assertResponse($this->introspectionQuery, $expected, self::ANONYMOUS_USER, 'disableIntrospection');
40
-    }
41
-}
Please login to merge, or discard this patch.
Upper-Lower-Casing   -30 removed lines patch added patch discarded remove patch
@@ -9,33 +9,3 @@
 block discarded – undo
9 9
 class DisableIntrospectionTest extends TestCase
10 10
 {
11 11
     private string $introspectionQuery = <<<'EOF'
12
-        query {
13
-          __schema {
14
-            types {
15
-              name
16
-              description
17
-            }
18
-          }
19
-        }
20
-        EOF;
21
-
22
-    public function testIntrospectionDisabled(): void
23
-    {
24
-        $expected = [
25
-            'errors' => [
26
-                [
27
-                    'message' => 'GraphQL introspection is not allowed, but the query contained __schema or __type',
28
-                    'extensions' => ['category' => 'graphql'],
29
-                    'locations' => [
30
-                        [
31
-                            'line' => 2,
32
-                            'column' => 3,
33
-                        ],
34
-                    ],
35
-                ],
36
-            ],
37
-        ];
38
-
39
-        $this->assertResponse($this->introspectionQuery, $expected, self::ANONYMOUS_USER, 'disableIntrospection');
40
-    }
41
-}
Please login to merge, or discard this patch.
tests/Functional/Security/QueryMaxDepthTest.php 5 patches
Indentation   -79 removed lines patch added patch discarded remove patch
@@ -9,82 +9,3 @@
 block discarded – undo
9 9
 class QueryMaxDepthTest extends TestCase
10 10
 {
11 11
     private string $userFriendsWithoutViolationQuery = <<<'EOF'
12
-        query {
13
-          user {
14
-            friends(first:1) {
15
-              edges {
16
-                node {
17
-                  name
18
-                }
19
-              }
20
-            }
21
-          }
22
-        }
23
-        EOF;
24
-
25
-    private string $userFriendsWithViolationQuery = <<<'EOF'
26
-        query {
27
-          user {
28
-            friends(first: 1) {
29
-              edges {
30
-                node {
31
-                  name
32
-                  friends {
33
-                    edges {
34
-                      node {
35
-                        name
36
-                      }
37
-                    }
38
-                  }
39
-                }
40
-              }
41
-            }
42
-          }
43
-        }
44
-        EOF;
45
-
46
-    public function testMaxDepthReachLimitation(): void
47
-    {
48
-        $expected = [
49
-            'errors' => [
50
-                [
51
-                    'message' => 'Max query depth should be 3 but got 6.',
52
-                    'extensions' => ['category' => 'graphql'],
53
-                ],
54
-            ],
55
-        ];
56
-
57
-        $this->assertResponse($this->userFriendsWithViolationQuery, $expected, self::ANONYMOUS_USER, 'queryMaxDepth');
58
-    }
59
-
60
-    public function testMaxDepthReachLimitationEnv(): void
61
-    {
62
-        $expected = [
63
-            'errors' => [
64
-                [
65
-                    'message' => 'Max query depth should be 3 but got 6.',
66
-                    'extensions' => ['category' => 'graphql'],
67
-                ],
68
-            ],
69
-        ];
70
-
71
-        $this->assertResponse($this->userFriendsWithViolationQuery, $expected, self::ANONYMOUS_USER, 'queryMaxDepthEnv');
72
-    }
73
-
74
-    public function testComplexityUnderLimitation(): void
75
-    {
76
-        $expected = [
77
-            'data' => [
78
-                'user' => [
79
-                    'friends' => [
80
-                        'edges' => [
81
-                            ['node' => ['name' => 'Nick']],
82
-                        ],
83
-                    ],
84
-                ],
85
-            ],
86
-        ];
87
-
88
-        $this->assertResponse($this->userFriendsWithoutViolationQuery, $expected, self::ANONYMOUS_USER, 'queryMaxDepth');
89
-    }
90
-}
Please login to merge, or discard this patch.
Switch Indentation   -79 removed lines patch added patch discarded remove patch
@@ -9,82 +9,3 @@
 block discarded – undo
9 9
 class QueryMaxDepthTest extends TestCase
10 10
 {
11 11
     private string $userFriendsWithoutViolationQuery = <<<'EOF'
12
-        query {
13
-          user {
14
-            friends(first:1) {
15
-              edges {
16
-                node {
17
-                  name
18
-                }
19
-              }
20
-            }
21
-          }
22
-        }
23
-        EOF;
24
-
25
-    private string $userFriendsWithViolationQuery = <<<'EOF'
26
-        query {
27
-          user {
28
-            friends(first: 1) {
29
-              edges {
30
-                node {
31
-                  name
32
-                  friends {
33
-                    edges {
34
-                      node {
35
-                        name
36
-                      }
37
-                    }
38
-                  }
39
-                }
40
-              }
41
-            }
42
-          }
43
-        }
44
-        EOF;
45
-
46
-    public function testMaxDepthReachLimitation(): void
47
-    {
48
-        $expected = [
49
-            'errors' => [
50
-                [
51
-                    'message' => 'Max query depth should be 3 but got 6.',
52
-                    'extensions' => ['category' => 'graphql'],
53
-                ],
54
-            ],
55
-        ];
56
-
57
-        $this->assertResponse($this->userFriendsWithViolationQuery, $expected, self::ANONYMOUS_USER, 'queryMaxDepth');
58
-    }
59
-
60
-    public function testMaxDepthReachLimitationEnv(): void
61
-    {
62
-        $expected = [
63
-            'errors' => [
64
-                [
65
-                    'message' => 'Max query depth should be 3 but got 6.',
66
-                    'extensions' => ['category' => 'graphql'],
67
-                ],
68
-            ],
69
-        ];
70
-
71
-        $this->assertResponse($this->userFriendsWithViolationQuery, $expected, self::ANONYMOUS_USER, 'queryMaxDepthEnv');
72
-    }
73
-
74
-    public function testComplexityUnderLimitation(): void
75
-    {
76
-        $expected = [
77
-            'data' => [
78
-                'user' => [
79
-                    'friends' => [
80
-                        'edges' => [
81
-                            ['node' => ['name' => 'Nick']],
82
-                        ],
83
-                    ],
84
-                ],
85
-            ],
86
-        ];
87
-
88
-        $this->assertResponse($this->userFriendsWithoutViolationQuery, $expected, self::ANONYMOUS_USER, 'queryMaxDepth');
89
-    }
90
-}
Please login to merge, or discard this patch.
Spacing   -79 removed lines patch added patch discarded remove patch
@@ -9,82 +9,3 @@
 block discarded – undo
9 9
 class QueryMaxDepthTest extends TestCase
10 10
 {
11 11
     private string $userFriendsWithoutViolationQuery = <<<'EOF'
12
-        query {
13
-          user {
14
-            friends(first:1) {
15
-              edges {
16
-                node {
17
-                  name
18
-                }
19
-              }
20
-            }
21
-          }
22
-        }
23
-        EOF;
24
-
25
-    private string $userFriendsWithViolationQuery = <<<'EOF'
26
-        query {
27
-          user {
28
-            friends(first: 1) {
29
-              edges {
30
-                node {
31
-                  name
32
-                  friends {
33
-                    edges {
34
-                      node {
35
-                        name
36
-                      }
37
-                    }
38
-                  }
39
-                }
40
-              }
41
-            }
42
-          }
43
-        }
44
-        EOF;
45
-
46
-    public function testMaxDepthReachLimitation(): void
47
-    {
48
-        $expected = [
49
-            'errors' => [
50
-                [
51
-                    'message' => 'Max query depth should be 3 but got 6.',
52
-                    'extensions' => ['category' => 'graphql'],
53
-                ],
54
-            ],
55
-        ];
56
-
57
-        $this->assertResponse($this->userFriendsWithViolationQuery, $expected, self::ANONYMOUS_USER, 'queryMaxDepth');
58
-    }
59
-
60
-    public function testMaxDepthReachLimitationEnv(): void
61
-    {
62
-        $expected = [
63
-            'errors' => [
64
-                [
65
-                    'message' => 'Max query depth should be 3 but got 6.',
66
-                    'extensions' => ['category' => 'graphql'],
67
-                ],
68
-            ],
69
-        ];
70
-
71
-        $this->assertResponse($this->userFriendsWithViolationQuery, $expected, self::ANONYMOUS_USER, 'queryMaxDepthEnv');
72
-    }
73
-
74
-    public function testComplexityUnderLimitation(): void
75
-    {
76
-        $expected = [
77
-            'data' => [
78
-                'user' => [
79
-                    'friends' => [
80
-                        'edges' => [
81
-                            ['node' => ['name' => 'Nick']],
82
-                        ],
83
-                    ],
84
-                ],
85
-            ],
86
-        ];
87
-
88
-        $this->assertResponse($this->userFriendsWithoutViolationQuery, $expected, self::ANONYMOUS_USER, 'queryMaxDepth');
89
-    }
90
-}
Please login to merge, or discard this patch.
Braces   -79 removed lines patch added patch discarded remove patch
@@ -9,82 +9,3 @@
 block discarded – undo
9 9
 class QueryMaxDepthTest extends TestCase
10 10
 {
11 11
     private string $userFriendsWithoutViolationQuery = <<<'EOF'
12
-        query {
13
-          user {
14
-            friends(first:1) {
15
-              edges {
16
-                node {
17
-                  name
18
-                }
19
-              }
20
-            }
21
-          }
22
-        }
23
-        EOF;
24
-
25
-    private string $userFriendsWithViolationQuery = <<<'EOF'
26
-        query {
27
-          user {
28
-            friends(first: 1) {
29
-              edges {
30
-                node {
31
-                  name
32
-                  friends {
33
-                    edges {
34
-                      node {
35
-                        name
36
-                      }
37
-                    }
38
-                  }
39
-                }
40
-              }
41
-            }
42
-          }
43
-        }
44
-        EOF;
45
-
46
-    public function testMaxDepthReachLimitation(): void
47
-    {
48
-        $expected = [
49
-            'errors' => [
50
-                [
51
-                    'message' => 'Max query depth should be 3 but got 6.',
52
-                    'extensions' => ['category' => 'graphql'],
53
-                ],
54
-            ],
55
-        ];
56
-
57
-        $this->assertResponse($this->userFriendsWithViolationQuery, $expected, self::ANONYMOUS_USER, 'queryMaxDepth');
58
-    }
59
-
60
-    public function testMaxDepthReachLimitationEnv(): void
61
-    {
62
-        $expected = [
63
-            'errors' => [
64
-                [
65
-                    'message' => 'Max query depth should be 3 but got 6.',
66
-                    'extensions' => ['category' => 'graphql'],
67
-                ],
68
-            ],
69
-        ];
70
-
71
-        $this->assertResponse($this->userFriendsWithViolationQuery, $expected, self::ANONYMOUS_USER, 'queryMaxDepthEnv');
72
-    }
73
-
74
-    public function testComplexityUnderLimitation(): void
75
-    {
76
-        $expected = [
77
-            'data' => [
78
-                'user' => [
79
-                    'friends' => [
80
-                        'edges' => [
81
-                            ['node' => ['name' => 'Nick']],
82
-                        ],
83
-                    ],
84
-                ],
85
-            ],
86
-        ];
87
-
88
-        $this->assertResponse($this->userFriendsWithoutViolationQuery, $expected, self::ANONYMOUS_USER, 'queryMaxDepth');
89
-    }
90
-}
Please login to merge, or discard this patch.
Upper-Lower-Casing   -79 removed lines patch added patch discarded remove patch
@@ -9,82 +9,3 @@
 block discarded – undo
9 9
 class QueryMaxDepthTest extends TestCase
10 10
 {
11 11
     private string $userFriendsWithoutViolationQuery = <<<'EOF'
12
-        query {
13
-          user {
14
-            friends(first:1) {
15
-              edges {
16
-                node {
17
-                  name
18
-                }
19
-              }
20
-            }
21
-          }
22
-        }
23
-        EOF;
24
-
25
-    private string $userFriendsWithViolationQuery = <<<'EOF'
26
-        query {
27
-          user {
28
-            friends(first: 1) {
29
-              edges {
30
-                node {
31
-                  name
32
-                  friends {
33
-                    edges {
34
-                      node {
35
-                        name
36
-                      }
37
-                    }
38
-                  }
39
-                }
40
-              }
41
-            }
42
-          }
43
-        }
44
-        EOF;
45
-
46
-    public function testMaxDepthReachLimitation(): void
47
-    {
48
-        $expected = [
49
-            'errors' => [
50
-                [
51
-                    'message' => 'Max query depth should be 3 but got 6.',
52
-                    'extensions' => ['category' => 'graphql'],
53
-                ],
54
-            ],
55
-        ];
56
-
57
-        $this->assertResponse($this->userFriendsWithViolationQuery, $expected, self::ANONYMOUS_USER, 'queryMaxDepth');
58
-    }
59
-
60
-    public function testMaxDepthReachLimitationEnv(): void
61
-    {
62
-        $expected = [
63
-            'errors' => [
64
-                [
65
-                    'message' => 'Max query depth should be 3 but got 6.',
66
-                    'extensions' => ['category' => 'graphql'],
67
-                ],
68
-            ],
69
-        ];
70
-
71
-        $this->assertResponse($this->userFriendsWithViolationQuery, $expected, self::ANONYMOUS_USER, 'queryMaxDepthEnv');
72
-    }
73
-
74
-    public function testComplexityUnderLimitation(): void
75
-    {
76
-        $expected = [
77
-            'data' => [
78
-                'user' => [
79
-                    'friends' => [
80
-                        'edges' => [
81
-                            ['node' => ['name' => 'Nick']],
82
-                        ],
83
-                    ],
84
-                ],
85
-            ],
86
-        ];
87
-
88
-        $this->assertResponse($this->userFriendsWithoutViolationQuery, $expected, self::ANONYMOUS_USER, 'queryMaxDepth');
89
-    }
90
-}
Please login to merge, or discard this patch.
tests/Functional/Security/QueryComplexityTest.php 5 patches
Indentation   -72 removed lines patch added patch discarded remove patch
@@ -9,75 +9,3 @@
 block discarded – undo
9 9
 class QueryComplexityTest extends TestCase
10 10
 {
11 11
     private string $userFriendsWithoutLimitQuery = <<<'EOF'
12
-        query {
13
-          user {
14
-            friends {
15
-              edges {
16
-                node {
17
-                  name
18
-                }
19
-              }
20
-            }
21
-          }
22
-        }
23
-        EOF;
24
-
25
-    private string $userFriendsWithLimitQuery = <<<'EOF'
26
-        query {
27
-          user {
28
-            friends(first: 1) {
29
-              edges {
30
-                node {
31
-                  name
32
-                }
33
-              }
34
-            }
35
-          }
36
-        }
37
-        EOF;
38
-
39
-    public function testComplexityReachLimitation(): void
40
-    {
41
-        $expected = [
42
-            'errors' => [
43
-                [
44
-                    'message' => 'Max query complexity should be 10 but got 54.',
45
-                    'extensions' => ['category' => 'graphql'],
46
-                ],
47
-            ],
48
-        ];
49
-
50
-        $this->assertResponse($this->userFriendsWithoutLimitQuery, $expected, self::ANONYMOUS_USER, 'queryComplexity');
51
-    }
52
-
53
-    public function testComplexityReachLimitationEnv(): void
54
-    {
55
-        $expected = [
56
-            'errors' => [
57
-                [
58
-                    'message' => 'Max query complexity should be 10 but got 54.',
59
-                    'extensions' => ['category' => 'graphql'],
60
-                ],
61
-            ],
62
-        ];
63
-
64
-        $this->assertResponse($this->userFriendsWithoutLimitQuery, $expected, self::ANONYMOUS_USER, 'queryComplexityEnv');
65
-    }
66
-
67
-    public function testComplexityUnderLimitation(): void
68
-    {
69
-        $expected = [
70
-            'data' => [
71
-                'user' => [
72
-                    'friends' => [
73
-                        'edges' => [
74
-                            ['node' => ['name' => 'Nick']],
75
-                        ],
76
-                    ],
77
-                ],
78
-            ],
79
-        ];
80
-
81
-        $this->assertResponse($this->userFriendsWithLimitQuery, $expected, self::ANONYMOUS_USER, 'queryComplexity');
82
-    }
83
-}
Please login to merge, or discard this patch.
Switch Indentation   -72 removed lines patch added patch discarded remove patch
@@ -9,75 +9,3 @@
 block discarded – undo
9 9
 class QueryComplexityTest extends TestCase
10 10
 {
11 11
     private string $userFriendsWithoutLimitQuery = <<<'EOF'
12
-        query {
13
-          user {
14
-            friends {
15
-              edges {
16
-                node {
17
-                  name
18
-                }
19
-              }
20
-            }
21
-          }
22
-        }
23
-        EOF;
24
-
25
-    private string $userFriendsWithLimitQuery = <<<'EOF'
26
-        query {
27
-          user {
28
-            friends(first: 1) {
29
-              edges {
30
-                node {
31
-                  name
32
-                }
33
-              }
34
-            }
35
-          }
36
-        }
37
-        EOF;
38
-
39
-    public function testComplexityReachLimitation(): void
40
-    {
41
-        $expected = [
42
-            'errors' => [
43
-                [
44
-                    'message' => 'Max query complexity should be 10 but got 54.',
45
-                    'extensions' => ['category' => 'graphql'],
46
-                ],
47
-            ],
48
-        ];
49
-
50
-        $this->assertResponse($this->userFriendsWithoutLimitQuery, $expected, self::ANONYMOUS_USER, 'queryComplexity');
51
-    }
52
-
53
-    public function testComplexityReachLimitationEnv(): void
54
-    {
55
-        $expected = [
56
-            'errors' => [
57
-                [
58
-                    'message' => 'Max query complexity should be 10 but got 54.',
59
-                    'extensions' => ['category' => 'graphql'],
60
-                ],
61
-            ],
62
-        ];
63
-
64
-        $this->assertResponse($this->userFriendsWithoutLimitQuery, $expected, self::ANONYMOUS_USER, 'queryComplexityEnv');
65
-    }
66
-
67
-    public function testComplexityUnderLimitation(): void
68
-    {
69
-        $expected = [
70
-            'data' => [
71
-                'user' => [
72
-                    'friends' => [
73
-                        'edges' => [
74
-                            ['node' => ['name' => 'Nick']],
75
-                        ],
76
-                    ],
77
-                ],
78
-            ],
79
-        ];
80
-
81
-        $this->assertResponse($this->userFriendsWithLimitQuery, $expected, self::ANONYMOUS_USER, 'queryComplexity');
82
-    }
83
-}
Please login to merge, or discard this patch.
Spacing   -72 removed lines patch added patch discarded remove patch
@@ -9,75 +9,3 @@
 block discarded – undo
9 9
 class QueryComplexityTest extends TestCase
10 10
 {
11 11
     private string $userFriendsWithoutLimitQuery = <<<'EOF'
12
-        query {
13
-          user {
14
-            friends {
15
-              edges {
16
-                node {
17
-                  name
18
-                }
19
-              }
20
-            }
21
-          }
22
-        }
23
-        EOF;
24
-
25
-    private string $userFriendsWithLimitQuery = <<<'EOF'
26
-        query {
27
-          user {
28
-            friends(first: 1) {
29
-              edges {
30
-                node {
31
-                  name
32
-                }
33
-              }
34
-            }
35
-          }
36
-        }
37
-        EOF;
38
-
39
-    public function testComplexityReachLimitation(): void
40
-    {
41
-        $expected = [
42
-            'errors' => [
43
-                [
44
-                    'message' => 'Max query complexity should be 10 but got 54.',
45
-                    'extensions' => ['category' => 'graphql'],
46
-                ],
47
-            ],
48
-        ];
49
-
50
-        $this->assertResponse($this->userFriendsWithoutLimitQuery, $expected, self::ANONYMOUS_USER, 'queryComplexity');
51
-    }
52
-
53
-    public function testComplexityReachLimitationEnv(): void
54
-    {
55
-        $expected = [
56
-            'errors' => [
57
-                [
58
-                    'message' => 'Max query complexity should be 10 but got 54.',
59
-                    'extensions' => ['category' => 'graphql'],
60
-                ],
61
-            ],
62
-        ];
63
-
64
-        $this->assertResponse($this->userFriendsWithoutLimitQuery, $expected, self::ANONYMOUS_USER, 'queryComplexityEnv');
65
-    }
66
-
67
-    public function testComplexityUnderLimitation(): void
68
-    {
69
-        $expected = [
70
-            'data' => [
71
-                'user' => [
72
-                    'friends' => [
73
-                        'edges' => [
74
-                            ['node' => ['name' => 'Nick']],
75
-                        ],
76
-                    ],
77
-                ],
78
-            ],
79
-        ];
80
-
81
-        $this->assertResponse($this->userFriendsWithLimitQuery, $expected, self::ANONYMOUS_USER, 'queryComplexity');
82
-    }
83
-}
Please login to merge, or discard this patch.
Braces   -72 removed lines patch added patch discarded remove patch
@@ -9,75 +9,3 @@
 block discarded – undo
9 9
 class QueryComplexityTest extends TestCase
10 10
 {
11 11
     private string $userFriendsWithoutLimitQuery = <<<'EOF'
12
-        query {
13
-          user {
14
-            friends {
15
-              edges {
16
-                node {
17
-                  name
18
-                }
19
-              }
20
-            }
21
-          }
22
-        }
23
-        EOF;
24
-
25
-    private string $userFriendsWithLimitQuery = <<<'EOF'
26
-        query {
27
-          user {
28
-            friends(first: 1) {
29
-              edges {
30
-                node {
31
-                  name
32
-                }
33
-              }
34
-            }
35
-          }
36
-        }
37
-        EOF;
38
-
39
-    public function testComplexityReachLimitation(): void
40
-    {
41
-        $expected = [
42
-            'errors' => [
43
-                [
44
-                    'message' => 'Max query complexity should be 10 but got 54.',
45
-                    'extensions' => ['category' => 'graphql'],
46
-                ],
47
-            ],
48
-        ];
49
-
50
-        $this->assertResponse($this->userFriendsWithoutLimitQuery, $expected, self::ANONYMOUS_USER, 'queryComplexity');
51
-    }
52
-
53
-    public function testComplexityReachLimitationEnv(): void
54
-    {
55
-        $expected = [
56
-            'errors' => [
57
-                [
58
-                    'message' => 'Max query complexity should be 10 but got 54.',
59
-                    'extensions' => ['category' => 'graphql'],
60
-                ],
61
-            ],
62
-        ];
63
-
64
-        $this->assertResponse($this->userFriendsWithoutLimitQuery, $expected, self::ANONYMOUS_USER, 'queryComplexityEnv');
65
-    }
66
-
67
-    public function testComplexityUnderLimitation(): void
68
-    {
69
-        $expected = [
70
-            'data' => [
71
-                'user' => [
72
-                    'friends' => [
73
-                        'edges' => [
74
-                            ['node' => ['name' => 'Nick']],
75
-                        ],
76
-                    ],
77
-                ],
78
-            ],
79
-        ];
80
-
81
-        $this->assertResponse($this->userFriendsWithLimitQuery, $expected, self::ANONYMOUS_USER, 'queryComplexity');
82
-    }
83
-}
Please login to merge, or discard this patch.
Upper-Lower-Casing   -72 removed lines patch added patch discarded remove patch
@@ -9,75 +9,3 @@
 block discarded – undo
9 9
 class QueryComplexityTest extends TestCase
10 10
 {
11 11
     private string $userFriendsWithoutLimitQuery = <<<'EOF'
12
-        query {
13
-          user {
14
-            friends {
15
-              edges {
16
-                node {
17
-                  name
18
-                }
19
-              }
20
-            }
21
-          }
22
-        }
23
-        EOF;
24
-
25
-    private string $userFriendsWithLimitQuery = <<<'EOF'
26
-        query {
27
-          user {
28
-            friends(first: 1) {
29
-              edges {
30
-                node {
31
-                  name
32
-                }
33
-              }
34
-            }
35
-          }
36
-        }
37
-        EOF;
38
-
39
-    public function testComplexityReachLimitation(): void
40
-    {
41
-        $expected = [
42
-            'errors' => [
43
-                [
44
-                    'message' => 'Max query complexity should be 10 but got 54.',
45
-                    'extensions' => ['category' => 'graphql'],
46
-                ],
47
-            ],
48
-        ];
49
-
50
-        $this->assertResponse($this->userFriendsWithoutLimitQuery, $expected, self::ANONYMOUS_USER, 'queryComplexity');
51
-    }
52
-
53
-    public function testComplexityReachLimitationEnv(): void
54
-    {
55
-        $expected = [
56
-            'errors' => [
57
-                [
58
-                    'message' => 'Max query complexity should be 10 but got 54.',
59
-                    'extensions' => ['category' => 'graphql'],
60
-                ],
61
-            ],
62
-        ];
63
-
64
-        $this->assertResponse($this->userFriendsWithoutLimitQuery, $expected, self::ANONYMOUS_USER, 'queryComplexityEnv');
65
-    }
66
-
67
-    public function testComplexityUnderLimitation(): void
68
-    {
69
-        $expected = [
70
-            'data' => [
71
-                'user' => [
72
-                    'friends' => [
73
-                        'edges' => [
74
-                            ['node' => ['name' => 'Nick']],
75
-                        ],
76
-                    ],
77
-                ],
78
-            ],
79
-        ];
80
-
81
-        $this->assertResponse($this->userFriendsWithLimitQuery, $expected, self::ANONYMOUS_USER, 'queryComplexity');
82
-    }
83
-}
Please login to merge, or discard this patch.
tests/Functional/Security/AccessTest.php 5 patches
Indentation   -347 removed lines patch added patch discarded remove patch
@@ -26,350 +26,3 @@
 block discarded – undo
26 26
     private string $userIsEnabledQuery = 'query ($hasAccess: Boolean = true) { user { isEnabled(hasAccess: $hasAccess) } }';
27 27
 
28 28
     private string $userFriendsQuery = <<<'QUERY'
29
-        query {
30
-          user {
31
-            friends(first: 2) {
32
-              edges {
33
-                node {
34
-                  name
35
-                }
36
-              }
37
-            }
38
-          }
39
-        }
40
-        QUERY;
41
-
42
-    private string $simpleMutationWithThunkQuery = <<<'MUTATION'
43
-        mutation M {
44
-          simpleMutationWithThunkFields(input: {inputData: %d, clientMutationId: "bac"}) {
45
-            result
46
-            clientMutationId
47
-          }
48
-        }
49
-        MUTATION;
50
-
51
-    public function setUp(): void
52
-    {
53
-        parent::setUp();
54
-        // load types
55
-        $this->loader = function ($class): void {
56
-            if (preg_match('@^'.preg_quote('Overblog\GraphQLBundle\Access\__DEFINITIONS__\\').'(.*)$@', $class, $matches)) {
57
-                $file = sys_get_temp_dir().'/OverblogGraphQLBundle/'.Kernel::VERSION.'/access/cache/testaccess/overblog/graphql-bundle/__definitions__/'.$matches[1].'.php';
58
-                if (file_exists($file)) {
59
-                    require $file;
60
-                }
61
-            }
62
-        };
63
-        spl_autoload_register($this->loader);
64
-    }
65
-
66
-    public function testCustomClassLoaderNotRegister(): void
67
-    {
68
-        $this->expectException(Error::class);
69
-        if ((int) phpversion() <= 7) {
70
-            $this->expectExceptionMessage('Class \'Overblog\GraphQLBundle\Access\__DEFINITIONS__\RootQueryType\' not found');
71
-        } else {
72
-            $this->expectExceptionMessage('Class "Overblog\GraphQLBundle\Access\__DEFINITIONS__\RootQueryType" not found');
73
-        }
74
-        spl_autoload_unregister($this->loader);
75
-        $this->assertResponse($this->userNameQuery, [], static::ANONYMOUS_USER, 'access');
76
-    }
77
-
78
-    public function testNotAuthenticatedUserAccessAsPromisedFulfilledTrue(): void
79
-    {
80
-        $this->assertResponse(
81
-            $this->userIsEnabledQuery,
82
-            ['data' => ['user' => ['isEnabled' => true]]],
83
-            static::ANONYMOUS_USER,
84
-            'access'
85
-        );
86
-    }
87
-
88
-    public function testNotAuthenticatedUserAccessAsPromisedFulfilledFalse(): void
89
-    {
90
-        $this->assertResponse(
91
-            $this->userIsEnabledQuery,
92
-            [
93
-                'data' => [
94
-                    'user' => [
95
-                        'isEnabled' => null,
96
-                    ],
97
-                ],
98
-                'extensions' => [
99
-                    'warnings' => [
100
-                        [
101
-                            'message' => 'Access denied to this field.',
102
-                            'extensions' => ['category' => 'user'],
103
-                            'locations' => [['line' => 1, 'column' => 45]],
104
-                            'path' => ['user', 'isEnabled'],
105
-                        ],
106
-                    ],
107
-                ],
108
-            ],
109
-            static::ANONYMOUS_USER,
110
-            'access',
111
-            '',
112
-            ['hasAccess' => false]
113
-        );
114
-    }
115
-
116
-    public function testNotAuthenticatedUserAccessToUserName(): void
117
-    {
118
-        $expected = [
119
-            'data' => [
120
-                'user' => [
121
-                    'name' => null,
122
-                ],
123
-            ],
124
-            'extensions' => [
125
-                'warnings' => [
126
-                    [
127
-                        'message' => 'Access denied to this field.',
128
-                        'extensions' => ['category' => 'user'],
129
-                        'locations' => [['line' => 1, 'column' => 16]],
130
-                        'path' => ['user', 'name'],
131
-                    ],
132
-                ],
133
-            ],
134
-        ];
135
-
136
-        $this->assertResponse($this->userNameQuery, $expected, static::ANONYMOUS_USER, 'access');
137
-    }
138
-
139
-    public function testNonAuthenticatedUserAccessSecuredFieldWhichInitiallyResolvesToArray(): void
140
-    {
141
-        $expected = [
142
-            'data' => [
143
-                'youShallNotSeeThisUnauthenticated' => null,
144
-            ],
145
-            'extensions' => [
146
-                'warnings' => [
147
-                    [
148
-                        'message' => 'Access denied to this field.',
149
-                        'extensions' => ['category' => 'user'],
150
-                        'locations' => [
151
-                            [
152
-                                'line' => 2,
153
-                                'column' => 3,
154
-                            ],
155
-                        ],
156
-                        'path' => ['youShallNotSeeThisUnauthenticated'],
157
-                    ],
158
-                ],
159
-            ],
160
-        ];
161
-
162
-        $query = <<<'QUERY'
163
-            {
164
-              youShallNotSeeThisUnauthenticated {
165
-                secretValue
166
-                youAreAuthenticated
167
-              }
168
-            }
169
-            QUERY;
170
-
171
-        $this->assertResponse($query, $expected, static::ANONYMOUS_USER, 'access');
172
-    }
173
-
174
-    public function testFullyAuthenticatedUserAccessToUserName(): void
175
-    {
176
-        $expected = [
177
-            'data' => [
178
-                'user' => [
179
-                    'name' => 'Dan',
180
-                ],
181
-            ],
182
-        ];
183
-
184
-        $this->assertResponse($this->userNameQuery, $expected, static::USER_RYAN, 'access');
185
-    }
186
-
187
-    public function testNotAuthenticatedUserAccessToUserRoles(): void
188
-    {
189
-        $this->assertResponse($this->userRolesQuery, $this->expectedFailedUserRoles(), static::ANONYMOUS_USER, 'access');
190
-    }
191
-
192
-    public function testAuthenticatedUserAccessToUserRolesWithoutEnoughRights(): void
193
-    {
194
-        $this->assertResponse($this->userRolesQuery, $this->expectedFailedUserRoles(), static::USER_RYAN, 'access');
195
-    }
196
-
197
-    public function testUserWithCorrectRightsAccessToUserRoles(): void
198
-    {
199
-        $expected = [
200
-            'data' => [
201
-                'user' => [
202
-                    'roles' => ['ROLE_USER'],
203
-                ],
204
-            ],
205
-        ];
206
-
207
-        $this->assertResponse($this->userRolesQuery, $expected, static::USER_ADMIN, 'access');
208
-    }
209
-
210
-    public function testUserForbiddenField(): void
211
-    {
212
-        $expected = [
213
-            'data' => [
214
-                'user' => null,
215
-            ],
216
-            'extensions' => [
217
-                'warnings' => [
218
-                    [
219
-                        'message' => 'Access denied to this field.',
220
-                        'extensions' => ['category' => 'user'],
221
-                        'locations' => [
222
-                            [
223
-                                'line' => 3,
224
-                                'column' => 5,
225
-                            ],
226
-                        ],
227
-                        'path' => ['user', 'forbidden'],
228
-                    ],
229
-                ],
230
-            ],
231
-        ];
232
-
233
-        $query = <<<'QUERY'
234
-            query MyQuery {
235
-              user {
236
-                forbidden
237
-              }
238
-            }
239
-            QUERY;
240
-
241
-        $this->assertResponse($query, $expected, static::USER_ADMIN, 'access');
242
-    }
243
-
244
-    public function testUserAccessToUserFriends(): void
245
-    {
246
-        $expected = [
247
-            'data' => [
248
-                'user' => [
249
-                    'friends' => [
250
-                        'edges' => [
251
-                            ['node' => ['name' => 'Nick']],
252
-                            ['node' => null],
253
-                        ],
254
-                    ],
255
-                ],
256
-            ],
257
-        ];
258
-
259
-        $this->assertResponse($this->userFriendsQuery, $expected, static::USER_ADMIN, 'access');
260
-    }
261
-
262
-    public function testUserAccessToUserFriendsAsArray(): void
263
-    {
264
-        $expected = [
265
-            'data' => [
266
-                'user' => [
267
-                    'friendsAsArray' => [1, null, 3],
268
-                ],
269
-            ],
270
-        ];
271
-
272
-        $this->assertResponse('query { user { friendsAsArray } }', $expected, static::USER_ADMIN, 'access');
273
-    }
274
-
275
-    public function testMutationAllowedUser(): void
276
-    {
277
-        $result = 123;
278
-
279
-        $expected = [
280
-            'data' => [
281
-                'simpleMutationWithThunkFields' => [
282
-                    'result' => $result,
283
-                    'clientMutationId' => 'bac',
284
-                ],
285
-            ],
286
-        ];
287
-
288
-        $this->assertResponse(sprintf($this->simpleMutationWithThunkQuery, $result), $expected, static::USER_ADMIN, 'access');
289
-        $this->assertTrue(SimpleMutationWithThunkFieldsMutation::hasMutate(true));
290
-    }
291
-
292
-    public function testMutationAllowedButNoRightsToDisplayPayload(): void
293
-    {
294
-        $expected = [
295
-            'data' => [
296
-                'simpleMutationWithThunkFields' => [
297
-                    'result' => null,
298
-                    'clientMutationId' => 'bac',
299
-                ],
300
-            ],
301
-            'extensions' => [
302
-                'warnings' => [
303
-                    [
304
-                        'message' => 'Access denied to this field.',
305
-                        'extensions' => ['category' => 'user'],
306
-                        'locations' => [
307
-                            [
308
-                                'line' => 3,
309
-                                'column' => 5,
310
-                            ],
311
-                        ],
312
-                        'path' => ['simpleMutationWithThunkFields', 'result'],
313
-                    ],
314
-                ],
315
-            ],
316
-        ];
317
-
318
-        $this->assertResponse(sprintf($this->simpleMutationWithThunkQuery, 321), $expected, static::USER_ADMIN, 'access');
319
-        $this->assertTrue(SimpleMutationWithThunkFieldsMutation::hasMutate(true));
320
-    }
321
-
322
-    public function testMutationNotAllowedUser(): void
323
-    {
324
-        $expected = [
325
-            'errors' => [
326
-                [
327
-                    'message' => 'Access denied to this field.',
328
-                    'extensions' => ['category' => 'user'],
329
-                    'locations' => [
330
-                        [
331
-                            'line' => 2,
332
-                            'column' => 3,
333
-                        ],
334
-                    ],
335
-                    'path' => ['simpleMutationWithThunkFields'],
336
-                ],
337
-            ],
338
-            'data' => [
339
-                'simpleMutationWithThunkFields' => null,
340
-            ],
341
-        ];
342
-
343
-        $this->assertResponse(sprintf($this->simpleMutationWithThunkQuery, 123), $expected, static::USER_RYAN, 'access');
344
-        $this->assertFalse(SimpleMutationWithThunkFieldsMutation::hasMutate(true));
345
-    }
346
-
347
-    private function expectedFailedUserRoles(): array
348
-    {
349
-        return [
350
-            'data' => [
351
-                'user' => [
352
-                    'roles' => null,
353
-                ],
354
-            ],
355
-            'extensions' => [
356
-                'warnings' => [
357
-                    [
358
-                        'message' => 'Access denied to this field.',
359
-                        'extensions' => ['category' => 'user'],
360
-                        'locations' => [
361
-                            [
362
-                                'line' => 1,
363
-                                'column' => 16,
364
-                            ],
365
-                        ],
366
-                        'path' => [
367
-                            'user',
368
-                            'roles',
369
-                        ],
370
-                    ],
371
-                ],
372
-            ],
373
-        ];
374
-    }
375
-}
Please login to merge, or discard this patch.
Switch Indentation   -347 removed lines patch added patch discarded remove patch
@@ -26,350 +26,3 @@
 block discarded – undo
26 26
     private string $userIsEnabledQuery = 'query ($hasAccess: Boolean = true) { user { isEnabled(hasAccess: $hasAccess) } }';
27 27
 
28 28
     private string $userFriendsQuery = <<<'QUERY'
29
-        query {
30
-          user {
31
-            friends(first: 2) {
32
-              edges {
33
-                node {
34
-                  name
35
-                }
36
-              }
37
-            }
38
-          }
39
-        }
40
-        QUERY;
41
-
42
-    private string $simpleMutationWithThunkQuery = <<<'MUTATION'
43
-        mutation M {
44
-          simpleMutationWithThunkFields(input: {inputData: %d, clientMutationId: "bac"}) {
45
-            result
46
-            clientMutationId
47
-          }
48
-        }
49
-        MUTATION;
50
-
51
-    public function setUp(): void
52
-    {
53
-        parent::setUp();
54
-        // load types
55
-        $this->loader = function ($class): void {
56
-            if (preg_match('@^'.preg_quote('Overblog\GraphQLBundle\Access\__DEFINITIONS__\\').'(.*)$@', $class, $matches)) {
57
-                $file = sys_get_temp_dir().'/OverblogGraphQLBundle/'.Kernel::VERSION.'/access/cache/testaccess/overblog/graphql-bundle/__definitions__/'.$matches[1].'.php';
58
-                if (file_exists($file)) {
59
-                    require $file;
60
-                }
61
-            }
62
-        };
63
-        spl_autoload_register($this->loader);
64
-    }
65
-
66
-    public function testCustomClassLoaderNotRegister(): void
67
-    {
68
-        $this->expectException(Error::class);
69
-        if ((int) phpversion() <= 7) {
70
-            $this->expectExceptionMessage('Class \'Overblog\GraphQLBundle\Access\__DEFINITIONS__\RootQueryType\' not found');
71
-        } else {
72
-            $this->expectExceptionMessage('Class "Overblog\GraphQLBundle\Access\__DEFINITIONS__\RootQueryType" not found');
73
-        }
74
-        spl_autoload_unregister($this->loader);
75
-        $this->assertResponse($this->userNameQuery, [], static::ANONYMOUS_USER, 'access');
76
-    }
77
-
78
-    public function testNotAuthenticatedUserAccessAsPromisedFulfilledTrue(): void
79
-    {
80
-        $this->assertResponse(
81
-            $this->userIsEnabledQuery,
82
-            ['data' => ['user' => ['isEnabled' => true]]],
83
-            static::ANONYMOUS_USER,
84
-            'access'
85
-        );
86
-    }
87
-
88
-    public function testNotAuthenticatedUserAccessAsPromisedFulfilledFalse(): void
89
-    {
90
-        $this->assertResponse(
91
-            $this->userIsEnabledQuery,
92
-            [
93
-                'data' => [
94
-                    'user' => [
95
-                        'isEnabled' => null,
96
-                    ],
97
-                ],
98
-                'extensions' => [
99
-                    'warnings' => [
100
-                        [
101
-                            'message' => 'Access denied to this field.',
102
-                            'extensions' => ['category' => 'user'],
103
-                            'locations' => [['line' => 1, 'column' => 45]],
104
-                            'path' => ['user', 'isEnabled'],
105
-                        ],
106
-                    ],
107
-                ],
108
-            ],
109
-            static::ANONYMOUS_USER,
110
-            'access',
111
-            '',
112
-            ['hasAccess' => false]
113
-        );
114
-    }
115
-
116
-    public function testNotAuthenticatedUserAccessToUserName(): void
117
-    {
118
-        $expected = [
119
-            'data' => [
120
-                'user' => [
121
-                    'name' => null,
122
-                ],
123
-            ],
124
-            'extensions' => [
125
-                'warnings' => [
126
-                    [
127
-                        'message' => 'Access denied to this field.',
128
-                        'extensions' => ['category' => 'user'],
129
-                        'locations' => [['line' => 1, 'column' => 16]],
130
-                        'path' => ['user', 'name'],
131
-                    ],
132
-                ],
133
-            ],
134
-        ];
135
-
136
-        $this->assertResponse($this->userNameQuery, $expected, static::ANONYMOUS_USER, 'access');
137
-    }
138
-
139
-    public function testNonAuthenticatedUserAccessSecuredFieldWhichInitiallyResolvesToArray(): void
140
-    {
141
-        $expected = [
142
-            'data' => [
143
-                'youShallNotSeeThisUnauthenticated' => null,
144
-            ],
145
-            'extensions' => [
146
-                'warnings' => [
147
-                    [
148
-                        'message' => 'Access denied to this field.',
149
-                        'extensions' => ['category' => 'user'],
150
-                        'locations' => [
151
-                            [
152
-                                'line' => 2,
153
-                                'column' => 3,
154
-                            ],
155
-                        ],
156
-                        'path' => ['youShallNotSeeThisUnauthenticated'],
157
-                    ],
158
-                ],
159
-            ],
160
-        ];
161
-
162
-        $query = <<<'QUERY'
163
-            {
164
-              youShallNotSeeThisUnauthenticated {
165
-                secretValue
166
-                youAreAuthenticated
167
-              }
168
-            }
169
-            QUERY;
170
-
171
-        $this->assertResponse($query, $expected, static::ANONYMOUS_USER, 'access');
172
-    }
173
-
174
-    public function testFullyAuthenticatedUserAccessToUserName(): void
175
-    {
176
-        $expected = [
177
-            'data' => [
178
-                'user' => [
179
-                    'name' => 'Dan',
180
-                ],
181
-            ],
182
-        ];
183
-
184
-        $this->assertResponse($this->userNameQuery, $expected, static::USER_RYAN, 'access');
185
-    }
186
-
187
-    public function testNotAuthenticatedUserAccessToUserRoles(): void
188
-    {
189
-        $this->assertResponse($this->userRolesQuery, $this->expectedFailedUserRoles(), static::ANONYMOUS_USER, 'access');
190
-    }
191
-
192
-    public function testAuthenticatedUserAccessToUserRolesWithoutEnoughRights(): void
193
-    {
194
-        $this->assertResponse($this->userRolesQuery, $this->expectedFailedUserRoles(), static::USER_RYAN, 'access');
195
-    }
196
-
197
-    public function testUserWithCorrectRightsAccessToUserRoles(): void
198
-    {
199
-        $expected = [
200
-            'data' => [
201
-                'user' => [
202
-                    'roles' => ['ROLE_USER'],
203
-                ],
204
-            ],
205
-        ];
206
-
207
-        $this->assertResponse($this->userRolesQuery, $expected, static::USER_ADMIN, 'access');
208
-    }
209
-
210
-    public function testUserForbiddenField(): void
211
-    {
212
-        $expected = [
213
-            'data' => [
214
-                'user' => null,
215
-            ],
216
-            'extensions' => [
217
-                'warnings' => [
218
-                    [
219
-                        'message' => 'Access denied to this field.',
220
-                        'extensions' => ['category' => 'user'],
221
-                        'locations' => [
222
-                            [
223
-                                'line' => 3,
224
-                                'column' => 5,
225
-                            ],
226
-                        ],
227
-                        'path' => ['user', 'forbidden'],
228
-                    ],
229
-                ],
230
-            ],
231
-        ];
232
-
233
-        $query = <<<'QUERY'
234
-            query MyQuery {
235
-              user {
236
-                forbidden
237
-              }
238
-            }
239
-            QUERY;
240
-
241
-        $this->assertResponse($query, $expected, static::USER_ADMIN, 'access');
242
-    }
243
-
244
-    public function testUserAccessToUserFriends(): void
245
-    {
246
-        $expected = [
247
-            'data' => [
248
-                'user' => [
249
-                    'friends' => [
250
-                        'edges' => [
251
-                            ['node' => ['name' => 'Nick']],
252
-                            ['node' => null],
253
-                        ],
254
-                    ],
255
-                ],
256
-            ],
257
-        ];
258
-
259
-        $this->assertResponse($this->userFriendsQuery, $expected, static::USER_ADMIN, 'access');
260
-    }
261
-
262
-    public function testUserAccessToUserFriendsAsArray(): void
263
-    {
264
-        $expected = [
265
-            'data' => [
266
-                'user' => [
267
-                    'friendsAsArray' => [1, null, 3],
268
-                ],
269
-            ],
270
-        ];
271
-
272
-        $this->assertResponse('query { user { friendsAsArray } }', $expected, static::USER_ADMIN, 'access');
273
-    }
274
-
275
-    public function testMutationAllowedUser(): void
276
-    {
277
-        $result = 123;
278
-
279
-        $expected = [
280
-            'data' => [
281
-                'simpleMutationWithThunkFields' => [
282
-                    'result' => $result,
283
-                    'clientMutationId' => 'bac',
284
-                ],
285
-            ],
286
-        ];
287
-
288
-        $this->assertResponse(sprintf($this->simpleMutationWithThunkQuery, $result), $expected, static::USER_ADMIN, 'access');
289
-        $this->assertTrue(SimpleMutationWithThunkFieldsMutation::hasMutate(true));
290
-    }
291
-
292
-    public function testMutationAllowedButNoRightsToDisplayPayload(): void
293
-    {
294
-        $expected = [
295
-            'data' => [
296
-                'simpleMutationWithThunkFields' => [
297
-                    'result' => null,
298
-                    'clientMutationId' => 'bac',
299
-                ],
300
-            ],
301
-            'extensions' => [
302
-                'warnings' => [
303
-                    [
304
-                        'message' => 'Access denied to this field.',
305
-                        'extensions' => ['category' => 'user'],
306
-                        'locations' => [
307
-                            [
308
-                                'line' => 3,
309
-                                'column' => 5,
310
-                            ],
311
-                        ],
312
-                        'path' => ['simpleMutationWithThunkFields', 'result'],
313
-                    ],
314
-                ],
315
-            ],
316
-        ];
317
-
318
-        $this->assertResponse(sprintf($this->simpleMutationWithThunkQuery, 321), $expected, static::USER_ADMIN, 'access');
319
-        $this->assertTrue(SimpleMutationWithThunkFieldsMutation::hasMutate(true));
320
-    }
321
-
322
-    public function testMutationNotAllowedUser(): void
323
-    {
324
-        $expected = [
325
-            'errors' => [
326
-                [
327
-                    'message' => 'Access denied to this field.',
328
-                    'extensions' => ['category' => 'user'],
329
-                    'locations' => [
330
-                        [
331
-                            'line' => 2,
332
-                            'column' => 3,
333
-                        ],
334
-                    ],
335
-                    'path' => ['simpleMutationWithThunkFields'],
336
-                ],
337
-            ],
338
-            'data' => [
339
-                'simpleMutationWithThunkFields' => null,
340
-            ],
341
-        ];
342
-
343
-        $this->assertResponse(sprintf($this->simpleMutationWithThunkQuery, 123), $expected, static::USER_RYAN, 'access');
344
-        $this->assertFalse(SimpleMutationWithThunkFieldsMutation::hasMutate(true));
345
-    }
346
-
347
-    private function expectedFailedUserRoles(): array
348
-    {
349
-        return [
350
-            'data' => [
351
-                'user' => [
352
-                    'roles' => null,
353
-                ],
354
-            ],
355
-            'extensions' => [
356
-                'warnings' => [
357
-                    [
358
-                        'message' => 'Access denied to this field.',
359
-                        'extensions' => ['category' => 'user'],
360
-                        'locations' => [
361
-                            [
362
-                                'line' => 1,
363
-                                'column' => 16,
364
-                            ],
365
-                        ],
366
-                        'path' => [
367
-                            'user',
368
-                            'roles',
369
-                        ],
370
-                    ],
371
-                ],
372
-            ],
373
-        ];
374
-    }
375
-}
Please login to merge, or discard this patch.
Spacing   -347 removed lines patch added patch discarded remove patch
@@ -26,350 +26,3 @@
 block discarded – undo
26 26
     private string $userIsEnabledQuery = 'query ($hasAccess: Boolean = true) { user { isEnabled(hasAccess: $hasAccess) } }';
27 27
 
28 28
     private string $userFriendsQuery = <<<'QUERY'
29
-        query {
30
-          user {
31
-            friends(first: 2) {
32
-              edges {
33
-                node {
34
-                  name
35
-                }
36
-              }
37
-            }
38
-          }
39
-        }
40
-        QUERY;
41
-
42
-    private string $simpleMutationWithThunkQuery = <<<'MUTATION'
43
-        mutation M {
44
-          simpleMutationWithThunkFields(input: {inputData: %d, clientMutationId: "bac"}) {
45
-            result
46
-            clientMutationId
47
-          }
48
-        }
49
-        MUTATION;
50
-
51
-    public function setUp(): void
52
-    {
53
-        parent::setUp();
54
-        // load types
55
-        $this->loader = function ($class): void {
56
-            if (preg_match('@^'.preg_quote('Overblog\GraphQLBundle\Access\__DEFINITIONS__\\').'(.*)$@', $class, $matches)) {
57
-                $file = sys_get_temp_dir().'/OverblogGraphQLBundle/'.Kernel::VERSION.'/access/cache/testaccess/overblog/graphql-bundle/__definitions__/'.$matches[1].'.php';
58
-                if (file_exists($file)) {
59
-                    require $file;
60
-                }
61
-            }
62
-        };
63
-        spl_autoload_register($this->loader);
64
-    }
65
-
66
-    public function testCustomClassLoaderNotRegister(): void
67
-    {
68
-        $this->expectException(Error::class);
69
-        if ((int) phpversion() <= 7) {
70
-            $this->expectExceptionMessage('Class \'Overblog\GraphQLBundle\Access\__DEFINITIONS__\RootQueryType\' not found');
71
-        } else {
72
-            $this->expectExceptionMessage('Class "Overblog\GraphQLBundle\Access\__DEFINITIONS__\RootQueryType" not found');
73
-        }
74
-        spl_autoload_unregister($this->loader);
75
-        $this->assertResponse($this->userNameQuery, [], static::ANONYMOUS_USER, 'access');
76
-    }
77
-
78
-    public function testNotAuthenticatedUserAccessAsPromisedFulfilledTrue(): void
79
-    {
80
-        $this->assertResponse(
81
-            $this->userIsEnabledQuery,
82
-            ['data' => ['user' => ['isEnabled' => true]]],
83
-            static::ANONYMOUS_USER,
84
-            'access'
85
-        );
86
-    }
87
-
88
-    public function testNotAuthenticatedUserAccessAsPromisedFulfilledFalse(): void
89
-    {
90
-        $this->assertResponse(
91
-            $this->userIsEnabledQuery,
92
-            [
93
-                'data' => [
94
-                    'user' => [
95
-                        'isEnabled' => null,
96
-                    ],
97
-                ],
98
-                'extensions' => [
99
-                    'warnings' => [
100
-                        [
101
-                            'message' => 'Access denied to this field.',
102
-                            'extensions' => ['category' => 'user'],
103
-                            'locations' => [['line' => 1, 'column' => 45]],
104
-                            'path' => ['user', 'isEnabled'],
105
-                        ],
106
-                    ],
107
-                ],
108
-            ],
109
-            static::ANONYMOUS_USER,
110
-            'access',
111
-            '',
112
-            ['hasAccess' => false]
113
-        );
114
-    }
115
-
116
-    public function testNotAuthenticatedUserAccessToUserName(): void
117
-    {
118
-        $expected = [
119
-            'data' => [
120
-                'user' => [
121
-                    'name' => null,
122
-                ],
123
-            ],
124
-            'extensions' => [
125
-                'warnings' => [
126
-                    [
127
-                        'message' => 'Access denied to this field.',
128
-                        'extensions' => ['category' => 'user'],
129
-                        'locations' => [['line' => 1, 'column' => 16]],
130
-                        'path' => ['user', 'name'],
131
-                    ],
132
-                ],
133
-            ],
134
-        ];
135
-
136
-        $this->assertResponse($this->userNameQuery, $expected, static::ANONYMOUS_USER, 'access');
137
-    }
138
-
139
-    public function testNonAuthenticatedUserAccessSecuredFieldWhichInitiallyResolvesToArray(): void
140
-    {
141
-        $expected = [
142
-            'data' => [
143
-                'youShallNotSeeThisUnauthenticated' => null,
144
-            ],
145
-            'extensions' => [
146
-                'warnings' => [
147
-                    [
148
-                        'message' => 'Access denied to this field.',
149
-                        'extensions' => ['category' => 'user'],
150
-                        'locations' => [
151
-                            [
152
-                                'line' => 2,
153
-                                'column' => 3,
154
-                            ],
155
-                        ],
156
-                        'path' => ['youShallNotSeeThisUnauthenticated'],
157
-                    ],
158
-                ],
159
-            ],
160
-        ];
161
-
162
-        $query = <<<'QUERY'
163
-            {
164
-              youShallNotSeeThisUnauthenticated {
165
-                secretValue
166
-                youAreAuthenticated
167
-              }
168
-            }
169
-            QUERY;
170
-
171
-        $this->assertResponse($query, $expected, static::ANONYMOUS_USER, 'access');
172
-    }
173
-
174
-    public function testFullyAuthenticatedUserAccessToUserName(): void
175
-    {
176
-        $expected = [
177
-            'data' => [
178
-                'user' => [
179
-                    'name' => 'Dan',
180
-                ],
181
-            ],
182
-        ];
183
-
184
-        $this->assertResponse($this->userNameQuery, $expected, static::USER_RYAN, 'access');
185
-    }
186
-
187
-    public function testNotAuthenticatedUserAccessToUserRoles(): void
188
-    {
189
-        $this->assertResponse($this->userRolesQuery, $this->expectedFailedUserRoles(), static::ANONYMOUS_USER, 'access');
190
-    }
191
-
192
-    public function testAuthenticatedUserAccessToUserRolesWithoutEnoughRights(): void
193
-    {
194
-        $this->assertResponse($this->userRolesQuery, $this->expectedFailedUserRoles(), static::USER_RYAN, 'access');
195
-    }
196
-
197
-    public function testUserWithCorrectRightsAccessToUserRoles(): void
198
-    {
199
-        $expected = [
200
-            'data' => [
201
-                'user' => [
202
-                    'roles' => ['ROLE_USER'],
203
-                ],
204
-            ],
205
-        ];
206
-
207
-        $this->assertResponse($this->userRolesQuery, $expected, static::USER_ADMIN, 'access');
208
-    }
209
-
210
-    public function testUserForbiddenField(): void
211
-    {
212
-        $expected = [
213
-            'data' => [
214
-                'user' => null,
215
-            ],
216
-            'extensions' => [
217
-                'warnings' => [
218
-                    [
219
-                        'message' => 'Access denied to this field.',
220
-                        'extensions' => ['category' => 'user'],
221
-                        'locations' => [
222
-                            [
223
-                                'line' => 3,
224
-                                'column' => 5,
225
-                            ],
226
-                        ],
227
-                        'path' => ['user', 'forbidden'],
228
-                    ],
229
-                ],
230
-            ],
231
-        ];
232
-
233
-        $query = <<<'QUERY'
234
-            query MyQuery {
235
-              user {
236
-                forbidden
237
-              }
238
-            }
239
-            QUERY;
240
-
241
-        $this->assertResponse($query, $expected, static::USER_ADMIN, 'access');
242
-    }
243
-
244
-    public function testUserAccessToUserFriends(): void
245
-    {
246
-        $expected = [
247
-            'data' => [
248
-                'user' => [
249
-                    'friends' => [
250
-                        'edges' => [
251
-                            ['node' => ['name' => 'Nick']],
252
-                            ['node' => null],
253
-                        ],
254
-                    ],
255
-                ],
256
-            ],
257
-        ];
258
-
259
-        $this->assertResponse($this->userFriendsQuery, $expected, static::USER_ADMIN, 'access');
260
-    }
261
-
262
-    public function testUserAccessToUserFriendsAsArray(): void
263
-    {
264
-        $expected = [
265
-            'data' => [
266
-                'user' => [
267
-                    'friendsAsArray' => [1, null, 3],
268
-                ],
269
-            ],
270
-        ];
271
-
272
-        $this->assertResponse('query { user { friendsAsArray } }', $expected, static::USER_ADMIN, 'access');
273
-    }
274
-
275
-    public function testMutationAllowedUser(): void
276
-    {
277
-        $result = 123;
278
-
279
-        $expected = [
280
-            'data' => [
281
-                'simpleMutationWithThunkFields' => [
282
-                    'result' => $result,
283
-                    'clientMutationId' => 'bac',
284
-                ],
285
-            ],
286
-        ];
287
-
288
-        $this->assertResponse(sprintf($this->simpleMutationWithThunkQuery, $result), $expected, static::USER_ADMIN, 'access');
289
-        $this->assertTrue(SimpleMutationWithThunkFieldsMutation::hasMutate(true));
290
-    }
291
-
292
-    public function testMutationAllowedButNoRightsToDisplayPayload(): void
293
-    {
294
-        $expected = [
295
-            'data' => [
296
-                'simpleMutationWithThunkFields' => [
297
-                    'result' => null,
298
-                    'clientMutationId' => 'bac',
299
-                ],
300
-            ],
301
-            'extensions' => [
302
-                'warnings' => [
303
-                    [
304
-                        'message' => 'Access denied to this field.',
305
-                        'extensions' => ['category' => 'user'],
306
-                        'locations' => [
307
-                            [
308
-                                'line' => 3,
309
-                                'column' => 5,
310
-                            ],
311
-                        ],
312
-                        'path' => ['simpleMutationWithThunkFields', 'result'],
313
-                    ],
314
-                ],
315
-            ],
316
-        ];
317
-
318
-        $this->assertResponse(sprintf($this->simpleMutationWithThunkQuery, 321), $expected, static::USER_ADMIN, 'access');
319
-        $this->assertTrue(SimpleMutationWithThunkFieldsMutation::hasMutate(true));
320
-    }
321
-
322
-    public function testMutationNotAllowedUser(): void
323
-    {
324
-        $expected = [
325
-            'errors' => [
326
-                [
327
-                    'message' => 'Access denied to this field.',
328
-                    'extensions' => ['category' => 'user'],
329
-                    'locations' => [
330
-                        [
331
-                            'line' => 2,
332
-                            'column' => 3,
333
-                        ],
334
-                    ],
335
-                    'path' => ['simpleMutationWithThunkFields'],
336
-                ],
337
-            ],
338
-            'data' => [
339
-                'simpleMutationWithThunkFields' => null,
340
-            ],
341
-        ];
342
-
343
-        $this->assertResponse(sprintf($this->simpleMutationWithThunkQuery, 123), $expected, static::USER_RYAN, 'access');
344
-        $this->assertFalse(SimpleMutationWithThunkFieldsMutation::hasMutate(true));
345
-    }
346
-
347
-    private function expectedFailedUserRoles(): array
348
-    {
349
-        return [
350
-            'data' => [
351
-                'user' => [
352
-                    'roles' => null,
353
-                ],
354
-            ],
355
-            'extensions' => [
356
-                'warnings' => [
357
-                    [
358
-                        'message' => 'Access denied to this field.',
359
-                        'extensions' => ['category' => 'user'],
360
-                        'locations' => [
361
-                            [
362
-                                'line' => 1,
363
-                                'column' => 16,
364
-                            ],
365
-                        ],
366
-                        'path' => [
367
-                            'user',
368
-                            'roles',
369
-                        ],
370
-                    ],
371
-                ],
372
-            ],
373
-        ];
374
-    }
375
-}
Please login to merge, or discard this patch.
Braces   -347 removed lines patch added patch discarded remove patch
@@ -26,350 +26,3 @@
 block discarded – undo
26 26
     private string $userIsEnabledQuery = 'query ($hasAccess: Boolean = true) { user { isEnabled(hasAccess: $hasAccess) } }';
27 27
 
28 28
     private string $userFriendsQuery = <<<'QUERY'
29
-        query {
30
-          user {
31
-            friends(first: 2) {
32
-              edges {
33
-                node {
34
-                  name
35
-                }
36
-              }
37
-            }
38
-          }
39
-        }
40
-        QUERY;
41
-
42
-    private string $simpleMutationWithThunkQuery = <<<'MUTATION'
43
-        mutation M {
44
-          simpleMutationWithThunkFields(input: {inputData: %d, clientMutationId: "bac"}) {
45
-            result
46
-            clientMutationId
47
-          }
48
-        }
49
-        MUTATION;
50
-
51
-    public function setUp(): void
52
-    {
53
-        parent::setUp();
54
-        // load types
55
-        $this->loader = function ($class): void {
56
-            if (preg_match('@^'.preg_quote('Overblog\GraphQLBundle\Access\__DEFINITIONS__\\').'(.*)$@', $class, $matches)) {
57
-                $file = sys_get_temp_dir().'/OverblogGraphQLBundle/'.Kernel::VERSION.'/access/cache/testaccess/overblog/graphql-bundle/__definitions__/'.$matches[1].'.php';
58
-                if (file_exists($file)) {
59
-                    require $file;
60
-                }
61
-            }
62
-        };
63
-        spl_autoload_register($this->loader);
64
-    }
65
-
66
-    public function testCustomClassLoaderNotRegister(): void
67
-    {
68
-        $this->expectException(Error::class);
69
-        if ((int) phpversion() <= 7) {
70
-            $this->expectExceptionMessage('Class \'Overblog\GraphQLBundle\Access\__DEFINITIONS__\RootQueryType\' not found');
71
-        } else {
72
-            $this->expectExceptionMessage('Class "Overblog\GraphQLBundle\Access\__DEFINITIONS__\RootQueryType" not found');
73
-        }
74
-        spl_autoload_unregister($this->loader);
75
-        $this->assertResponse($this->userNameQuery, [], static::ANONYMOUS_USER, 'access');
76
-    }
77
-
78
-    public function testNotAuthenticatedUserAccessAsPromisedFulfilledTrue(): void
79
-    {
80
-        $this->assertResponse(
81
-            $this->userIsEnabledQuery,
82
-            ['data' => ['user' => ['isEnabled' => true]]],
83
-            static::ANONYMOUS_USER,
84
-            'access'
85
-        );
86
-    }
87
-
88
-    public function testNotAuthenticatedUserAccessAsPromisedFulfilledFalse(): void
89
-    {
90
-        $this->assertResponse(
91
-            $this->userIsEnabledQuery,
92
-            [
93
-                'data' => [
94
-                    'user' => [
95
-                        'isEnabled' => null,
96
-                    ],
97
-                ],
98
-                'extensions' => [
99
-                    'warnings' => [
100
-                        [
101
-                            'message' => 'Access denied to this field.',
102
-                            'extensions' => ['category' => 'user'],
103
-                            'locations' => [['line' => 1, 'column' => 45]],
104
-                            'path' => ['user', 'isEnabled'],
105
-                        ],
106
-                    ],
107
-                ],
108
-            ],
109
-            static::ANONYMOUS_USER,
110
-            'access',
111
-            '',
112
-            ['hasAccess' => false]
113
-        );
114
-    }
115
-
116
-    public function testNotAuthenticatedUserAccessToUserName(): void
117
-    {
118
-        $expected = [
119
-            'data' => [
120
-                'user' => [
121
-                    'name' => null,
122
-                ],
123
-            ],
124
-            'extensions' => [
125
-                'warnings' => [
126
-                    [
127
-                        'message' => 'Access denied to this field.',
128
-                        'extensions' => ['category' => 'user'],
129
-                        'locations' => [['line' => 1, 'column' => 16]],
130
-                        'path' => ['user', 'name'],
131
-                    ],
132
-                ],
133
-            ],
134
-        ];
135
-
136
-        $this->assertResponse($this->userNameQuery, $expected, static::ANONYMOUS_USER, 'access');
137
-    }
138
-
139
-    public function testNonAuthenticatedUserAccessSecuredFieldWhichInitiallyResolvesToArray(): void
140
-    {
141
-        $expected = [
142
-            'data' => [
143
-                'youShallNotSeeThisUnauthenticated' => null,
144
-            ],
145
-            'extensions' => [
146
-                'warnings' => [
147
-                    [
148
-                        'message' => 'Access denied to this field.',
149
-                        'extensions' => ['category' => 'user'],
150
-                        'locations' => [
151
-                            [
152
-                                'line' => 2,
153
-                                'column' => 3,
154
-                            ],
155
-                        ],
156
-                        'path' => ['youShallNotSeeThisUnauthenticated'],
157
-                    ],
158
-                ],
159
-            ],
160
-        ];
161
-
162
-        $query = <<<'QUERY'
163
-            {
164
-              youShallNotSeeThisUnauthenticated {
165
-                secretValue
166
-                youAreAuthenticated
167
-              }
168
-            }
169
-            QUERY;
170
-
171
-        $this->assertResponse($query, $expected, static::ANONYMOUS_USER, 'access');
172
-    }
173
-
174
-    public function testFullyAuthenticatedUserAccessToUserName(): void
175
-    {
176
-        $expected = [
177
-            'data' => [
178
-                'user' => [
179
-                    'name' => 'Dan',
180
-                ],
181
-            ],
182
-        ];
183
-
184
-        $this->assertResponse($this->userNameQuery, $expected, static::USER_RYAN, 'access');
185
-    }
186
-
187
-    public function testNotAuthenticatedUserAccessToUserRoles(): void
188
-    {
189
-        $this->assertResponse($this->userRolesQuery, $this->expectedFailedUserRoles(), static::ANONYMOUS_USER, 'access');
190
-    }
191
-
192
-    public function testAuthenticatedUserAccessToUserRolesWithoutEnoughRights(): void
193
-    {
194
-        $this->assertResponse($this->userRolesQuery, $this->expectedFailedUserRoles(), static::USER_RYAN, 'access');
195
-    }
196
-
197
-    public function testUserWithCorrectRightsAccessToUserRoles(): void
198
-    {
199
-        $expected = [
200
-            'data' => [
201
-                'user' => [
202
-                    'roles' => ['ROLE_USER'],
203
-                ],
204
-            ],
205
-        ];
206
-
207
-        $this->assertResponse($this->userRolesQuery, $expected, static::USER_ADMIN, 'access');
208
-    }
209
-
210
-    public function testUserForbiddenField(): void
211
-    {
212
-        $expected = [
213
-            'data' => [
214
-                'user' => null,
215
-            ],
216
-            'extensions' => [
217
-                'warnings' => [
218
-                    [
219
-                        'message' => 'Access denied to this field.',
220
-                        'extensions' => ['category' => 'user'],
221
-                        'locations' => [
222
-                            [
223
-                                'line' => 3,
224
-                                'column' => 5,
225
-                            ],
226
-                        ],
227
-                        'path' => ['user', 'forbidden'],
228
-                    ],
229
-                ],
230
-            ],
231
-        ];
232
-
233
-        $query = <<<'QUERY'
234
-            query MyQuery {
235
-              user {
236
-                forbidden
237
-              }
238
-            }
239
-            QUERY;
240
-
241
-        $this->assertResponse($query, $expected, static::USER_ADMIN, 'access');
242
-    }
243
-
244
-    public function testUserAccessToUserFriends(): void
245
-    {
246
-        $expected = [
247
-            'data' => [
248
-                'user' => [
249
-                    'friends' => [
250
-                        'edges' => [
251
-                            ['node' => ['name' => 'Nick']],
252
-                            ['node' => null],
253
-                        ],
254
-                    ],
255
-                ],
256
-            ],
257
-        ];
258
-
259
-        $this->assertResponse($this->userFriendsQuery, $expected, static::USER_ADMIN, 'access');
260
-    }
261
-
262
-    public function testUserAccessToUserFriendsAsArray(): void
263
-    {
264
-        $expected = [
265
-            'data' => [
266
-                'user' => [
267
-                    'friendsAsArray' => [1, null, 3],
268
-                ],
269
-            ],
270
-        ];
271
-
272
-        $this->assertResponse('query { user { friendsAsArray } }', $expected, static::USER_ADMIN, 'access');
273
-    }
274
-
275
-    public function testMutationAllowedUser(): void
276
-    {
277
-        $result = 123;
278
-
279
-        $expected = [
280
-            'data' => [
281
-                'simpleMutationWithThunkFields' => [
282
-                    'result' => $result,
283
-                    'clientMutationId' => 'bac',
284
-                ],
285
-            ],
286
-        ];
287
-
288
-        $this->assertResponse(sprintf($this->simpleMutationWithThunkQuery, $result), $expected, static::USER_ADMIN, 'access');
289
-        $this->assertTrue(SimpleMutationWithThunkFieldsMutation::hasMutate(true));
290
-    }
291
-
292
-    public function testMutationAllowedButNoRightsToDisplayPayload(): void
293
-    {
294
-        $expected = [
295
-            'data' => [
296
-                'simpleMutationWithThunkFields' => [
297
-                    'result' => null,
298
-                    'clientMutationId' => 'bac',
299
-                ],
300
-            ],
301
-            'extensions' => [
302
-                'warnings' => [
303
-                    [
304
-                        'message' => 'Access denied to this field.',
305
-                        'extensions' => ['category' => 'user'],
306
-                        'locations' => [
307
-                            [
308
-                                'line' => 3,
309
-                                'column' => 5,
310
-                            ],
311
-                        ],
312
-                        'path' => ['simpleMutationWithThunkFields', 'result'],
313
-                    ],
314
-                ],
315
-            ],
316
-        ];
317
-
318
-        $this->assertResponse(sprintf($this->simpleMutationWithThunkQuery, 321), $expected, static::USER_ADMIN, 'access');
319
-        $this->assertTrue(SimpleMutationWithThunkFieldsMutation::hasMutate(true));
320
-    }
321
-
322
-    public function testMutationNotAllowedUser(): void
323
-    {
324
-        $expected = [
325
-            'errors' => [
326
-                [
327
-                    'message' => 'Access denied to this field.',
328
-                    'extensions' => ['category' => 'user'],
329
-                    'locations' => [
330
-                        [
331
-                            'line' => 2,
332
-                            'column' => 3,
333
-                        ],
334
-                    ],
335
-                    'path' => ['simpleMutationWithThunkFields'],
336
-                ],
337
-            ],
338
-            'data' => [
339
-                'simpleMutationWithThunkFields' => null,
340
-            ],
341
-        ];
342
-
343
-        $this->assertResponse(sprintf($this->simpleMutationWithThunkQuery, 123), $expected, static::USER_RYAN, 'access');
344
-        $this->assertFalse(SimpleMutationWithThunkFieldsMutation::hasMutate(true));
345
-    }
346
-
347
-    private function expectedFailedUserRoles(): array
348
-    {
349
-        return [
350
-            'data' => [
351
-                'user' => [
352
-                    'roles' => null,
353
-                ],
354
-            ],
355
-            'extensions' => [
356
-                'warnings' => [
357
-                    [
358
-                        'message' => 'Access denied to this field.',
359
-                        'extensions' => ['category' => 'user'],
360
-                        'locations' => [
361
-                            [
362
-                                'line' => 1,
363
-                                'column' => 16,
364
-                            ],
365
-                        ],
366
-                        'path' => [
367
-                            'user',
368
-                            'roles',
369
-                        ],
370
-                    ],
371
-                ],
372
-            ],
373
-        ];
374
-    }
375
-}
Please login to merge, or discard this patch.
Upper-Lower-Casing   -347 removed lines patch added patch discarded remove patch
@@ -26,350 +26,3 @@
 block discarded – undo
26 26
     private string $userIsEnabledQuery = 'query ($hasAccess: Boolean = true) { user { isEnabled(hasAccess: $hasAccess) } }';
27 27
 
28 28
     private string $userFriendsQuery = <<<'QUERY'
29
-        query {
30
-          user {
31
-            friends(first: 2) {
32
-              edges {
33
-                node {
34
-                  name
35
-                }
36
-              }
37
-            }
38
-          }
39
-        }
40
-        QUERY;
41
-
42
-    private string $simpleMutationWithThunkQuery = <<<'MUTATION'
43
-        mutation M {
44
-          simpleMutationWithThunkFields(input: {inputData: %d, clientMutationId: "bac"}) {
45
-            result
46
-            clientMutationId
47
-          }
48
-        }
49
-        MUTATION;
50
-
51
-    public function setUp(): void
52
-    {
53
-        parent::setUp();
54
-        // load types
55
-        $this->loader = function ($class): void {
56
-            if (preg_match('@^'.preg_quote('Overblog\GraphQLBundle\Access\__DEFINITIONS__\\').'(.*)$@', $class, $matches)) {
57
-                $file = sys_get_temp_dir().'/OverblogGraphQLBundle/'.Kernel::VERSION.'/access/cache/testaccess/overblog/graphql-bundle/__definitions__/'.$matches[1].'.php';
58
-                if (file_exists($file)) {
59
-                    require $file;
60
-                }
61
-            }
62
-        };
63
-        spl_autoload_register($this->loader);
64
-    }
65
-
66
-    public function testCustomClassLoaderNotRegister(): void
67
-    {
68
-        $this->expectException(Error::class);
69
-        if ((int) phpversion() <= 7) {
70
-            $this->expectExceptionMessage('Class \'Overblog\GraphQLBundle\Access\__DEFINITIONS__\RootQueryType\' not found');
71
-        } else {
72
-            $this->expectExceptionMessage('Class "Overblog\GraphQLBundle\Access\__DEFINITIONS__\RootQueryType" not found');
73
-        }
74
-        spl_autoload_unregister($this->loader);
75
-        $this->assertResponse($this->userNameQuery, [], static::ANONYMOUS_USER, 'access');
76
-    }
77
-
78
-    public function testNotAuthenticatedUserAccessAsPromisedFulfilledTrue(): void
79
-    {
80
-        $this->assertResponse(
81
-            $this->userIsEnabledQuery,
82
-            ['data' => ['user' => ['isEnabled' => true]]],
83
-            static::ANONYMOUS_USER,
84
-            'access'
85
-        );
86
-    }
87
-
88
-    public function testNotAuthenticatedUserAccessAsPromisedFulfilledFalse(): void
89
-    {
90
-        $this->assertResponse(
91
-            $this->userIsEnabledQuery,
92
-            [
93
-                'data' => [
94
-                    'user' => [
95
-                        'isEnabled' => null,
96
-                    ],
97
-                ],
98
-                'extensions' => [
99
-                    'warnings' => [
100
-                        [
101
-                            'message' => 'Access denied to this field.',
102
-                            'extensions' => ['category' => 'user'],
103
-                            'locations' => [['line' => 1, 'column' => 45]],
104
-                            'path' => ['user', 'isEnabled'],
105
-                        ],
106
-                    ],
107
-                ],
108
-            ],
109
-            static::ANONYMOUS_USER,
110
-            'access',
111
-            '',
112
-            ['hasAccess' => false]
113
-        );
114
-    }
115
-
116
-    public function testNotAuthenticatedUserAccessToUserName(): void
117
-    {
118
-        $expected = [
119
-            'data' => [
120
-                'user' => [
121
-                    'name' => null,
122
-                ],
123
-            ],
124
-            'extensions' => [
125
-                'warnings' => [
126
-                    [
127
-                        'message' => 'Access denied to this field.',
128
-                        'extensions' => ['category' => 'user'],
129
-                        'locations' => [['line' => 1, 'column' => 16]],
130
-                        'path' => ['user', 'name'],
131
-                    ],
132
-                ],
133
-            ],
134
-        ];
135
-
136
-        $this->assertResponse($this->userNameQuery, $expected, static::ANONYMOUS_USER, 'access');
137
-    }
138
-
139
-    public function testNonAuthenticatedUserAccessSecuredFieldWhichInitiallyResolvesToArray(): void
140
-    {
141
-        $expected = [
142
-            'data' => [
143
-                'youShallNotSeeThisUnauthenticated' => null,
144
-            ],
145
-            'extensions' => [
146
-                'warnings' => [
147
-                    [
148
-                        'message' => 'Access denied to this field.',
149
-                        'extensions' => ['category' => 'user'],
150
-                        'locations' => [
151
-                            [
152
-                                'line' => 2,
153
-                                'column' => 3,
154
-                            ],
155
-                        ],
156
-                        'path' => ['youShallNotSeeThisUnauthenticated'],
157
-                    ],
158
-                ],
159
-            ],
160
-        ];
161
-
162
-        $query = <<<'QUERY'
163
-            {
164
-              youShallNotSeeThisUnauthenticated {
165
-                secretValue
166
-                youAreAuthenticated
167
-              }
168
-            }
169
-            QUERY;
170
-
171
-        $this->assertResponse($query, $expected, static::ANONYMOUS_USER, 'access');
172
-    }
173
-
174
-    public function testFullyAuthenticatedUserAccessToUserName(): void
175
-    {
176
-        $expected = [
177
-            'data' => [
178
-                'user' => [
179
-                    'name' => 'Dan',
180
-                ],
181
-            ],
182
-        ];
183
-
184
-        $this->assertResponse($this->userNameQuery, $expected, static::USER_RYAN, 'access');
185
-    }
186
-
187
-    public function testNotAuthenticatedUserAccessToUserRoles(): void
188
-    {
189
-        $this->assertResponse($this->userRolesQuery, $this->expectedFailedUserRoles(), static::ANONYMOUS_USER, 'access');
190
-    }
191
-
192
-    public function testAuthenticatedUserAccessToUserRolesWithoutEnoughRights(): void
193
-    {
194
-        $this->assertResponse($this->userRolesQuery, $this->expectedFailedUserRoles(), static::USER_RYAN, 'access');
195
-    }
196
-
197
-    public function testUserWithCorrectRightsAccessToUserRoles(): void
198
-    {
199
-        $expected = [
200
-            'data' => [
201
-                'user' => [
202
-                    'roles' => ['ROLE_USER'],
203
-                ],
204
-            ],
205
-        ];
206
-
207
-        $this->assertResponse($this->userRolesQuery, $expected, static::USER_ADMIN, 'access');
208
-    }
209
-
210
-    public function testUserForbiddenField(): void
211
-    {
212
-        $expected = [
213
-            'data' => [
214
-                'user' => null,
215
-            ],
216
-            'extensions' => [
217
-                'warnings' => [
218
-                    [
219
-                        'message' => 'Access denied to this field.',
220
-                        'extensions' => ['category' => 'user'],
221
-                        'locations' => [
222
-                            [
223
-                                'line' => 3,
224
-                                'column' => 5,
225
-                            ],
226
-                        ],
227
-                        'path' => ['user', 'forbidden'],
228
-                    ],
229
-                ],
230
-            ],
231
-        ];
232
-
233
-        $query = <<<'QUERY'
234
-            query MyQuery {
235
-              user {
236
-                forbidden
237
-              }
238
-            }
239
-            QUERY;
240
-
241
-        $this->assertResponse($query, $expected, static::USER_ADMIN, 'access');
242
-    }
243
-
244
-    public function testUserAccessToUserFriends(): void
245
-    {
246
-        $expected = [
247
-            'data' => [
248
-                'user' => [
249
-                    'friends' => [
250
-                        'edges' => [
251
-                            ['node' => ['name' => 'Nick']],
252
-                            ['node' => null],
253
-                        ],
254
-                    ],
255
-                ],
256
-            ],
257
-        ];
258
-
259
-        $this->assertResponse($this->userFriendsQuery, $expected, static::USER_ADMIN, 'access');
260
-    }
261
-
262
-    public function testUserAccessToUserFriendsAsArray(): void
263
-    {
264
-        $expected = [
265
-            'data' => [
266
-                'user' => [
267
-                    'friendsAsArray' => [1, null, 3],
268
-                ],
269
-            ],
270
-        ];
271
-
272
-        $this->assertResponse('query { user { friendsAsArray } }', $expected, static::USER_ADMIN, 'access');
273
-    }
274
-
275
-    public function testMutationAllowedUser(): void
276
-    {
277
-        $result = 123;
278
-
279
-        $expected = [
280
-            'data' => [
281
-                'simpleMutationWithThunkFields' => [
282
-                    'result' => $result,
283
-                    'clientMutationId' => 'bac',
284
-                ],
285
-            ],
286
-        ];
287
-
288
-        $this->assertResponse(sprintf($this->simpleMutationWithThunkQuery, $result), $expected, static::USER_ADMIN, 'access');
289
-        $this->assertTrue(SimpleMutationWithThunkFieldsMutation::hasMutate(true));
290
-    }
291
-
292
-    public function testMutationAllowedButNoRightsToDisplayPayload(): void
293
-    {
294
-        $expected = [
295
-            'data' => [
296
-                'simpleMutationWithThunkFields' => [
297
-                    'result' => null,
298
-                    'clientMutationId' => 'bac',
299
-                ],
300
-            ],
301
-            'extensions' => [
302
-                'warnings' => [
303
-                    [
304
-                        'message' => 'Access denied to this field.',
305
-                        'extensions' => ['category' => 'user'],
306
-                        'locations' => [
307
-                            [
308
-                                'line' => 3,
309
-                                'column' => 5,
310
-                            ],
311
-                        ],
312
-                        'path' => ['simpleMutationWithThunkFields', 'result'],
313
-                    ],
314
-                ],
315
-            ],
316
-        ];
317
-
318
-        $this->assertResponse(sprintf($this->simpleMutationWithThunkQuery, 321), $expected, static::USER_ADMIN, 'access');
319
-        $this->assertTrue(SimpleMutationWithThunkFieldsMutation::hasMutate(true));
320
-    }
321
-
322
-    public function testMutationNotAllowedUser(): void
323
-    {
324
-        $expected = [
325
-            'errors' => [
326
-                [
327
-                    'message' => 'Access denied to this field.',
328
-                    'extensions' => ['category' => 'user'],
329
-                    'locations' => [
330
-                        [
331
-                            'line' => 2,
332
-                            'column' => 3,
333
-                        ],
334
-                    ],
335
-                    'path' => ['simpleMutationWithThunkFields'],
336
-                ],
337
-            ],
338
-            'data' => [
339
-                'simpleMutationWithThunkFields' => null,
340
-            ],
341
-        ];
342
-
343
-        $this->assertResponse(sprintf($this->simpleMutationWithThunkQuery, 123), $expected, static::USER_RYAN, 'access');
344
-        $this->assertFalse(SimpleMutationWithThunkFieldsMutation::hasMutate(true));
345
-    }
346
-
347
-    private function expectedFailedUserRoles(): array
348
-    {
349
-        return [
350
-            'data' => [
351
-                'user' => [
352
-                    'roles' => null,
353
-                ],
354
-            ],
355
-            'extensions' => [
356
-                'warnings' => [
357
-                    [
358
-                        'message' => 'Access denied to this field.',
359
-                        'extensions' => ['category' => 'user'],
360
-                        'locations' => [
361
-                            [
362
-                                'line' => 1,
363
-                                'column' => 16,
364
-                            ],
365
-                        ],
366
-                        'path' => [
367
-                            'user',
368
-                            'roles',
369
-                        ],
370
-                    ],
371
-                ],
372
-            ],
373
-        ];
374
-    }
375
-}
Please login to merge, or discard this patch.