Beispiel #1
0
    public function testPatch()
    {
        $response = Unirest\Request::patch('http://httpbin.org/patch', array(
            'Accept' => 'application/json'
        ), array(
            'name' => 'Mark',
            'nick' => 'thefosk'
        ));

        $this->assertEquals(200, $response->code);

        $form = $response->body->form;
        $this->assertEquals('Mark', $form->name);
        $this->assertEquals('thefosk', $form->nick);
    }
 public function testPatch()
 {
     $response = Unirest\Request::patch('http://mockbin.com/request', array('Accept' => 'application/json'), array('name' => 'Mark', 'nick' => 'thefosk'));
     $this->assertEquals(200, $response->code);
     $this->assertEquals('PATCH', $response->body->method);
     $this->assertEquals('Mark', $response->body->postData->params->name);
     $this->assertEquals('thefosk', $response->body->postData->params->nick);
 }
 public function patch($url, $body = null)
 {
     Unirest\Request::auth($this->login, $this->pass);
     Unirest\Request::defaultHeader('User-Agent', $this->service . " (" . $this->mail . ")");
     $body = Unirest\Request\Body::json($body);
     $response = Unirest\Request::patch($this->root . $url . '.json', array(), $body);
     if (floor($response->code / 100) >= 4) {
         throw new Error($response->body->errors->error[0]);
     }
     return $response->body;
 }