Skip to content

Commit aca66f9

Browse files
committed
Add test for fix in #9630
1 parent 5e3b297 commit aca66f9

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/TestCase/Network/Http/ClientTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,40 @@ public function testGetSimpleWithHeadersAndCookies()
193193
$this->assertSame($result, $response);
194194
}
195195

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+
196230
/**
197231
* test get request with querystring data
198232
*

0 commit comments

Comments
 (0)