1 | <?php |
||
19 | class RequestTest extends \PHPUnit_Framework_TestCase |
||
20 | { |
||
21 | |||
22 | /** +++++++++++++++++++++++++++++++++++ **/ |
||
23 | /** ++++++++++++++ TESTS ++++++++++++++ **/ |
||
24 | /** +++++++++++++++++++++++++++++++++++ **/ |
||
25 | |||
26 | /** |
||
27 | * Test default type is returned by default |
||
28 | * if no type is set. |
||
29 | * |
||
30 | * @access public |
||
31 | * @return void |
||
32 | */ |
||
33 | public function testDefaultTypeIsReturnedByDefaultIfNotTypeIsSet() |
||
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 can add setting. |
||
399 | * |
||
400 | * @access public |
||
401 | * @return void |
||
402 | */ |
||
403 | public function testCanAddSetting() |
||
418 | |||
419 | /** |
||
420 | * Test set timeout sets resource |
||
421 | * timeout in settings |
||
422 | * |
||
423 | * @access public |
||
424 | * @return void |
||
425 | */ |
||
426 | public function testSetTimeoutSetsResourceTimeoutInSettings() |
||
437 | |||
438 | /** |
||
439 | * Test can set viewport width. |
||
440 | * |
||
441 | * @access public |
||
442 | * @return void |
||
443 | */ |
||
444 | public function testCanSetViewportWidth() |
||
454 | |||
455 | /** |
||
456 | * Test can set viewport height. |
||
457 | * |
||
458 | * @access public |
||
459 | * @return void |
||
460 | */ |
||
461 | public function testCanSetViewportHeight() |
||
471 | |||
472 | /** +++++++++++++++++++++++++++++++++++ **/ |
||
473 | /** ++++++++++ TEST ENTITIES ++++++++++ **/ |
||
474 | /** +++++++++++++++++++++++++++++++++++ **/ |
||
475 | |||
476 | /** |
||
477 | * Get request instance. |
||
478 | * |
||
479 | * @access protected |
||
480 | * @param string $url (default: null) |
||
481 | * @param string $method (default: RequestInterface::METHOD_GET) |
||
482 | * @param int $timeout (default: 5000) |
||
483 | * @return \JonnyW\PhantomJs\Http\Request |
||
484 | */ |
||
485 | protected function getRequest($url = null, $method = RequestInterface::METHOD_GET, $timeout = 5000) |
||
491 | } |
||
492 |