diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/units/CommentTest.php | 16 | ||||
-rw-r--r-- | tests/units/UserTest.php | 16 |
2 files changed, 28 insertions, 4 deletions
diff --git a/tests/units/CommentTest.php b/tests/units/CommentTest.php index 36ff1352..295ac60e 100644 --- a/tests/units/CommentTest.php +++ b/tests/units/CommentTest.php @@ -17,16 +17,24 @@ class CommentTest extends Base $this->assertEquals(1, $p->create(array('name' => 'test1'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1))); - $this->assertNotFalse($c->create(array('task_id' => 1, 'comment' => 'bla bla', 'user_id' => 1))); + $this->assertEquals(1, $c->create(array('task_id' => 1, 'comment' => 'bla bla', 'user_id' => 1))); + $this->assertEquals(2, $c->create(array('task_id' => 1, 'comment' => 'bla bla'))); $comment = $c->getById(1); - $this->assertNotEmpty($comment); $this->assertEquals('bla bla', $comment['comment']); $this->assertEquals(1, $comment['task_id']); $this->assertEquals(1, $comment['user_id']); $this->assertEquals('admin', $comment['username']); - $this->assertNotEmpty($comment['date']); + $this->assertEquals(time(), $comment['date_creation'], '', 3); + + $comment = $c->getById(2); + $this->assertNotEmpty($comment); + $this->assertEquals('bla bla', $comment['comment']); + $this->assertEquals(1, $comment['task_id']); + $this->assertEquals(0, $comment['user_id']); + $this->assertEquals('', $comment['username']); + $this->assertEquals(time(), $comment['date_creation'], '', 3); } public function testGetAll() @@ -103,7 +111,7 @@ class CommentTest extends Base $this->assertFalse($result[0]); $result = $c->validateCreation(array('task_id' => 1, 'comment' => 'bla')); - $this->assertFalse($result[0]); + $this->assertTrue($result[0]); $result = $c->validateCreation(array('comment' => 'bla')); $this->assertFalse($result[0]); diff --git a/tests/units/UserTest.php b/tests/units/UserTest.php index a596918e..fcdf3934 100644 --- a/tests/units/UserTest.php +++ b/tests/units/UserTest.php @@ -3,6 +3,8 @@ require_once __DIR__.'/Base.php'; use Model\User; +use Model\Subtask; +use Model\Comment; use Model\Task; use Model\TaskCreation; use Model\TaskFinder; @@ -133,10 +135,14 @@ class UserTest extends Base $tc = new TaskCreation($this->container); $tf = new TaskFinder($this->container); $p = new Project($this->container); + $s = new Subtask($this->container); + $c = new Comment($this->container); $this->assertNotFalse($u->create(array('username' => 'toto', 'password' => '123456', 'name' => 'Toto'))); $this->assertEquals(1, $p->create(array('name' => 'Project #1'))); $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'owner_id' => 2))); + $this->assertEquals(1, $s->create(array('title' => 'Subtask #1', 'user_id' => 2, 'task_id' => 1))); + $this->assertEquals(1, $c->create(array('comment' => 'foobar', 'user_id' => 2, 'task_id' => 1))); $task = $tf->getById(1); $this->assertEquals(1, $task['id']); @@ -152,6 +158,16 @@ class UserTest extends Base $this->assertEquals(1, $task['id']); $this->assertEquals(0, $task['owner_id']); + // Make sure that assigned subtasks are unassigned after removing the user + $subtask = $s->getById(1); + $this->assertEquals(1, $subtask['id']); + $this->assertEquals(0, $subtask['user_id']); + + // Make sure that comments are not related to the user anymore + $comment = $c->getById(1); + $this->assertEquals(1, $comment['id']); + $this->assertEquals(0, $comment['user_id']); + // Make sure that private projects are also removed $user_id1 = $u->create(array('username' => 'toto1', 'password' => '123456', 'name' => 'Toto')); $user_id2 = $u->create(array('username' => 'toto2', 'password' => '123456', 'name' => 'Toto')); |