1 | <?php declare(strict_types = 1); |
||
23 | trait ApiTestCase |
||
24 | { |
||
25 | /** |
||
26 | * @var ApiTestClient |
||
27 | */ |
||
28 | protected $client; |
||
29 | |||
30 | /** |
||
31 | * @var SchemaValidator |
||
32 | */ |
||
33 | private $validator; |
||
34 | |||
35 | /** |
||
36 | */ |
||
37 | protected function setUp() |
||
41 | |||
42 | /** |
||
43 | * Create a client, booting the kernel using SYMFONY_ENV = $this->env |
||
44 | */ |
||
45 | protected function createApiTestClient() |
||
54 | |||
55 | /** |
||
56 | * @return array |
||
57 | */ |
||
58 | protected function getDefaultServerVars(): array |
||
62 | |||
63 | /** |
||
64 | * @return string |
||
65 | */ |
||
66 | protected function getEnv(): string |
||
70 | |||
71 | /** |
||
72 | * @param string $path |
||
73 | * @param array $params |
||
74 | * |
||
75 | * @return mixed |
||
76 | * @throws ApiResponseErrorException |
||
77 | */ |
||
78 | protected function get(string $path, array $params = []) |
||
82 | |||
83 | /** |
||
84 | * @param string $path |
||
85 | * @param array $params |
||
86 | * |
||
87 | * @return mixed |
||
88 | * @throws ApiResponseErrorException |
||
89 | */ |
||
90 | protected function delete(string $path, array $params = []) |
||
94 | |||
95 | /** |
||
96 | * @param string $path |
||
97 | * @param array $content |
||
98 | * @param array $params |
||
99 | * |
||
100 | * @return mixed |
||
101 | * @throws ApiResponseErrorException |
||
102 | */ |
||
103 | protected function patch(string $path, array $content, array $params = []) |
||
107 | |||
108 | /** |
||
109 | * @param string $path |
||
110 | * @param array $content |
||
111 | * @param array $params |
||
112 | * |
||
113 | * @return mixed |
||
114 | * @throws ApiResponseErrorException |
||
115 | */ |
||
116 | protected function post(string $path, array $content, array $params = []) |
||
120 | |||
121 | /** |
||
122 | * @param string $path |
||
123 | * @param array $content |
||
124 | * @param array $params |
||
125 | * |
||
126 | * @return mixed |
||
127 | * @throws ApiResponseErrorException |
||
128 | */ |
||
129 | protected function put(string $path, array $content, array $params = []) |
||
133 | |||
134 | /** |
||
135 | * @param string $path |
||
136 | * @param string $method |
||
137 | * @param array $params |
||
138 | * @param array|null $content |
||
139 | * |
||
140 | * @return mixed |
||
141 | * @throws ApiResponseErrorException |
||
142 | */ |
||
143 | protected function request(string $path, string $method, array $params = [], array $content = null) |
||
183 | |||
184 | /** |
||
185 | * @return SchemaValidator |
||
186 | */ |
||
187 | protected function getValidator(): SchemaValidator |
||
191 | |||
192 | /** |
||
193 | * @param string $path |
||
194 | * @param array $params |
||
195 | * |
||
196 | * @return string |
||
197 | */ |
||
198 | private function assembleUri(string $path, array $params = []) |
||
207 | |||
208 | /** |
||
209 | * @param mixed $expected |
||
210 | * @param mixed $actual |
||
211 | * @param string $message |
||
212 | * |
||
213 | * @return mixed |
||
214 | */ |
||
215 | abstract public function assertSame($expected, $actual, $message = ''); |
||
216 | } |
||
217 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.