1 | <?php |
||
25 | trait ApiTestCase |
||
26 | { |
||
27 | use AssertsTrait; |
||
28 | |||
29 | /** |
||
30 | * @var SchemaManager |
||
31 | */ |
||
32 | protected static $schemaManager; |
||
33 | |||
34 | /** |
||
35 | * @var SwaggerDocument |
||
36 | */ |
||
37 | protected static $document; |
||
38 | |||
39 | /** |
||
40 | * @var ApiTestClient |
||
41 | */ |
||
42 | protected $client; |
||
43 | |||
44 | /** |
||
45 | * PHPUnit cannot add this to code coverage |
||
46 | * |
||
47 | * @codeCoverageIgnore |
||
48 | * |
||
49 | * @param $swaggerPath |
||
50 | * |
||
51 | * @throws \InvalidArgumentException |
||
52 | * @throws \org\bovigo\vfs\vfsStreamException |
||
53 | */ |
||
54 | public static function initSchemaManager($swaggerPath) |
||
79 | |||
80 | /** |
||
81 | * Create a client, booting the kernel using SYMFONY_ENV = $this->env |
||
82 | */ |
||
83 | protected function setUp() |
||
89 | |||
90 | |||
91 | /** |
||
92 | * @param string $path |
||
93 | * @param array $params |
||
94 | * |
||
95 | * @return object |
||
96 | * @throws ApiResponseErrorException |
||
97 | */ |
||
98 | protected function get($path, array $params = []) |
||
102 | |||
103 | /** |
||
104 | * @param string $path |
||
105 | * @param array $params |
||
106 | * |
||
107 | * @return object |
||
108 | * @throws ApiResponseErrorException |
||
109 | */ |
||
110 | protected function delete($path, array $params = []) |
||
114 | |||
115 | /** |
||
116 | * @param string $path |
||
117 | * @param array $content |
||
118 | * @param array $params |
||
119 | * |
||
120 | * @return object |
||
121 | * @throws ApiResponseErrorException |
||
122 | */ |
||
123 | protected function patch($path, array $content, array $params = []) |
||
127 | |||
128 | /** |
||
129 | * @param string $path |
||
130 | * @param array $content |
||
131 | * @param array $params |
||
132 | * |
||
133 | * @return object |
||
134 | * @throws ApiResponseErrorException |
||
135 | */ |
||
136 | protected function post($path, array $content, array $params = []) |
||
140 | |||
141 | /** |
||
142 | * @param string $path |
||
143 | * @param array $content |
||
144 | * @param array $params |
||
145 | * |
||
146 | * @return object |
||
147 | * @throws ApiResponseErrorException |
||
148 | */ |
||
149 | protected function put($path, array $content, array $params = []) |
||
153 | |||
154 | /** |
||
155 | * @param string $path |
||
156 | * @param array $method |
||
157 | * @param array $params |
||
158 | * @param array|null $content |
||
159 | * |
||
160 | * @return object |
||
161 | * @throws ApiResponseErrorException |
||
162 | */ |
||
163 | protected function sendRequest($path, $method, array $params = [], array $content = null) |
||
175 | |||
176 | |||
177 | /** |
||
178 | * @param string $path |
||
179 | * @param array $params |
||
180 | * |
||
181 | * @return string |
||
182 | */ |
||
183 | private function assembleUri($path, array $params = []) |
||
192 | |||
193 | /** |
||
194 | * @param string $fullPath |
||
195 | * @param string $method |
||
196 | * |
||
197 | * @return object|null |
||
198 | * @throws ApiResponseErrorException |
||
199 | */ |
||
200 | private function getJsonForLastRequest($fullPath, $method) |
||
237 | |||
238 | /** |
||
239 | * @param $code |
||
240 | * @param Response $response |
||
241 | * @param string $method |
||
242 | * @param string $fullPath |
||
243 | * @param mixed $data |
||
244 | */ |
||
245 | private function validateResponse($code, $response, $method, $fullPath, $data) |
||
264 | } |
||
265 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: