diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/functionals/ApiTest.php | 26 | ||||
-rw-r--r-- | tests/units/CommentTest.php | 17 |
2 files changed, 34 insertions, 9 deletions
diff --git a/tests/functionals/ApiTest.php b/tests/functionals/ApiTest.php index 0960eba7..e633c598 100644 --- a/tests/functionals/ApiTest.php +++ b/tests/functionals/ApiTest.php @@ -318,10 +318,10 @@ class Api extends PHPUnit_Framework_TestCase $comment = array( 'task_id' => $tasks[0]['id'], 'user_id' => 2, - 'comment' => 'boo', + 'content' => 'boo', ); - $this->assertTrue($this->client->createComment($comment)); + $this->assertTrue($this->client->execute('createComment', $comment)); } public function testGetComment() @@ -335,10 +335,11 @@ class Api extends PHPUnit_Framework_TestCase public function testUpdateComment() { - $comment = $this->client->getComment(1); - $comment['comment'] = 'test'; + $comment = array(); + $comment['id'] = 1; + $comment['content'] = 'test'; - $this->assertTrue($this->client->updateComment($comment)); + $this->assertTrue($this->client->execute('updateComment', $comment)); $comment = $this->client->getComment(1); $this->assertEquals('test', $comment['comment']); @@ -351,10 +352,10 @@ class Api extends PHPUnit_Framework_TestCase $comment = array( 'task_id' => $task_id, 'user_id' => 1, - 'comment' => 'blabla', + 'content' => 'blabla', ); - $this->assertTrue($this->client->createComment($comment)); + $this->assertTrue($this->client->execute('createComment', $comment)); $comments = $this->client->getAllComments($task_id); $this->assertNotFalse($comments); @@ -366,13 +367,20 @@ class Api extends PHPUnit_Framework_TestCase public function testRemoveComment() { $task_id = $this->getTaskId(); - $this->assertTrue($this->client->removeComment($task_id)); $comments = $this->client->getAllComments($task_id); $this->assertNotFalse($comments); $this->assertNotEmpty($comments); $this->assertTrue(is_array($comments)); - $this->assertEquals(1, count($comments)); + + foreach ($comments as $comment) { + $this->assertTrue($this->client->removeComment($comment['id'])); + } + + $comments = $this->client->getAllComments($task_id); + $this->assertNotFalse($comments); + $this->assertEmpty($comments); + $this->assertTrue(is_array($comments)); } public function testCreateSubtask() diff --git a/tests/units/CommentTest.php b/tests/units/CommentTest.php index fa790555..31c46996 100644 --- a/tests/units/CommentTest.php +++ b/tests/units/CommentTest.php @@ -47,6 +47,8 @@ class CommentTest extends Base $this->assertEquals(1, $comments[0]['id']); $this->assertEquals(2, $comments[1]['id']); $this->assertEquals(3, $comments[2]['id']); + + $this->assertEquals(3, $c->count(1)); } public function testUpdate() @@ -65,6 +67,21 @@ class CommentTest extends Base $this->assertEquals('bla', $comment['comment']); } + public function validateRemove() + { + $c = new Comment($this->registry); + $t = new Task($this->registry); + $p = new Project($this->registry); + + $this->assertEquals(1, $p->create(array('name' => 'test1'))); + $this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1))); + $this->assertTrue($c->create(array('task_id' => 1, 'comment' => 'c1', 'user_id' => 1))); + + $this->assertTrue($c->remove(1)); + $this->assertFalse($c->remove(1)); + $this->assertFalse($c->remove(1111)); + } + public function testValidateCreation() { $c = new Comment($this->registry); |