summaryrefslogtreecommitdiff
path: root/tests/units/CommentTest.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-09-05 23:30:56 -0400
committerFrederic Guillot <fred@kanboard.net>2015-09-05 23:30:56 -0400
commit710f2c7bb046b43ec9878ae795a181101f6d7515 (patch)
treeb62723b6b49c3b6bf2b3ca41a772f552464a9031 /tests/units/CommentTest.php
parent94b38dd94bd819168163003beec8ef693f9d9839 (diff)
Improve unit tests
Diffstat (limited to 'tests/units/CommentTest.php')
-rw-r--r--tests/units/CommentTest.php142
1 files changed, 0 insertions, 142 deletions
diff --git a/tests/units/CommentTest.php b/tests/units/CommentTest.php
deleted file mode 100644
index 295ac60e..00000000
--- a/tests/units/CommentTest.php
+++ /dev/null
@@ -1,142 +0,0 @@
-<?php
-
-require_once __DIR__.'/Base.php';
-
-use Model\Task;
-use Model\TaskCreation;
-use Model\Project;
-use Model\Comment;
-
-class CommentTest extends Base
-{
- public function testCreate()
- {
- $c = new Comment($this->container);
- $tc = new TaskCreation($this->container);
- $p = new Project($this->container);
-
- $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->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->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()
- {
- $c = new Comment($this->container);
- $tc = new TaskCreation($this->container);
- $p = new Project($this->container);
-
- $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' => 'c1', 'user_id' => 1)));
- $this->assertNotFalse($c->create(array('task_id' => 1, 'comment' => 'c2', 'user_id' => 1)));
- $this->assertNotFalse($c->create(array('task_id' => 1, 'comment' => 'c3', 'user_id' => 1)));
-
- $comments = $c->getAll(1);
-
- $this->assertNotEmpty($comments);
- $this->assertEquals(3, count($comments));
- $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()
- {
- $c = new Comment($this->container);
- $tc = new TaskCreation($this->container);
- $p = new Project($this->container);
-
- $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' => 'c1', 'user_id' => 1)));
- $this->assertTrue($c->update(array('id' => 1, 'comment' => 'bla')));
-
- $comment = $c->getById(1);
- $this->assertNotEmpty($comment);
- $this->assertEquals('bla', $comment['comment']);
- }
-
- public function validateRemove()
- {
- $c = new Comment($this->container);
- $tc = new TaskCreation($this->container);
- $p = new Project($this->container);
-
- $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->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->container);
-
- $result = $c->validateCreation(array('user_id' => 1, 'task_id' => 1, 'comment' => 'bla'));
- $this->assertTrue($result[0]);
-
- $result = $c->validateCreation(array('user_id' => 1, 'task_id' => 1, 'comment' => ''));
- $this->assertFalse($result[0]);
-
- $result = $c->validateCreation(array('user_id' => 1, 'task_id' => 'a', 'comment' => 'bla'));
- $this->assertFalse($result[0]);
-
- $result = $c->validateCreation(array('user_id' => 'b', 'task_id' => 1, 'comment' => 'bla'));
- $this->assertFalse($result[0]);
-
- $result = $c->validateCreation(array('user_id' => 1, 'comment' => 'bla'));
- $this->assertFalse($result[0]);
-
- $result = $c->validateCreation(array('task_id' => 1, 'comment' => 'bla'));
- $this->assertTrue($result[0]);
-
- $result = $c->validateCreation(array('comment' => 'bla'));
- $this->assertFalse($result[0]);
-
- $result = $c->validateCreation(array());
- $this->assertFalse($result[0]);
- }
-
- public function testValidateModification()
- {
- $c = new Comment($this->container);
-
- $result = $c->validateModification(array('id' => 1, 'comment' => 'bla'));
- $this->assertTrue($result[0]);
-
- $result = $c->validateModification(array('id' => 1, 'comment' => ''));
- $this->assertFalse($result[0]);
-
- $result = $c->validateModification(array('comment' => 'bla'));
- $this->assertFalse($result[0]);
-
- $result = $c->validateModification(array('id' => 'b', 'comment' => 'bla'));
- $this->assertFalse($result[0]);
-
- $result = $c->validateModification(array());
- $this->assertFalse($result[0]);
- }
-}