We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
17 | class AccessTest extends TestCase |
||
18 | { |
||
19 | const USER_RYAN = 'ryan'; |
||
20 | const USER_ADMIN = 'admin'; |
||
21 | const ANONYMOUS_USER = null; |
||
22 | |||
23 | private $userNameQuery = 'query MyQuery { user { name } }'; |
||
24 | |||
25 | private $userRolesQuery = 'query MyQuery { user { roles } }'; |
||
26 | |||
27 | private $userIsEnabledQuery = 'query MyQuery { user { isEnabled } }'; |
||
|
|||
28 | |||
29 | private $userFriendsQuery = <<<EOF |
||
30 | query MyQuery { |
||
31 | user { |
||
32 | friends(first: 2) { |
||
33 | edges { |
||
34 | node { |
||
35 | name |
||
36 | } |
||
37 | } |
||
38 | } |
||
39 | } |
||
40 | } |
||
41 | EOF; |
||
42 | |||
43 | private $simpleMutationWithThunkQuery = <<<EOF |
||
44 | mutation M { |
||
45 | simpleMutationWithThunkFields(input: {inputData: %d, clientMutationId: "bac"}) { |
||
46 | result |
||
47 | clientMutationId |
||
48 | } |
||
49 | } |
||
50 | EOF; |
||
51 | |||
52 | View Code Duplication | public function testNotAuthenticatedUserAccessToUserName() |
|
72 | |||
73 | public function testFullyAuthenticatedUserAccessToUserName() |
||
85 | |||
86 | public function testNotAuthenticatedUserAccessToUserRoles() |
||
90 | |||
91 | public function testAuthenticatedUserAccessToUserRolesWithoutEnoughRights() |
||
95 | |||
96 | public function testUserWithCorrectRightsAccessToUserRoles() |
||
108 | |||
109 | View Code Duplication | public function testUserForbiddenField() |
|
110 | { |
||
111 | $expected = [ |
||
112 | 'data' => [ |
||
113 | 'user' => null, |
||
114 | ], |
||
115 | 'extensions' => [ |
||
116 | 'warnings' => [ |
||
117 | [ |
||
118 | 'message' => 'Access denied to this field.', |
||
119 | 'locations' => [ |
||
120 | [ |
||
121 | 'line' => 3, |
||
122 | 'column' => 5, |
||
123 | ], |
||
124 | ], |
||
125 | ], |
||
126 | ], |
||
127 | ], |
||
128 | ]; |
||
129 | |||
130 | $query = <<<EOF |
||
131 | query MyQuery { |
||
132 | user { |
||
133 | forbidden |
||
134 | } |
||
135 | } |
||
136 | EOF; |
||
137 | |||
138 | $this->assertResponse($query, $expected, static::USER_ADMIN); |
||
139 | } |
||
140 | |||
141 | public function testUserAccessToUserFriends() |
||
158 | |||
159 | public function testMutationAllowedUser() |
||
175 | |||
176 | public function testMutationAllowedButNoRightsToDisplayPayload() |
||
203 | |||
204 | public function testMutationNotAllowedUser() |
||
226 | |||
227 | private function expectedFailedUserRoles() |
||
237 | |||
238 | View Code Duplication | private static function assertResponse($query, array $expected, $username) |
|
249 | |||
250 | private static function createClientAuthenticated($username) |
||
263 | } |
||
264 |
This check marks private properties in classes that are never used. Those properties can be removed.