1 | <?php |
||
19 | class PdfRequestTest extends \PHPUnit_Framework_TestCase |
||
20 | { |
||
21 | |||
22 | /** +++++++++++++++++++++++++++++++++++ **/ |
||
23 | /** ++++++++++++++ TESTS ++++++++++++++ **/ |
||
24 | /** +++++++++++++++++++++++++++++++++++ **/ |
||
25 | |||
26 | /** |
||
27 | * Test PDF type is returned by default |
||
28 | * if no type is set. |
||
29 | * |
||
30 | * @access public |
||
31 | * @return void |
||
32 | */ |
||
33 | public function testPdfTypeIsReturnedByDefaultIfNotTypeIsSet() |
||
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 URL does not contain query params if |
||
115 | * mehtod is not HEAD or GET. |
||
116 | * |
||
117 | * @access public |
||
118 | * @return void |
||
119 | */ |
||
120 | public function testUrlDoesNotContainQueryParamsIfMethodIsNotHeadOrGet() |
||
136 | |||
137 | /** |
||
138 | * Test URL does contain query params if mehthod |
||
139 | * is GET. |
||
140 | * |
||
141 | * @access public |
||
142 | * @return void |
||
143 | */ |
||
144 | public function testUrlDoesContainQueryParamsIfMethodIsGet() |
||
162 | |||
163 | /** |
||
164 | * Test URL does contain query params if method |
||
165 | * is HEAD. |
||
166 | * |
||
167 | * @access public |
||
168 | * @return void |
||
169 | */ |
||
170 | public function testUrlDoesContainQueryParamsIfMethodIsHead() |
||
188 | |||
189 | /** |
||
190 | * Test query params are appended to URL if |
||
191 | * URL contains existng query params. |
||
192 | * |
||
193 | * @access public |
||
194 | * @return void |
||
195 | */ |
||
196 | public function testQueryParamsAreAppendedToUrlIfUrlContainsExistingQueryParams() |
||
214 | |||
215 | /** |
||
216 | * Test request contains no body if method |
||
217 | * is GET. |
||
218 | * |
||
219 | * @access public |
||
220 | * @return void |
||
221 | */ |
||
222 | public function testRequestContainsNoBodyIfMethodIsGet() |
||
235 | |||
236 | /** |
||
237 | * Test request contains no body if method |
||
238 | * is HEAD. |
||
239 | * |
||
240 | * @access public |
||
241 | * @return void |
||
242 | */ |
||
243 | public function testRequestContainsNoBodyIfMethodIsHead() |
||
256 | |||
257 | /** |
||
258 | * Test request contains a body if method is |
||
259 | * not HEAD or GET. |
||
260 | * |
||
261 | * @access public |
||
262 | * @return void |
||
263 | */ |
||
264 | public function testRequestContainsABodyIfMethodIsNotHeadOrGet() |
||
279 | |||
280 | /** |
||
281 | * Test request data can be flattened. |
||
282 | * |
||
283 | * @access public |
||
284 | * @return void |
||
285 | */ |
||
286 | public function testRequestDataCanBeFalttened() |
||
307 | |||
308 | /** |
||
309 | * Test raw request data can be accessed. |
||
310 | * |
||
311 | * @access public |
||
312 | * @return void |
||
313 | */ |
||
314 | public function testRawRequestDataCanBeAccessed() |
||
329 | |||
330 | /** |
||
331 | * Test headers can be added. |
||
332 | * |
||
333 | * @access public |
||
334 | * @return void |
||
335 | */ |
||
336 | public function testHeadersCanBeAdded() |
||
355 | |||
356 | /** |
||
357 | * Test headers can be accessed in |
||
358 | * JSON format |
||
359 | * |
||
360 | * @access public |
||
361 | * @return void |
||
362 | */ |
||
363 | public function testHeadersCanBeAccessedInJsonFormat() |
||
377 | |||
378 | /** |
||
379 | * Test raw headers can be accessed. |
||
380 | * |
||
381 | * @access public |
||
382 | * @return void |
||
383 | */ |
||
384 | public function testRawHeadersCanBeAccessed() |
||
396 | |||
397 | /** |
||
398 | * Test not writable exception is thrown if |
||
399 | * output path is not writable. |
||
400 | * |
||
401 | * @access public |
||
402 | * @return void |
||
403 | */ |
||
404 | public function tesNotWritableExceptonIsThrownIfOutputPathIsNotWritable() |
||
413 | |||
414 | /** |
||
415 | * Test can set output file. |
||
416 | * |
||
417 | * @access public |
||
418 | * @return void |
||
419 | */ |
||
420 | public function testCanSetOutputFile() |
||
429 | |||
430 | /** |
||
431 | * Test can set viewport width. |
||
432 | * |
||
433 | * @access public |
||
434 | * @return void |
||
435 | */ |
||
436 | public function testCanSetViewportWidth() |
||
446 | |||
447 | /** |
||
448 | * Test can set viewport height. |
||
449 | * |
||
450 | * @access public |
||
451 | * @return void |
||
452 | */ |
||
453 | public function testCanSetViewportHeight() |
||
463 | |||
464 | /** |
||
465 | * Test can set paper width. |
||
466 | * |
||
467 | * @access public |
||
468 | * @return void |
||
469 | */ |
||
470 | public function testCanSetPaperWidth() |
||
480 | |||
481 | /** |
||
482 | * Test can set paper height. |
||
483 | * |
||
484 | * @access public |
||
485 | * @return void |
||
486 | */ |
||
487 | public function testCanSetPaperHeight() |
||
497 | |||
498 | /** |
||
499 | * Test can set zoom. |
||
500 | * |
||
501 | * @access public |
||
502 | * @return void |
||
503 | */ |
||
504 | public function testCanSetZoom() |
||
513 | |||
514 | /** +++++++++++++++++++++++++++++++++++ **/ |
||
515 | /** ++++++++++ TEST ENTITIES ++++++++++ **/ |
||
516 | /** +++++++++++++++++++++++++++++++++++ **/ |
||
517 | |||
518 | /** |
||
519 | * Get PDF request instance. |
||
520 | * |
||
521 | * @access protected |
||
522 | * @param string $url (default: null) |
||
523 | * @param string $method (default: RequestInterface::METHOD_GET) |
||
524 | * @param int $timeout (default: 5000) |
||
525 | * @return \JonnyW\PhantomJs\Http\PdfRequest |
||
526 | */ |
||
527 | protected function getPdfRequest($url = null, $method = RequestInterface::METHOD_GET, $timeout = 5000) |
||
533 | } |
||
534 |