Added unit test when updating tags for a task

This commit is contained in:
Frederic Guillot
2016-06-24 18:35:33 -04:00
parent 16a138c86f
commit 49d312d5a4
2 changed files with 52 additions and 9 deletions

View File

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