1 | <?php |
||
26 | trait ApiTestCase |
||
27 | { |
||
28 | use AssertsTrait; |
||
29 | |||
30 | /** |
||
31 | * @var SchemaManager |
||
32 | */ |
||
33 | protected static $schemaManager; |
||
34 | |||
35 | /** |
||
36 | * @var SwaggerDocument |
||
37 | */ |
||
38 | protected static $document; |
||
39 | |||
40 | /** |
||
41 | * @var ApiTestClient |
||
42 | */ |
||
43 | protected $client; |
||
44 | |||
45 | /** |
||
46 | * PHPUnit cannot add this to code coverage |
||
47 | * |
||
48 | * @codeCoverageIgnore |
||
49 | * |
||
50 | * @param $swaggerPath |
||
51 | * |
||
52 | * @throws \InvalidArgumentException |
||
53 | * @throws \org\bovigo\vfs\vfsStreamException |
||
54 | */ |
||
55 | public static function initSchemaManager($swaggerPath) |
||
81 | |||
82 | /** |
||
83 | * Create a client, booting the kernel using SYMFONY_ENV = $this->env |
||
84 | */ |
||
85 | protected function setUp() |
||
91 | |||
92 | |||
93 | /** |
||
94 | * @param string $path |
||
95 | * @param array $params |
||
96 | * |
||
97 | * @return object |
||
98 | * @throws ApiResponseErrorException |
||
99 | */ |
||
100 | protected function get($path, array $params = []) |
||
104 | |||
105 | /** |
||
106 | * @param string $path |
||
107 | * @param array $params |
||
108 | * |
||
109 | * @return object |
||
110 | * @throws ApiResponseErrorException |
||
111 | */ |
||
112 | protected function delete($path, array $params = []) |
||
116 | |||
117 | /** |
||
118 | * @param string $path |
||
119 | * @param array $content |
||
120 | * @param array $params |
||
121 | * |
||
122 | * @return object |
||
123 | * @throws ApiResponseErrorException |
||
124 | */ |
||
125 | protected function patch($path, array $content, array $params = []) |
||
129 | |||
130 | /** |
||
131 | * @param string $path |
||
132 | * @param array $content |
||
133 | * @param array $params |
||
134 | * |
||
135 | * @return object |
||
136 | * @throws ApiResponseErrorException |
||
137 | */ |
||
138 | protected function post($path, array $content, 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 put($path, array $content, array $params = []) |
||
155 | |||
156 | /** |
||
157 | * @param string $path |
||
158 | * @param array $method |
||
159 | * @param array $params |
||
160 | * @param array|null $content |
||
161 | * |
||
162 | * @return object |
||
163 | * @throws ApiResponseErrorException |
||
164 | */ |
||
165 | protected function sendRequest($path, $method, array $params = [], array $content = null) |
||
177 | |||
178 | |||
179 | /** |
||
180 | * @param string $path |
||
181 | * @param array $params |
||
182 | * |
||
183 | * @return string |
||
184 | */ |
||
185 | private function assembleUri($path, array $params = []) |
||
194 | |||
195 | /** |
||
196 | * @param string $fullPath |
||
197 | * @param string $method |
||
198 | * |
||
199 | * @return object|null |
||
200 | * @throws ApiResponseErrorException |
||
201 | */ |
||
202 | private function getJsonForLastRequest($fullPath, $method) |
||
239 | |||
240 | /** |
||
241 | * @param $code |
||
242 | * @param Response $response |
||
243 | * @param string $method |
||
244 | * @param string $fullPath |
||
245 | * @param mixed $data |
||
246 | */ |
||
247 | private function validateResponse($code, $response, $method, $fullPath, $data) |
||
266 | } |
||
267 |
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: