File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
tests/TestCase/Network/Http Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -193,6 +193,40 @@ public function testGetSimpleWithHeadersAndCookies()
193
193
$ this ->assertSame ($ result , $ response );
194
194
}
195
195
196
+ /**
197
+ * test get request with no data
198
+ *
199
+ * @return void
200
+ */
201
+ public function testGetNoData ()
202
+ {
203
+ $ response = new Response ();
204
+
205
+ $ mock = $ this ->getMockBuilder ('Cake\Http\Client\Adapter\Stream ' )
206
+ ->setMethods (['send ' ])
207
+ ->getMock ();
208
+ $ mock ->expects ($ this ->once ())
209
+ ->method ('send ' )
210
+ ->with ($ this ->callback (function ($ request ) {
211
+ $ this ->assertEquals (Request::METHOD_GET , $ request ->getMethod ());
212
+ $ this ->assertEmpty ($ request ->getHeaderLine ('Content-Type ' ), 'Should have no content-type set ' );
213
+ $ this ->assertEquals (
214
+ 'http://cakephp.org/search ' ,
215
+ $ request ->getUri () . ''
216
+ );
217
+
218
+ return true ;
219
+ }))
220
+ ->will ($ this ->returnValue ([$ response ]));
221
+
222
+ $ http = new Client ([
223
+ 'host ' => 'cakephp.org ' ,
224
+ 'adapter ' => $ mock
225
+ ]);
226
+ $ result = $ http ->get ('/search ' );
227
+ $ this ->assertSame ($ result , $ response );
228
+ }
229
+
196
230
/**
197
231
* test get request with querystring data
198
232
*
You can’t perform that action at this time.
0 commit comments