Added automated action to change task color based on the priority

This commit is contained in:
Frederic Guillot
2016-05-04 22:52:08 -04:00
parent 1e1c127a85
commit d5c95e8240
29 changed files with 184 additions and 32 deletions

View File

@@ -40,7 +40,6 @@ class CommentCreationMoveTaskColumnTest extends Base
public function testWithUserNotLogged()
{
$projectModel = new Project($this->container);
$commentModel = new Comment($this->container);
$taskCreationModel = new TaskCreation($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));

View File

@@ -46,7 +46,6 @@ class CommentCreationTest extends Base
{
$userModel = new User($this->container);
$projectModel = new Project($this->container);
$projectUserRoleModel = new ProjectUserRole($this->container);
$commentModel = new Comment($this->container);
$taskCreationModel = new TaskCreation($this->container);
@@ -74,8 +73,6 @@ class CommentCreationTest extends Base
{
$userModel = new User($this->container);
$projectModel = new Project($this->container);
$projectUserRoleModel = new ProjectUserRole($this->container);
$commentModel = new Comment($this->container);
$taskCreationModel = new TaskCreation($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));

View File

@@ -42,7 +42,6 @@ class TaskAssignCategoryColorTest extends Base
$categoryModel = new Category($this->container);
$projectModel = new Project($this->container);
$taskCreationModel = new TaskCreation($this->container);
$taskFinderModel = new TaskFinder($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));

View File

@@ -42,7 +42,6 @@ class TaskAssignCategoryLabelTest extends Base
$categoryModel = new Category($this->container);
$projectModel = new Project($this->container);
$taskCreationModel = new TaskCreation($this->container);
$taskFinderModel = new TaskFinder($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));
@@ -64,7 +63,6 @@ class TaskAssignCategoryLabelTest extends Base
$categoryModel = new Category($this->container);
$projectModel = new Project($this->container);
$taskCreationModel = new TaskCreation($this->container);
$taskFinderModel = new TaskFinder($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(1, $categoryModel->create(array('name' => 'c1', 'project_id' => 1)));

View File

@@ -70,7 +70,6 @@ class TaskAssignCategoryLinkTest extends Base
public function testThatExistingCategoryWillNotChange()
{
$tc = new TaskCreation($this->container);
$tf = new TaskFinder($this->container);
$p = new Project($this->container);
$c = new Category($this->container);

View File

@@ -39,10 +39,8 @@ class TaskAssignColorCategoryTest extends Base
public function testWithWrongCategory()
{
$categoryModel = new Category($this->container);
$projectModel = new Project($this->container);
$taskCreationModel = new TaskCreation($this->container);
$taskFinderModel = new TaskFinder($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));

View File

@@ -38,7 +38,6 @@ class TaskAssignColorColumnTest extends Base
{
$projectModel = new Project($this->container);
$taskCreationModel = new TaskCreation($this->container);
$taskFinderModel = new TaskFinder($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));

View File

@@ -38,7 +38,6 @@ class TaskAssignColorLinkTest extends Base
{
$projectModel = new Project($this->container);
$taskCreationModel = new TaskCreation($this->container);
$taskFinderModel = new TaskFinder($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));

View File

@@ -0,0 +1,57 @@
<?php
require_once __DIR__.'/../Base.php';
use Kanboard\Event\GenericEvent;
use Kanboard\Model\Category;
use Kanboard\Model\TaskCreation;
use Kanboard\Model\TaskFinder;
use Kanboard\Model\Project;
use Kanboard\Model\Task;
use Kanboard\Action\TaskAssignColorPriority;
class TaskAssignColorPriorityTest extends Base
{
public function testChangeColor()
{
$categoryModel = new Category($this->container);
$projectModel = new Project($this->container);
$taskCreationModel = new TaskCreation($this->container);
$taskFinderModel = new TaskFinder($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));
$this->assertEquals(1, $categoryModel->create(array('name' => 'c1', 'project_id' => 1)));
$event = new GenericEvent(array('project_id' => 1, 'task_id' => 1, 'priority' => 1));
$action = new TaskAssignColorPriority($this->container);
$action->setProjectId(1);
$action->setParam('color_id', 'red');
$action->setParam('priority', 1);
$this->assertTrue($action->execute($event, Task::EVENT_CREATE_UPDATE));
$task = $taskFinderModel->getById(1);
$this->assertNotEmpty($task);
$this->assertEquals('red', $task['color_id']);
}
public function testWithWrongPriority()
{
$projectModel = new Project($this->container);
$taskCreationModel = new TaskCreation($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));
$event = new GenericEvent(array('project_id' => 1, 'task_id' => 1, 'priority' => 2));
$action = new TaskAssignColorPriority($this->container);
$action->setProjectId(1);
$action->setParam('color_id', 'red');
$action->setParam('priority', 1);
$this->assertFalse($action->execute($event, Task::EVENT_CREATE_UPDATE));
}
}

View File

@@ -38,7 +38,6 @@ class TaskAssignColorUserTest extends Base
{
$projectModel = new Project($this->container);
$taskCreationModel = new TaskCreation($this->container);
$taskFinderModel = new TaskFinder($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));

View File

@@ -41,7 +41,6 @@ class TaskAssignCurrentUserColumnTest extends Base
$projectModel = new Project($this->container);
$taskCreationModel = new TaskCreation($this->container);
$taskFinderModel = new TaskFinder($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));
@@ -59,7 +58,6 @@ class TaskAssignCurrentUserColumnTest extends Base
{
$projectModel = new Project($this->container);
$taskCreationModel = new TaskCreation($this->container);
$taskFinderModel = new TaskFinder($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));

View File

@@ -38,7 +38,6 @@ class TaskAssignCurrentUserTest extends Base
{
$projectModel = new Project($this->container);
$taskCreationModel = new TaskCreation($this->container);
$taskFinderModel = new TaskFinder($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));

View File

@@ -38,7 +38,6 @@ class TaskAssignSpecificUserTest extends Base
{
$projectModel = new Project($this->container);
$taskCreationModel = new TaskCreation($this->container);
$taskFinderModel = new TaskFinder($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));

View File

@@ -41,11 +41,8 @@ class TaskAssignUserTest extends Base
public function testWithNotAssignableUser()
{
$userModel = new User($this->container);
$projectModel = new Project($this->container);
$projectUserRoleModel = new ProjectUserRole($this->container);
$taskCreationModel = new TaskCreation($this->container);
$taskFinderModel = new TaskFinder($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));

View File

@@ -37,7 +37,6 @@ class TaskCloseColumnTest extends Base
{
$projectModel = new Project($this->container);
$taskCreationModel = new TaskCreation($this->container);
$taskFinderModel = new TaskFinder($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));

View File

@@ -34,7 +34,6 @@ class TaskCreationActionTest extends Base
public function testWithNoTitle()
{
$projectModel = new Project($this->container);
$taskFinderModel = new TaskFinder($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));

View File

@@ -39,7 +39,6 @@ class TaskDuplicateAnotherProjectTest extends Base
public function testWithWrongColumn()
{
$projectModel = new Project($this->container);
$taskCreationModel = new TaskCreation($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(2, $projectModel->create(array('name' => 'test2')));

View File

@@ -44,7 +44,6 @@ class TaskEmailTest extends Base
public function testWithWrongColumn()
{
$projectModel = new Project($this->container);
$taskCreationModel = new TaskCreation($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));

View File

@@ -40,7 +40,6 @@ class TaskMoveAnotherProjectTest extends Base
public function testWithWrongColumn()
{
$projectModel = new Project($this->container);
$taskCreationModel = new TaskCreation($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(2, $projectModel->create(array('name' => 'test2')));

View File

@@ -39,7 +39,6 @@ class TaskMoveColumnAssignedTest extends Base
public function testWithWrongColumn()
{
$projectModel = new Project($this->container);
$taskCreationModel = new TaskCreation($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(2, $projectModel->create(array('name' => 'test2')));

View File

@@ -43,7 +43,6 @@ class TaskMoveColumnCategoryChangeTest extends Base
{
$projectModel = new Project($this->container);
$taskCreationModel = new TaskCreation($this->container);
$taskFinderModel = new TaskFinder($this->container);
$categoryModel = new Category($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
@@ -65,7 +64,6 @@ class TaskMoveColumnCategoryChangeTest extends Base
{
$projectModel = new Project($this->container);
$taskCreationModel = new TaskCreation($this->container);
$taskFinderModel = new TaskFinder($this->container);
$categoryModel = new Category($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));

View File

@@ -39,7 +39,6 @@ class TaskMoveColumnUnAssignedTest extends Base
public function testWithWrongColumn()
{
$projectModel = new Project($this->container);
$taskCreationModel = new TaskCreation($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(2, $projectModel->create(array('name' => 'test2')));
@@ -57,7 +56,6 @@ class TaskMoveColumnUnAssignedTest extends Base
public function testWithWrongUser()
{
$projectModel = new Project($this->container);
$taskCreationModel = new TaskCreation($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(2, $projectModel->create(array('name' => 'test2')));

View File

@@ -315,6 +315,11 @@ class ProjectTest extends Base
$this->assertEquals(0, $project['priority_start']);
$this->assertEquals(3, $project['priority_end']);
$this->assertEquals(
array(0 => 0, 1 => 1, 2 => 2, 3 => 3),
$projectModel->getPriorities($project)
);
$this->assertTrue($projectModel->update(array('id' => 1, 'priority_start' => 2, 'priority_end' => 5, 'priority_default' => 4)));
$project = $projectModel->getById(1);
@@ -322,5 +327,10 @@ class ProjectTest extends Base
$this->assertEquals(4, $project['priority_default']);
$this->assertEquals(2, $project['priority_start']);
$this->assertEquals(5, $project['priority_end']);
$this->assertEquals(
array(2 => 2, 3 => 3, 4 => 4, 5 => 5),
$projectModel->getPriorities($project)
);
}
}