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) |
||
80 | |||
81 | /** |
||
82 | * Create a client, booting the kernel using SYMFONY_ENV = $this->env |
||
83 | */ |
||
84 | protected function setUp() |
||
90 | |||
91 | |||
92 | /** |
||
93 | * @param string $path |
||
94 | * @param array $params |
||
95 | * |
||
96 | * @return object |
||
97 | * @throws ApiResponseErrorException |
||
98 | */ |
||
99 | protected function get($path, array $params = []) |
||
103 | |||
104 | /** |
||
105 | * @param string $path |
||
106 | * @param array $params |
||
107 | * |
||
108 | * @return object |
||
109 | * @throws ApiResponseErrorException |
||
110 | */ |
||
111 | protected function delete($path, array $params = []) |
||
115 | |||
116 | /** |
||
117 | * @param string $path |
||
118 | * @param array $content |
||
119 | * @param array $params |
||
120 | * |
||
121 | * @return object |
||
122 | * @throws ApiResponseErrorException |
||
123 | */ |
||
124 | protected function patch($path, array $content, array $params = []) |
||
128 | |||
129 | /** |
||
130 | * @param string $path |
||
131 | * @param array $content |
||
132 | * @param array $params |
||
133 | * |
||
134 | * @return object |
||
135 | * @throws ApiResponseErrorException |
||
136 | */ |
||
137 | protected function post($path, array $content, array $params = []) |
||
141 | |||
142 | /** |
||
143 | * @param string $path |
||
144 | * @param array $content |
||
145 | * @param array $params |
||
146 | * |
||
147 | * @return object |
||
148 | * @throws ApiResponseErrorException |
||
149 | */ |
||
150 | protected function put($path, array $content, array $params = []) |
||
154 | |||
155 | /** |
||
156 | * @param string $path |
||
157 | * @param array $method |
||
158 | * @param array $params |
||
159 | * @param array|null $content |
||
160 | * |
||
161 | * @return object |
||
162 | * @throws ApiResponseErrorException |
||
163 | */ |
||
164 | protected function sendRequest($path, $method, array $params = [], array $content = null) |
||
176 | |||
177 | |||
178 | /** |
||
179 | * @param string $path |
||
180 | * @param array $params |
||
181 | * |
||
182 | * @return string |
||
183 | */ |
||
184 | private function assembleUri($path, array $params = []) |
||
193 | |||
194 | /** |
||
195 | * @param string $fullPath |
||
196 | * @param string $method |
||
197 | * |
||
198 | * @return object|null |
||
199 | * @throws ApiResponseErrorException |
||
200 | */ |
||
201 | private function getJsonForLastRequest($fullPath, $method) |
||
238 | |||
239 | /** |
||
240 | * @param $code |
||
241 | * @param Response $response |
||
242 | * @param string $method |
||
243 | * @param string $fullPath |
||
244 | * @param mixed $data |
||
245 | */ |
||
246 | private function validateResponse($code, $response, $method, $fullPath, $data) |
||
273 | } |
||
274 |
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: