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 | * Creates a Client. |
||
93 | * |
||
94 | * @param array $options An array of options to pass to the createKernel class |
||
95 | * @param array $server An array of server parameters |
||
96 | * |
||
97 | * @return Client A Client instance |
||
98 | */ |
||
99 | protected static function createClient(array $options = array(), array $server = array()) |
||
108 | |||
109 | |||
110 | /** |
||
111 | * @param string $path |
||
112 | * @param array $params |
||
113 | * |
||
114 | * @return object |
||
115 | * @throws ApiResponseErrorException |
||
116 | */ |
||
117 | protected function get($path, array $params = []) |
||
121 | |||
122 | /** |
||
123 | * @param string $path |
||
124 | * @param array $params |
||
125 | * |
||
126 | * @return object |
||
127 | * @throws ApiResponseErrorException |
||
128 | */ |
||
129 | protected function delete($path, array $params = []) |
||
133 | |||
134 | /** |
||
135 | * @param string $path |
||
136 | * @param array $content |
||
137 | * @param array $params |
||
138 | * |
||
139 | * @return object |
||
140 | * @throws ApiResponseErrorException |
||
141 | */ |
||
142 | protected function patch($path, array $content, array $params = []) |
||
146 | |||
147 | /** |
||
148 | * @param string $path |
||
149 | * @param array $content |
||
150 | * @param array $params |
||
151 | * |
||
152 | * @return object |
||
153 | * @throws ApiResponseErrorException |
||
154 | */ |
||
155 | protected function post($path, array $content, array $params = []) |
||
159 | |||
160 | /** |
||
161 | * @param string $path |
||
162 | * @param array $content |
||
163 | * @param array $params |
||
164 | * |
||
165 | * @return object |
||
166 | * @throws ApiResponseErrorException |
||
167 | */ |
||
168 | protected function put($path, array $content, array $params = []) |
||
172 | |||
173 | /** |
||
174 | * @param string $path |
||
175 | * @param array $method |
||
176 | * @param array $params |
||
177 | * @param array|null $content |
||
178 | * |
||
179 | * @return object |
||
180 | * @throws ApiResponseErrorException |
||
181 | */ |
||
182 | protected function sendRequest($path, $method, array $params = [], array $content = null) |
||
194 | |||
195 | |||
196 | /** |
||
197 | * @param string $path |
||
198 | * @param array $params |
||
199 | * |
||
200 | * @return string |
||
201 | */ |
||
202 | private function assembleUri($path, array $params = []) |
||
211 | |||
212 | /** |
||
213 | * @param string $fullPath |
||
214 | * @param string $method |
||
215 | * |
||
216 | * @return object|null |
||
217 | * @throws ApiResponseErrorException |
||
218 | */ |
||
219 | private function getJsonForLastRequest($fullPath, $method) |
||
256 | |||
257 | /** |
||
258 | * @param $code |
||
259 | * @param Response $response |
||
260 | * @param string $method |
||
261 | * @param string $fullPath |
||
262 | * @param mixed $data |
||
263 | */ |
||
264 | private function validateResponse($code, $response, $method, $fullPath, $data) |
||
291 | } |
||
292 |
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: