Permalink
Browse files

Adding test for task delete.

  • Loading branch information...
trevormorse committed May 27, 2011
1 parent 20a4e42 commit 66319f0f93d8b3ac44ed393e210f6eff00952000
Showing with 40 additions and 0 deletions.
  1. +40 −0 tests/tasks.test.php
View
@@ -486,4 +486,44 @@ public function testPutIvalidParamsJSON()
$this->assertEquals('SAVE_ERROR', $body->errors[0]->name);
$this->assertEquals('', $body->errors[0]->at);
}
+
+ /**
+ * Testing delete
+ *
+ * @access public
+ *
+ * @return void
+ */
+ public function testDeleteJSON()
+ {
+ $result = parent::makeRequest('project/' . $this->project_id . '/task', array($this->task_id), 'DELETE');
+ $headers = $result->getHeader();
+ $body = json_decode($result->getBody());
+
+ $this->assertEquals(200, $result->getStatus());
+ $this->assertEquals('OK', $result->getReasonPhrase());
+ $this->assertEquals('application/json; charset=utf-8', $headers['content-type']);
+ $this->assertTrue($body->success);
+ }
+
+ /**
+ * Testing a delete with invalid login
+ *
+ * @access public
+ *
+ * @return void
+ */
+ public function testDeleteInvalidLoginJSON()
+ {
+ $result = parent::makeRequest('project/' . $this->project_id . '/task', array($this->project_id), 'DELETE', 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);
+ }
}

0 comments on commit 66319f0

Please sign in to comment.