1 | <?php |
||
25 | class ApiTestClient extends Client |
||
26 | { |
||
27 | /** |
||
28 | * @var Client |
||
29 | */ |
||
30 | private $subject; |
||
31 | |||
32 | /** |
||
33 | * ApiTestClient constructor. |
||
34 | * |
||
35 | * @param Client $subject |
||
36 | */ |
||
37 | public function __construct(Client $subject) |
||
38 | { |
||
39 | $this->subject = $subject; |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * Makes a request from a Request object directly. |
||
44 | * |
||
45 | * @param Request $request A Request instance |
||
46 | * @param bool $changeHistory Whether to update the history or not (only used internally for back(), forward(), |
||
47 | * and reload()) |
||
48 | * |
||
49 | * @return Crawler |
||
50 | */ |
||
51 | public function requestFromRequest(Request $request, $changeHistory = true) |
||
52 | { |
||
53 | return $this->subject->requestFromRequest($request, $changeHistory); |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * Returns the container. |
||
58 | * |
||
59 | * @return ContainerInterface |
||
60 | */ |
||
61 | public function getContainer() |
||
62 | { |
||
63 | return $this->subject->getContainer(); |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * Returns the kernel. |
||
68 | * |
||
69 | * @return KernelInterface |
||
70 | */ |
||
71 | public function getKernel() |
||
72 | { |
||
73 | return $this->subject->getKernel(); |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * Gets the profile associated with the current Response. |
||
78 | * |
||
79 | * @return HttpProfile A Profile instance |
||
80 | */ |
||
81 | public function getProfile() |
||
82 | { |
||
83 | return $this->subject->getProfile(); |
||
84 | } |
||
85 | |||
86 | /** |
||
87 | * Enables the profiler for the very next request. |
||
88 | * |
||
89 | * If the profiler is not enabled, the call to this method does nothing. |
||
90 | */ |
||
91 | public function enableProfiler() |
||
95 | |||
96 | /** |
||
97 | * {@inheritdoc} |
||
98 | * |
||
99 | * @param Request $request A Request instance |
||
100 | * |
||
101 | * @return Response A Response instance |
||
102 | */ |
||
103 | protected function doRequest($request) |
||
107 | |||
108 | /** |
||
109 | * {@inheritdoc} |
||
110 | * |
||
111 | * @param Request $request A Request instance |
||
112 | * |
||
113 | * @return Response A Response instance |
||
114 | */ |
||
115 | protected function doRequestInProcess($request) |
||
119 | |||
120 | /** |
||
121 | * Returns the script to execute when the request must be insulated. |
||
122 | * |
||
123 | * It assumes that the autoloader is named 'autoload.php' and that it is |
||
124 | * stored in the same directory as the kernel (this is the case for the |
||
125 | * Symfony Standard Edition). If this is not your case, create your own |
||
126 | * client and override this method. |
||
127 | * |
||
128 | * @param Request $request A Request instance |
||
129 | * |
||
130 | * @return string The script content |
||
131 | */ |
||
132 | protected function getScript($request) |
||
136 | |||
137 | |||
138 | /** |
||
139 | * Sets whether to automatically follow redirects or not. |
||
140 | * |
||
141 | * @param bool $followRedirect Whether to follow redirects |
||
142 | * |
||
143 | * @api |
||
144 | */ |
||
145 | public function followRedirects($followRedirect = true) |
||
149 | |||
150 | /** |
||
151 | * Sets the maximum number of requests that crawler can follow. |
||
152 | * |
||
153 | * @param int $maxRedirects |
||
154 | */ |
||
155 | public function setMaxRedirects($maxRedirects) |
||
159 | |||
160 | /** |
||
161 | * Sets the insulated flag. |
||
162 | * |
||
163 | * @param bool $insulated Whether to insulate the requests or not |
||
164 | * |
||
165 | * @throws \RuntimeException When Symfony Process Component is not installed |
||
166 | * |
||
167 | * @api |
||
168 | */ |
||
169 | public function insulate($insulated = true) |
||
173 | |||
174 | /** |
||
175 | * Sets server parameters. |
||
176 | * |
||
177 | * @param array $server An array of server parameters |
||
178 | * |
||
179 | * @api |
||
180 | */ |
||
181 | public function setServerParameters(array $server) |
||
185 | |||
186 | /** |
||
187 | * Sets single server parameter. |
||
188 | * |
||
189 | * @param string $key A key of the parameter |
||
190 | * @param string $value A value of the parameter |
||
191 | */ |
||
192 | public function setServerParameter($key, $value) |
||
196 | |||
197 | /** |
||
198 | * Gets single server parameter for specified key. |
||
199 | * |
||
200 | * @param string $key A key of the parameter to get |
||
201 | * @param string $default A default value when key is undefined |
||
202 | * |
||
203 | * @return string A value of the parameter |
||
204 | */ |
||
205 | public function getServerParameter($key, $default = '') |
||
209 | |||
210 | /** |
||
211 | * Returns the History instance. |
||
212 | * |
||
213 | * @return History A History instance |
||
214 | * |
||
215 | * @api |
||
216 | */ |
||
217 | public function getHistory() |
||
221 | |||
222 | /** |
||
223 | * Returns the CookieJar instance. |
||
224 | * |
||
225 | * @return CookieJar A CookieJar instance |
||
226 | * |
||
227 | * @api |
||
228 | */ |
||
229 | public function getCookieJar() |
||
233 | |||
234 | /** |
||
235 | * Returns the current Crawler instance. |
||
236 | * |
||
237 | * @return Crawler|null A Crawler instance |
||
238 | * |
||
239 | * @api |
||
240 | */ |
||
241 | public function getCrawler() |
||
245 | |||
246 | /** |
||
247 | * Returns the current BrowserKit Response instance. |
||
248 | * |
||
249 | * @return Response|null A BrowserKit Response instance |
||
250 | * |
||
251 | * @api |
||
252 | */ |
||
253 | public function getInternalResponse() |
||
257 | |||
258 | /** |
||
259 | * Returns the current origin response instance. |
||
260 | * |
||
261 | * The origin response is the response instance that is returned |
||
262 | * by the code that handles requests. |
||
263 | * |
||
264 | * @return object|null A response instance |
||
265 | * |
||
266 | * @see doRequest() |
||
267 | * |
||
268 | * @api |
||
269 | */ |
||
270 | public function getResponse() |
||
274 | |||
275 | /** |
||
276 | * Returns the current BrowserKit Request instance. |
||
277 | * |
||
278 | * @return Request|null A BrowserKit Request instance |
||
279 | * |
||
280 | * @api |
||
281 | */ |
||
282 | public function getInternalRequest() |
||
286 | |||
287 | /** |
||
288 | * Returns the current origin Request instance. |
||
289 | * |
||
290 | * The origin request is the request instance that is sent |
||
291 | * to the code that handles requests. |
||
292 | * |
||
293 | * @return object|null A Request instance |
||
294 | * |
||
295 | * @see doRequest() |
||
296 | * |
||
297 | * @api |
||
298 | */ |
||
299 | public function getRequest() |
||
303 | |||
304 | /** |
||
305 | * Clicks on a given link. |
||
306 | * |
||
307 | * @param Link $link A Link instance |
||
308 | * |
||
309 | * @return Crawler |
||
310 | * |
||
311 | * @api |
||
312 | */ |
||
313 | public function click(Link $link) |
||
317 | |||
318 | /** |
||
319 | * Submits a form. |
||
320 | * |
||
321 | * @param Form $form A Form instance |
||
322 | * @param array $values An array of form field values |
||
323 | * |
||
324 | * @return Crawler |
||
325 | * |
||
326 | * @api |
||
327 | */ |
||
328 | public function submit(Form $form, array $values = []) |
||
332 | |||
333 | /** |
||
334 | * Calls a URI. |
||
335 | * |
||
336 | * @param string $method The request method |
||
337 | * @param string $uri The URI to fetch |
||
338 | * @param array $parameters The Request parameters |
||
339 | * @param array $files The files |
||
340 | * @param array $server The server parameters (HTTP headers are referenced with a HTTP_ prefix as PHP does) |
||
341 | * @param string $content The raw body data |
||
342 | * @param bool $changeHistory Whether to update the history or not (only used internally for back(), forward(), |
||
343 | * and reload()) |
||
344 | * |
||
345 | * @return Crawler |
||
346 | * |
||
347 | * @api |
||
348 | */ |
||
349 | public function request( |
||
368 | |||
369 | /** |
||
370 | * Filters the BrowserKit request to the origin one. |
||
371 | * |
||
372 | * @param Request $request The BrowserKit Request to filter |
||
373 | * |
||
374 | * @return object An origin request instance |
||
375 | */ |
||
376 | protected function filterRequest(Request $request) |
||
380 | |||
381 | /** |
||
382 | * Filters the origin response to the BrowserKit one. |
||
383 | * |
||
384 | * @param object $response The origin response to filter |
||
385 | * |
||
386 | * @return Response An BrowserKit Response instance |
||
387 | */ |
||
388 | protected function filterResponse($response) |
||
392 | |||
393 | /** |
||
394 | * Creates a crawler. |
||
395 | * |
||
396 | * This method returns null if the DomCrawler component is not available. |
||
397 | * |
||
398 | * @param string $uri A URI |
||
399 | * @param string $content Content for the crawler to use |
||
400 | * @param string $type Content type |
||
401 | * |
||
402 | * @return Crawler|null |
||
403 | */ |
||
404 | protected function createCrawlerFromContent($uri, $content, $type) |
||
408 | |||
409 | /** |
||
410 | * Goes back in the browser history. |
||
411 | * |
||
412 | * @return Crawler |
||
413 | * |
||
414 | * @api |
||
415 | */ |
||
416 | public function back() |
||
420 | |||
421 | /** |
||
422 | * Goes forward in the browser history. |
||
423 | * |
||
424 | * @return Crawler |
||
425 | * |
||
426 | * @api |
||
427 | */ |
||
428 | public function forward() |
||
432 | |||
433 | /** |
||
434 | * Reloads the current browser. |
||
435 | * |
||
436 | * @return Crawler |
||
437 | * |
||
438 | * @api |
||
439 | */ |
||
440 | public function reload() |
||
444 | |||
445 | /** |
||
446 | * Follow redirects? |
||
447 | * |
||
448 | * @return Crawler |
||
449 | * |
||
450 | * @throws \LogicException If request was not a redirect |
||
451 | * |
||
452 | * @api |
||
453 | */ |
||
454 | public function followRedirect() |
||
458 | |||
459 | /** |
||
460 | * Restarts the client. |
||
461 | * |
||
462 | * It flushes history and all cookies. |
||
463 | * |
||
464 | * @api |
||
465 | */ |
||
466 | public function restart() |
||
470 | |||
471 | /** |
||
472 | * Takes a URI and converts it to absolute if it is not already absolute. |
||
473 | * |
||
474 | * @param string $uri A URI |
||
475 | * |
||
476 | * @return string An absolute URI |
||
477 | */ |
||
478 | protected function getAbsoluteUri($uri) |
||
482 | } |
||
483 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: