44
55use PHPUnit_Framework_TestCase ;
66use Mockery ;
7- use PulkitJalan \Requester \Requester ;
87
98class RequesterTest extends PHPUnit_Framework_TestCase
109{
1110 public function setUp ()
1211 {
1312 $ this ->guzzle = Mockery::mock ('GuzzleHttp\Client ' )->makePartial ();
14- $ this ->requester = new Requester ( $ this ->guzzle , []);
13+ $ this ->requester = Mockery:: mock ( ' PulkitJalan\Requester\Requester ' , [ $ this ->guzzle , []])-> makePartial ( );
1514 }
1615
1716 public function tearDown ()
1817 {
1918 Mockery::close ();
2019 }
2120
22- public function test_url_getter ()
21+ public function testUrlGetter ()
2322 {
2423 $ this ->requester ->url ('example.com ' );
2524
@@ -34,37 +33,42 @@ public function test_url_getter()
3433 $ this ->assertEquals ('git://example.com ' , $ this ->requester ->getUrl ());
3534 }
3635
37- public function test_invalid_url_exception ()
36+ public function testInvalidUrlException ()
3837 {
3938 $ this ->setExpectedException ('PulkitJalan\Requester\Exceptions\InvalidUrlException ' );
4039
4140 $ this ->requester ->getUrl ();
4241 }
4342
44- public function test_guzzle_getter ()
43+ public function testGuzzleGetter ()
4544 {
4645 $ this ->assertInstanceOf ('GuzzleHttp\Client ' , $ this ->requester ->getGuzzleClient ());
4746 }
4847
49- public function test_disabling_ssl_verification ()
48+ public function testDisablingSslVerification ()
5049 {
51- $ this ->requester ->verify (false );
50+ $ this ->guzzle ->shouldReceive ('get ' )->once ()->with ('https://example.com ' , [
51+ 'verify ' => false ,
52+ ]);
5253
53- $ this ->assertEquals (['verify ' => false ], $ this ->readAttribute ($ this ->requester , 'options ' ));
54+ $ this ->requester ->url ('example.com ' )->verify (false )->get ();
55+ }
5456
55- $ this ->guzzle ->shouldReceive ('get ' )->once ()->with ('http://example.com ' , [
56- 'verify ' => false ,
57+ public function testSettingAsync ()
58+ {
59+ $ this ->guzzle ->shouldReceive ('get ' )->once ()->with ('https://example.com ' , [
60+ 'verify ' => true ,
61+ 'future ' => true
5762 ]);
5863
59- $ this ->requester ->url ('example.com ' )->secure ( false )-> verify ( false )->get ();
64+ $ this ->requester ->url ('example.com ' )->async ( true )->get ();
6065 }
6166
62- public function test_setting_and_adding_headers ()
67+ public function testSettingAndAddingHeaders ()
6368 {
6469 $ this ->requester ->headers (['Authorization ' => 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ== ' ]);
6570
6671 $ this ->assertEquals ([
67- 'verify ' => true ,
6872 'headers ' => [
6973 'Authorization ' => 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ== ' ,
7074 ],
@@ -73,15 +77,14 @@ public function test_setting_and_adding_headers()
7377 $ this ->requester ->headers (['Cache-Control ' => 'no-cache ' ]);
7478
7579 $ this ->assertEquals ([
76- 'verify ' => true ,
7780 'headers ' => [
7881 'Authorization ' => 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ== ' ,
7982 'Cache-Control ' => 'no-cache ' ,
8083 ],
8184 ], $ this ->readAttribute ($ this ->requester , 'options ' ));
8285 }
8386
84- public function test_adding_file_to_request ()
87+ public function testAddingFileToRequest ()
8588 {
8689 $ this ->requester ->addFile (__FILE__ );
8790
@@ -94,7 +97,7 @@ public function test_adding_file_to_request()
9497 $ this ->assertInternalType ('resource ' , $ this ->readAttribute ($ this ->requester , 'options ' )['body ' ]['image ' ]);
9598 }
9699
97- public function test_changing_retry_options ()
100+ public function testChangingRetryOptions ()
98101 {
99102 $ this ->requester ->retry (10 );
100103
@@ -113,7 +116,7 @@ public function test_changing_retry_options()
113116 $ this ->assertEquals (false , $ this ->readAttribute ($ this ->requester , 'retry ' ));
114117 }
115118
116- public function test_sending_get_request ()
119+ public function testSendingGetRequest ()
117120 {
118121 $ this ->guzzle ->shouldReceive ('get ' )->once ()->with ('https://example.com ' , [
119122 'verify ' => true ,
@@ -122,7 +125,7 @@ public function test_sending_get_request()
122125 $ this ->requester ->url ('example.com ' )->get ();
123126 }
124127
125- public function test_sending_head_request ()
128+ public function testSendingHeadRequest ()
126129 {
127130 $ this ->guzzle ->shouldReceive ('head ' )->once ()->with ('https://example.com ' , [
128131 'verify ' => true ,
@@ -131,7 +134,7 @@ public function test_sending_head_request()
131134 $ this ->requester ->url ('example.com ' )->head ();
132135 }
133136
134- public function test_sending_options_request ()
137+ public function testSendingOptionsRequest ()
135138 {
136139 $ this ->guzzle ->shouldReceive ('options ' )->once ()->with ('https://example.com ' , [
137140 'verify ' => true ,
@@ -140,7 +143,7 @@ public function test_sending_options_request()
140143 $ this ->requester ->url ('example.com ' )->options ();
141144 }
142145
143- public function test_sending_post_request ()
146+ public function testSendingPostRequest ()
144147 {
145148 $ this ->guzzle ->shouldReceive ('post ' )->once ()->with ('https://example.com ' , [
146149 'verify ' => true ,
@@ -156,7 +159,7 @@ public function test_sending_post_request()
156159 ]);
157160 }
158161
159- public function test_sending_put_request ()
162+ public function testSendingPutRequest ()
160163 {
161164 $ this ->guzzle ->shouldReceive ('put ' )->once ()->with ('https://example.com ' , [
162165 'verify ' => true ,
@@ -172,7 +175,7 @@ public function test_sending_put_request()
172175 ]);
173176 }
174177
175- public function test_sending_patch_request ()
178+ public function testSendingPatchRequest ()
176179 {
177180 $ this ->guzzle ->shouldReceive ('patch ' )->once ()->with ('https://example.com ' , [
178181 'verify ' => true ,
@@ -188,7 +191,7 @@ public function test_sending_patch_request()
188191 ]);
189192 }
190193
191- public function test_sending_delete_request ()
194+ public function testSendingDeleteRequest ()
192195 {
193196 $ this ->guzzle ->shouldReceive ('delete ' )->once ()->with ('https://example.com ' , [
194197 'verify ' => true ,
0 commit comments