diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-07-17 17:15:14 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-07-17 17:15:14 -0400 |
commit | ec0ecc5b0387924f061865f4ec12dbfc5b7018fe (patch) | |
tree | 146fe907e300fa88587b621aaf53a9ca05e8c2d8 /tests/units/Model/CommentTest.php | |
parent | 3aa0f8574898876518dddf29ced43dd32efa2375 (diff) |
Added event for removed comments with some refactoring
Diffstat (limited to 'tests/units/Model/CommentTest.php')
-rw-r--r-- | tests/units/Model/CommentTest.php | 106 |
1 files changed, 0 insertions, 106 deletions
diff --git a/tests/units/Model/CommentTest.php b/tests/units/Model/CommentTest.php deleted file mode 100644 index 574b5a87..00000000 --- a/tests/units/Model/CommentTest.php +++ /dev/null @@ -1,106 +0,0 @@ -<?php - -require_once __DIR__.'/../Base.php'; - -use Kanboard\Model\TaskCreationModel; -use Kanboard\Model\ProjectModel; -use Kanboard\Model\CommentModel; - -class CommentTest extends Base -{ - public function testCreate() - { - $commentModel = new CommentModel($this->container); - $taskCreationModel = new TaskCreationModel($this->container); - $projectModel = new ProjectModel($this->container); - - $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); - $this->assertEquals(1, $taskCreationModel->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1))); - $this->assertEquals(1, $commentModel->create(array('task_id' => 1, 'comment' => 'bla bla', 'user_id' => 1))); - $this->assertEquals(2, $commentModel->create(array('task_id' => 1, 'comment' => 'bla bla'))); - - $comment = $commentModel->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 = $commentModel->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() - { - $commentModel = new CommentModel($this->container); - $taskCreationModel = new TaskCreationModel($this->container); - $projectModel = new ProjectModel($this->container); - - $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); - $this->assertEquals(1, $taskCreationModel->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1))); - $this->assertEquals(1, $commentModel->create(array('task_id' => 1, 'comment' => 'c1', 'user_id' => 1))); - $this->assertEquals(2, $commentModel->create(array('task_id' => 1, 'comment' => 'c2', 'user_id' => 1))); - $this->assertEquals(3, $commentModel->create(array('task_id' => 1, 'comment' => 'c3', 'user_id' => 1))); - - $comments = $commentModel->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, $commentModel->count(1)); - } - - public function testUpdate() - { - $commentModel = new CommentModel($this->container); - $taskCreationModel = new TaskCreationModel($this->container); - $projectModel = new ProjectModel($this->container); - - $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); - $this->assertEquals(1, $taskCreationModel->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1))); - $this->assertEquals(1, $commentModel->create(array('task_id' => 1, 'comment' => 'c1', 'user_id' => 1))); - $this->assertTrue($commentModel->update(array('id' => 1, 'comment' => 'bla'))); - - $comment = $commentModel->getById(1); - $this->assertNotEmpty($comment); - $this->assertEquals('bla', $comment['comment']); - } - - public function validateRemove() - { - $commentModel = new CommentModel($this->container); - $taskCreationModel = new TaskCreationModel($this->container); - $projectModel = new ProjectModel($this->container); - - $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); - $this->assertEquals(1, $taskCreationModel->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1))); - $this->assertEquals(1, $commentModel->create(array('task_id' => 1, 'comment' => 'c1', 'user_id' => 1))); - - $this->assertTrue($commentModel->remove(1)); - $this->assertFalse($commentModel->remove(1)); - $this->assertFalse($commentModel->remove(1111)); - } - - public function testGetProjectId() - { - $commentModel = new CommentModel($this->container); - $taskCreationModel = new TaskCreationModel($this->container); - $projectModel = new ProjectModel($this->container); - - $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); - $this->assertEquals(1, $taskCreationModel->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1))); - $this->assertEquals(1, $commentModel->create(array('task_id' => 1, 'comment' => 'c1', 'user_id' => 1))); - - $this->assertEquals(1, $commentModel->getProjectId(1)); - $this->assertSame(0, $commentModel->getProjectId(2)); - } -} |