Improve API calls for comments

This commit is contained in:
Frédéric Guillot
2014-09-16 17:54:17 +02:00
parent a76939066b
commit eb6dfdca53
5 changed files with 374 additions and 17 deletions

View File

@@ -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()

View File

@@ -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);