diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-06-24 18:35:33 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-06-24 18:35:33 -0400 |
commit | 49d312d5a41ccfe23432ef0f00a6ae79c8fd558f (patch) | |
tree | 29817260c415d565847ea70834d4821821341fe5 /tests | |
parent | 16a138c86f3216ecb97f80062cdc36d7ae8a57ed (diff) |
Added unit test when updating tags for a task
Diffstat (limited to 'tests')
-rw-r--r-- | tests/units/Model/TaskModificationTest.php | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/tests/units/Model/TaskModificationTest.php b/tests/units/Model/TaskModificationTest.php index a8ace25a..5cbc44e6 100644 --- a/tests/units/Model/TaskModificationTest.php +++ b/tests/units/Model/TaskModificationTest.php @@ -7,6 +7,7 @@ use Kanboard\Model\TaskCreationModel; use Kanboard\Model\TaskModificationModel; use Kanboard\Model\TaskFinderModel; use Kanboard\Model\ProjectModel; +use Kanboard\Model\TaskTagModel; class TaskModificationTest extends Base { @@ -45,7 +46,6 @@ class TaskModificationTest extends Base $p = new ProjectModel($this->container); $tc = new TaskCreationModel($this->container); $tm = new TaskModificationModel($this->container); - $tf = new TaskFinderModel($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1))); @@ -280,4 +280,34 @@ class TaskModificationTest extends Base $task = $tf->getById(1); $this->assertEquals(13.3, $task['time_spent']); } + + public function testChangeTags() + { + $projectModel = new ProjectModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $taskModificationModel = new TaskModificationModel($this->container); + $taskTagModel = new TaskTagModel($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'test'))); + $this->assertEquals(1, $taskCreationModel->create(array('title' => 'test', 'project_id' => 1, 'tags' => array('tag1', 'tag2')))); + $this->assertTrue($taskModificationModel->update(array('id' => 1, 'tags' => array('tag2')))); + + $tags = $taskTagModel->getList(1); + $this->assertEquals(array(2 => 'tag2'), $tags); + } + + public function testRemoveAllTags() + { + $projectModel = new ProjectModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $taskModificationModel = new TaskModificationModel($this->container); + $taskTagModel = new TaskTagModel($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'test'))); + $this->assertEquals(1, $taskCreationModel->create(array('title' => 'test', 'project_id' => 1, 'tags' => array('tag1', 'tag2')))); + $this->assertTrue($taskModificationModel->update(array('id' => 1))); + + $tags = $taskTagModel->getList(1); + $this->assertEquals(array(), $tags); + } } |