コード例 #1
0
ファイル: HttpClientTest.php プロジェクト: im286er/windwalker
 /**
  * Method to test request().
  *
  * @return void
  *
  * @covers Windwalker\Http\HttpClient::request
  */
 public function testRequest()
 {
     $url = new Uri('http://example.com/?foo=bar');
     $this->instance->request('GET', $url, array('flower' => 'sakura'), array('X-Foo' => 'Bar'));
     $this->assertEquals('GET', $this->transport->request->getMethod());
     $this->assertEquals('http://example.com/?foo=bar&flower=sakura', $this->transport->request->getRequestTarget());
     $this->assertEquals('', $this->transport->request->getBody()->__toString());
     $this->assertEquals(array('X-Foo' => array('Bar')), $this->transport->request->getHeaders());
     $url = new Uri('http://example.com/?foo=bar');
     $this->instance->request('POST', $url, array('flower' => 'sakura'), array('X-Foo' => 'Bar'));
     $this->assertEquals('POST', $this->transport->request->getMethod());
     $this->assertEquals('http://example.com/?foo=bar', $this->transport->request->getRequestTarget());
     $this->assertEquals('flower=sakura', $this->transport->request->getBody()->__toString());
     $this->assertEquals(array('X-Foo' => array('Bar')), $this->transport->request->getHeaders());
 }