Browse Source

Add test for fix in #9630

Mark Story 9 years ago
parent
commit
aca66f9007
1 changed files with 34 additions and 0 deletions
  1. 34 0
      tests/TestCase/Network/Http/ClientTest.php

+ 34 - 0
tests/TestCase/Network/Http/ClientTest.php

@@ -194,6 +194,40 @@ class ClientTest extends TestCase
     }
 
     /**
+     * test get request with no data
+     *
+     * @return void
+     */
+    public function testGetNoData()
+    {
+        $response = new Response();
+
+        $mock = $this->getMockBuilder('Cake\Http\Client\Adapter\Stream')
+            ->setMethods(['send'])
+            ->getMock();
+        $mock->expects($this->once())
+            ->method('send')
+            ->with($this->callback(function ($request) {
+                $this->assertEquals(Request::METHOD_GET, $request->getMethod());
+                $this->assertEmpty($request->getHeaderLine('Content-Type'), 'Should have no content-type set');
+                $this->assertEquals(
+                    'http://cakephp.org/search',
+                    $request->getUri() . ''
+                );
+
+                return true;
+            }))
+            ->will($this->returnValue([$response]));
+
+        $http = new Client([
+            'host' => 'cakephp.org',
+            'adapter' => $mock
+        ]);
+        $result = $http->get('/search');
+        $this->assertSame($result, $response);
+    }
+
+    /**
      * test get request with querystring data
      *
      * @return void