/** * Testing a get with invalid login * * @access public * * @return void */ public function testGetNoIdInvalidLoginJSON() { $result = parent::makeRequest('contact', array(), 'GET', null, array('username' => '', 'password' => '')); $headers = $result->getHeader(); $body = json_decode($result->getBody()); $this->assertEquals(401, $result->getStatus()); $this->assertEquals('Authorization Required', $result->getReasonPhrase()); $this->assertEquals('application/json; charset=utf-8', $headers['content-type']); $this->assertEquals('Invalid Username or Password.', $body->errors[0]->message); $this->assertEquals('INVALID_LOGIN', $body->errors[0]->name); $this->assertEquals('', $body->errors[0]->at); }
/** * Testing a post with missing parameters * * @access public * * @return void */ public function testPostIvalidParamsJSON() { unset($this->post_data['task_name'], $this->post_data['task_project']); $result = parent::makeRequest('task', array($this->task_id), 'POST', $this->post_data); $headers = $result->getHeader(); $body = json_decode($result->getBody()); $this->assertEquals(401, $result->getStatus()); $this->assertEquals('Authorization Required', $result->getReasonPhrase()); $this->assertEquals('application/json; charset=utf-8', $headers['content-type']); $this->assertEquals('CTask::store-check failed - task name is NULL. CTask::store-check failed - task project is not set. ', $body->errors[0]->message); $this->assertEquals('SAVE_ERROR', $body->errors[0]->name); $this->assertEquals('', $body->errors[0]->at); }
/** * Testing a delete with invalid login * * @access public * * @return void */ public function testDeleteInvalidLoginXML() { $result = parent::makeRequest('project', array($this->project_id), 'DELETE', null, array('username' => '', 'password' => ''), 'http://w2p.api.frapi/', 'xml'); $headers = $result->getHeader(); $body = simplexml_load_string($result->getBody())->errors->error; $this->assertEquals(401, $result->getStatus()); $this->assertEquals('Authorization Required', $result->getReasonPhrase()); $this->assertEquals('application/xml; charset=utf-8', $headers['content-type']); $this->assertEquals('Invalid Username or Password.', (string) $body->message); $this->assertEquals('INVALID_LOGIN', (string) $body->name); $this->assertEquals('', (string) $body->at); }