We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ 16-88 (lines=73) @@ | ||
13 | ||
14 | use Overblog\GraphQLBundle\Tests\Functional\TestCase; |
|
15 | ||
16 | class QueryComplexityTest extends TestCase |
|
17 | { |
|
18 | private $userFriendsWithoutLimitQuery = <<<'EOF' |
|
19 | query { |
|
20 | user { |
|
21 | friends { |
|
22 | edges { |
|
23 | node { |
|
24 | name |
|
25 | } |
|
26 | } |
|
27 | } |
|
28 | } |
|
29 | } |
|
30 | EOF; |
|
31 | ||
32 | private $userFriendsWithLimitQuery = <<<'EOF' |
|
33 | query { |
|
34 | user { |
|
35 | friends(first: 1) { |
|
36 | edges { |
|
37 | node { |
|
38 | name |
|
39 | } |
|
40 | } |
|
41 | } |
|
42 | } |
|
43 | } |
|
44 | EOF; |
|
45 | ||
46 | public function testComplexityReachLimitation() |
|
47 | { |
|
48 | $expected = [ |
|
49 | 'errors' => [ |
|
50 | [ |
|
51 | 'message' => 'Max query complexity should be 10 but got 54.', |
|
52 | ], |
|
53 | ], |
|
54 | ]; |
|
55 | ||
56 | $this->assertResponse($this->userFriendsWithoutLimitQuery, $expected, self::ANONYMOUS_USER, 'queryComplexity'); |
|
57 | } |
|
58 | ||
59 | public function testComplexityReachLimitationEnv() |
|
60 | { |
|
61 | $expected = [ |
|
62 | 'errors' => [ |
|
63 | [ |
|
64 | 'message' => 'Max query complexity should be 10 but got 54.', |
|
65 | ], |
|
66 | ], |
|
67 | ]; |
|
68 | ||
69 | $this->assertResponse($this->userFriendsWithoutLimitQuery, $expected, self::ANONYMOUS_USER, 'queryComplexityEnv'); |
|
70 | } |
|
71 | ||
72 | public function testComplexityUnderLimitation() |
|
73 | { |
|
74 | $expected = [ |
|
75 | 'data' => [ |
|
76 | 'user' => [ |
|
77 | 'friends' => [ |
|
78 | 'edges' => [ |
|
79 | ['node' => ['name' => 'Nick']], |
|
80 | ], |
|
81 | ], |
|
82 | ], |
|
83 | ], |
|
84 | ]; |
|
85 | ||
86 | $this->assertResponse($this->userFriendsWithLimitQuery, $expected, self::ANONYMOUS_USER, 'queryComplexity'); |
|
87 | } |
|
88 | } |
|
89 |
@@ 16-95 (lines=80) @@ | ||
13 | ||
14 | use Overblog\GraphQLBundle\Tests\Functional\TestCase; |
|
15 | ||
16 | class QueryMaxDepthTest extends TestCase |
|
17 | { |
|
18 | private $userFriendsWithoutViolationQuery = <<<'EOF' |
|
19 | query { |
|
20 | user { |
|
21 | friends(first:1) { |
|
22 | edges { |
|
23 | node { |
|
24 | name |
|
25 | } |
|
26 | } |
|
27 | } |
|
28 | } |
|
29 | } |
|
30 | EOF; |
|
31 | ||
32 | private $userFriendsWithViolationQuery = <<<'EOF' |
|
33 | query { |
|
34 | user { |
|
35 | friends(first: 1) { |
|
36 | edges { |
|
37 | node { |
|
38 | name |
|
39 | friends { |
|
40 | edges { |
|
41 | node { |
|
42 | name |
|
43 | } |
|
44 | } |
|
45 | } |
|
46 | } |
|
47 | } |
|
48 | } |
|
49 | } |
|
50 | } |
|
51 | EOF; |
|
52 | ||
53 | public function testMaxDepthReachLimitation() |
|
54 | { |
|
55 | $expected = [ |
|
56 | 'errors' => [ |
|
57 | [ |
|
58 | 'message' => 'Max query depth should be 3 but got 6.', |
|
59 | ], |
|
60 | ], |
|
61 | ]; |
|
62 | ||
63 | $this->assertResponse($this->userFriendsWithViolationQuery, $expected, self::ANONYMOUS_USER, 'queryMaxDepth'); |
|
64 | } |
|
65 | ||
66 | public function testMaxDepthReachLimitationEnv() |
|
67 | { |
|
68 | $expected = [ |
|
69 | 'errors' => [ |
|
70 | [ |
|
71 | 'message' => 'Max query depth should be 3 but got 6.', |
|
72 | ], |
|
73 | ], |
|
74 | ]; |
|
75 | ||
76 | $this->assertResponse($this->userFriendsWithViolationQuery, $expected, self::ANONYMOUS_USER, 'queryMaxDepthEnv'); |
|
77 | } |
|
78 | ||
79 | public function testComplexityUnderLimitation() |
|
80 | { |
|
81 | $expected = [ |
|
82 | 'data' => [ |
|
83 | 'user' => [ |
|
84 | 'friends' => [ |
|
85 | 'edges' => [ |
|
86 | ['node' => ['name' => 'Nick']], |
|
87 | ], |
|
88 | ], |
|
89 | ], |
|
90 | ], |
|
91 | ]; |
|
92 | ||
93 | $this->assertResponse($this->userFriendsWithoutViolationQuery, $expected, self::ANONYMOUS_USER, 'queryMaxDepth'); |
|
94 | } |
|
95 | } |
|
96 |