Ejemplo n.º 1
0
 public function testSetUrl()
 {
     $data = array('key' => 'value');
     $curl = new Curl();
     $curl->setHeader('X-DEBUG-TEST', 'get');
     $curl->setUrl(Test::TEST_URL);
     $curl->delete($data);
     $this->assertEquals(Test::TEST_URL, $curl->baseUrl);
     $this->assertEquals('key=value', $curl->response);
     $curl = new Curl();
     $curl->setHeader('X-DEBUG-TEST', 'get');
     $curl->setUrl(Test::TEST_URL);
     $curl->doGet($data);
     $this->assertEquals(Test::TEST_URL, $curl->baseUrl);
     $this->assertEquals('key=value', $curl->response);
     $curl = new Curl();
     $curl->setHeader('X-DEBUG-TEST', 'get');
     $curl->setUrl(Test::TEST_URL);
     $curl->head($data);
     $this->assertEquals(Test::TEST_URL, $curl->baseUrl);
     $this->assertEquals('HEAD /?key=value HTTP/1.1', $curl->requestHeaders['Request-Line']);
     $curl = new Curl();
     $curl->setHeader('X-DEBUG-TEST', 'get');
     $curl->setUrl(Test::TEST_URL);
     $curl->options($data);
     $this->assertEquals(Test::TEST_URL, $curl->baseUrl);
     $this->assertEquals('key=value', $curl->response);
     $curl = new Curl();
     $curl->setHeader('X-DEBUG-TEST', 'request_method');
     $curl->setUrl(Test::TEST_URL);
     $curl->patch($data);
     $this->assertEquals(Test::TEST_URL, $curl->baseUrl);
     $this->assertEquals('PATCH', $curl->response);
     $curl = new Curl();
     $curl->setHeader('X-DEBUG-TEST', 'post');
     $curl->setUrl(Test::TEST_URL);
     $curl->post($data);
     $this->assertEquals(Test::TEST_URL, $curl->baseUrl);
     $this->assertEquals('key=value', $curl->response);
     $curl = new Curl();
     $curl->setHeader('X-DEBUG-TEST', 'put');
     $curl->setUrl(Test::TEST_URL);
     $curl->put($data);
     $this->assertEquals(Test::TEST_URL, $curl->baseUrl);
     $this->assertEquals('key=value', $curl->response);
 }