1 | <?php |
||
29 | trait ApiTestCase |
||
30 | { |
||
31 | use AssertsTrait; |
||
32 | |||
33 | /** |
||
34 | * @var SchemaManager |
||
35 | */ |
||
36 | protected static $schemaManager; |
||
37 | |||
38 | /** |
||
39 | * @var SwaggerDocument |
||
40 | */ |
||
41 | protected static $document; |
||
42 | |||
43 | /** |
||
44 | * @var ApiTestClient |
||
45 | */ |
||
46 | protected $client; |
||
47 | |||
48 | /** |
||
49 | * PHPUnit cannot add this to code coverage |
||
50 | * |
||
51 | * @codeCoverageIgnore |
||
52 | * |
||
53 | * @param string $swaggerPath |
||
54 | * |
||
55 | * @throws \InvalidArgumentException |
||
56 | * @throws \org\bovigo\vfs\vfsStreamException |
||
57 | */ |
||
58 | public static function initSchemaManager($swaggerPath) |
||
84 | |||
85 | /** |
||
86 | * Create a client, booting the kernel using SYMFONY_ENV = $this->env |
||
87 | */ |
||
88 | protected function setUp() |
||
94 | |||
95 | /** |
||
96 | * @return array |
||
97 | */ |
||
98 | protected function getDefaultServerVars() |
||
102 | |||
103 | /** |
||
104 | * @return array |
||
105 | */ |
||
106 | protected function getEnv() |
||
110 | |||
111 | /** |
||
112 | * @return bool |
||
113 | */ |
||
114 | protected function getValidateErrorResponse() |
||
118 | |||
119 | /** |
||
120 | * @param string $path |
||
121 | * @param array $params |
||
122 | * |
||
123 | * @return object |
||
124 | * @throws ApiResponseErrorException |
||
125 | */ |
||
126 | protected function get($path, array $params = []) |
||
130 | |||
131 | /** |
||
132 | * @param string $path |
||
133 | * @param array $params |
||
134 | * |
||
135 | * @return object |
||
136 | * @throws ApiResponseErrorException |
||
137 | */ |
||
138 | protected function delete($path, array $params = []) |
||
142 | |||
143 | /** |
||
144 | * @param string $path |
||
145 | * @param array $content |
||
146 | * @param array $params |
||
147 | * |
||
148 | * @return object |
||
149 | * @throws ApiResponseErrorException |
||
150 | */ |
||
151 | protected function patch($path, array $content, array $params = []) |
||
155 | |||
156 | /** |
||
157 | * @param string $path |
||
158 | * @param array $content |
||
159 | * @param array $params |
||
160 | * |
||
161 | * @return object |
||
162 | * @throws ApiResponseErrorException |
||
163 | */ |
||
164 | protected function post($path, array $content, array $params = []) |
||
168 | |||
169 | /** |
||
170 | * @param string $path |
||
171 | * @param array $content |
||
172 | * @param array $params |
||
173 | * |
||
174 | * @return object |
||
175 | * @throws ApiResponseErrorException |
||
176 | */ |
||
177 | protected function put($path, array $content, array $params = []) |
||
181 | |||
182 | /** |
||
183 | * @param string $path |
||
184 | * @param string $method |
||
185 | * @param array $params |
||
186 | * @param array|null $content |
||
187 | * |
||
188 | * @return object |
||
189 | * @throws ApiResponseErrorException |
||
190 | */ |
||
191 | protected function sendRequest($path, $method, array $params = [], array $content = null) |
||
202 | |||
203 | /** |
||
204 | * @param string $path |
||
205 | * @param array $params |
||
206 | * |
||
207 | * @return string |
||
208 | */ |
||
209 | private function assembleUri($path, array $params = []) |
||
218 | |||
219 | /** |
||
220 | * @param string $fullPath |
||
221 | * @param string $method |
||
222 | * |
||
223 | * @return object|null |
||
224 | * @throws ApiResponseErrorException |
||
225 | */ |
||
226 | private function getJsonForLastRequest($fullPath, $method) |
||
263 | |||
264 | /** |
||
265 | * @param $code |
||
266 | * @param Response $response |
||
267 | * @param string $method |
||
268 | * @param string $fullPath |
||
269 | * @param mixed $data |
||
270 | */ |
||
271 | private function validateResponse($code, $response, $method, $fullPath, $data) |
||
309 | |||
310 | /** |
||
311 | * @param mixed $expected |
||
312 | * @param mixed $actual |
||
313 | * @param string $message |
||
314 | * |
||
315 | * @return mixed |
||
316 | */ |
||
317 | public abstract function assertSame($expected, $actual, $message = ''); |
||
318 | } |
||
319 |