1 | <?php |
||
19 | class CaptureRequestTest extends \PHPUnit_Framework_TestCase |
||
20 | { |
||
21 | |||
22 | /** +++++++++++++++++++++++++++++++++++ **/ |
||
23 | /** ++++++++++++++ TESTS ++++++++++++++ **/ |
||
24 | /** +++++++++++++++++++++++++++++++++++ **/ |
||
25 | |||
26 | /** |
||
27 | * Test capture type is returned by default |
||
28 | * if no type is set. |
||
29 | * |
||
30 | * @access public |
||
31 | * @return void |
||
32 | */ |
||
33 | public function testCaptureTypeIsReturnedByDefaultIfNotTypeIsSet() |
||
39 | |||
40 | /** |
||
41 | * Test custom type can be set. |
||
42 | * |
||
43 | * @access public |
||
44 | * @return void |
||
45 | */ |
||
46 | public function testCustomTypeCanBeSet() |
||
55 | |||
56 | /** |
||
57 | * Test URL can be set via constructor. |
||
58 | * |
||
59 | * @access public |
||
60 | * @return void |
||
61 | */ |
||
62 | public function testUrlCanBeSetViaConstructor() |
||
69 | |||
70 | /** |
||
71 | * Test method can be set via constructor. |
||
72 | * |
||
73 | * @access public |
||
74 | * @return void |
||
75 | */ |
||
76 | public function testMethodCanBeSetViaConstructor() |
||
83 | |||
84 | /** |
||
85 | * Test timeout can be set via constructor. |
||
86 | * |
||
87 | * @access public |
||
88 | * @return void |
||
89 | */ |
||
90 | public function testTimeoutCanBeSetViaConstructor() |
||
97 | |||
98 | /** |
||
99 | * Test invalid method is thrown if method |
||
100 | * is invalid. |
||
101 | * |
||
102 | * @access public |
||
103 | * @return void |
||
104 | */ |
||
105 | public function testInvalidMethodIsThrownIfMethodIsInvalid() |
||
112 | |||
113 | /** |
||
114 | * Test rect width can be set. |
||
115 | * |
||
116 | * @access public |
||
117 | * @return void |
||
118 | */ |
||
119 | public function testRectWidthCanBeSet() |
||
129 | |||
130 | /** |
||
131 | * Test rect height can be set. |
||
132 | * |
||
133 | * @access public |
||
134 | * @return void |
||
135 | */ |
||
136 | public function testRectHeightCanBeSet() |
||
146 | |||
147 | /** |
||
148 | * Test rect top can be set. |
||
149 | * |
||
150 | * @access public |
||
151 | * @return void |
||
152 | */ |
||
153 | public function testRectTopCanBeSet() |
||
164 | |||
165 | /** |
||
166 | * Test rect left can be set. |
||
167 | * |
||
168 | * @access public |
||
169 | * @return void |
||
170 | */ |
||
171 | public function testRectLeftCanBeSet() |
||
182 | |||
183 | /** |
||
184 | * Test URL does not contain query params if |
||
185 | * mehtod is not HEAD or GET. |
||
186 | * |
||
187 | * @access public |
||
188 | * @return void |
||
189 | */ |
||
190 | public function testUrlDoesNotContainQueryParamsIfMethodIsNotHeadOrGet() |
||
206 | |||
207 | /** |
||
208 | * Test URL does contain query params if mehthod |
||
209 | * is GET. |
||
210 | * |
||
211 | * @access public |
||
212 | * @return void |
||
213 | */ |
||
214 | public function testUrlDoesContainQueryParamsIfMethodIsGet() |
||
232 | |||
233 | /** |
||
234 | * Test URL does contain query params if method |
||
235 | * is HEAD. |
||
236 | * |
||
237 | * @access public |
||
238 | * @return void |
||
239 | */ |
||
240 | public function testUrlDoesContainQueryParamsIfMethodIsHead() |
||
258 | |||
259 | /** |
||
260 | * Test query params are appended to URL if |
||
261 | * URL contains existng query params. |
||
262 | * |
||
263 | * @access public |
||
264 | * @return void |
||
265 | */ |
||
266 | public function testQueryParamsAreAppendedToUrlIfUrlContainsExistingQueryParams() |
||
284 | |||
285 | /** |
||
286 | * Test request contains no body if method |
||
287 | * is GET. |
||
288 | * |
||
289 | * @access public |
||
290 | * @return void |
||
291 | */ |
||
292 | public function testRequestContainsNoBodyIfMethodIsGet() |
||
305 | |||
306 | /** |
||
307 | * Test request contains no body if method |
||
308 | * is HEAD. |
||
309 | * |
||
310 | * @access public |
||
311 | * @return void |
||
312 | */ |
||
313 | public function testRequestContainsNoBodyIfMethodIsHead() |
||
326 | |||
327 | /** |
||
328 | * Test request contains a body if method is |
||
329 | * not HEAD or GET. |
||
330 | * |
||
331 | * @access public |
||
332 | * @return void |
||
333 | */ |
||
334 | public function testRequestContainsABodyIfMethodIsNotHeadOrGet() |
||
349 | |||
350 | /** |
||
351 | * Test request data can be flattened. |
||
352 | * |
||
353 | * @access public |
||
354 | * @return void |
||
355 | */ |
||
356 | public function testRequestDataCanBeFalttened() |
||
377 | |||
378 | /** |
||
379 | * Test raw request data can be accessed. |
||
380 | * |
||
381 | * @access public |
||
382 | * @return void |
||
383 | */ |
||
384 | public function testRawRequestDataCanBeAccessed() |
||
399 | |||
400 | /** |
||
401 | * Test headers can be added. |
||
402 | * |
||
403 | * @access public |
||
404 | * @return void |
||
405 | */ |
||
406 | public function testHeadersCanBeAdded() |
||
425 | |||
426 | /** |
||
427 | * Test headers can be accessed in |
||
428 | * JSON format |
||
429 | * |
||
430 | * @access public |
||
431 | * @return void |
||
432 | */ |
||
433 | public function testHeadersCanBeAccessedInJsonFormat() |
||
447 | |||
448 | /** |
||
449 | * Test raw headers can be accessed. |
||
450 | * |
||
451 | * @access public |
||
452 | * @return void |
||
453 | */ |
||
454 | public function testRawHeadersCanBeAccessed() |
||
466 | |||
467 | /** |
||
468 | * Test not writable exception is thrown if |
||
469 | * output path is not writable. |
||
470 | * |
||
471 | * @access public |
||
472 | * @return void |
||
473 | */ |
||
474 | public function testNotWritableExceptonIsThrownIfOutputPathIsNotWritable() |
||
483 | |||
484 | /** |
||
485 | * Test can set output file. |
||
486 | * |
||
487 | * @access public |
||
488 | * @return void |
||
489 | */ |
||
490 | public function testCanSetOutputFile() |
||
499 | |||
500 | /** |
||
501 | * Test can set viewport width. |
||
502 | * |
||
503 | * @access public |
||
504 | * @return void |
||
505 | */ |
||
506 | public function testCanSetViewportWidth() |
||
516 | |||
517 | /** |
||
518 | * Test can set viewport height. |
||
519 | * |
||
520 | * @access public |
||
521 | * @return void |
||
522 | */ |
||
523 | public function testCanSetViewportHeight() |
||
533 | |||
534 | /** +++++++++++++++++++++++++++++++++++ **/ |
||
535 | /** ++++++++++ TEST ENTITIES ++++++++++ **/ |
||
536 | /** +++++++++++++++++++++++++++++++++++ **/ |
||
537 | |||
538 | /** |
||
539 | * Get capture request instance. |
||
540 | * |
||
541 | * @access protected |
||
542 | * @param string $url (default: null) |
||
543 | * @param string $method (default: RequestInterface::METHOD_GET) |
||
544 | * @param int $timeout (default: 5000) |
||
545 | * @return \JonnyW\PhantomJs\Http\CaptureRequest |
||
546 | */ |
||
547 | protected function getCaptureRequest($url = null, $method = RequestInterface::METHOD_GET, $timeout = 5000) |
||
553 | } |
||
554 |