Add new automatic action to move a task to another column when closed
This commit is contained in:
parent
2a42e0e1aa
commit
9b2a32af78
|
|
@ -6,6 +6,7 @@ New features:
|
||||||
* New automated actions:
|
* New automated actions:
|
||||||
- Close tasks without activity in a specific column
|
- Close tasks without activity in a specific column
|
||||||
- Set due date automatically
|
- Set due date automatically
|
||||||
|
- Move a task to another column when closed
|
||||||
* Added internal task links to activity stream
|
* Added internal task links to activity stream
|
||||||
* Added new event for removed comments
|
* Added new event for removed comments
|
||||||
* Added search filter for task priority
|
* Added search filter for task priority
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use Kanboard\Event\GenericEvent;
|
||||||
/**
|
/**
|
||||||
* Base class for automatic actions
|
* Base class for automatic actions
|
||||||
*
|
*
|
||||||
* @package action
|
* @package Kanboard\Action
|
||||||
* @author Frederic Guillot
|
* @author Frederic Guillot
|
||||||
*/
|
*/
|
||||||
abstract class Base extends \Kanboard\Core\Base
|
abstract class Base extends \Kanboard\Core\Base
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ namespace Kanboard\Action;
|
||||||
/**
|
/**
|
||||||
* Create automatically a comment from a webhook
|
* Create automatically a comment from a webhook
|
||||||
*
|
*
|
||||||
* @package action
|
* @package Kanboard\Action
|
||||||
* @author Frederic Guillot
|
* @author Frederic Guillot
|
||||||
*/
|
*/
|
||||||
class CommentCreation extends Base
|
class CommentCreation extends Base
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||||
/**
|
/**
|
||||||
* Add a comment of the triggering event to the task description.
|
* Add a comment of the triggering event to the task description.
|
||||||
*
|
*
|
||||||
* @package action
|
* @package Kanboard\Action
|
||||||
* @author Oren Ben-Kiki
|
* @author Oren Ben-Kiki
|
||||||
*/
|
*/
|
||||||
class CommentCreationMoveTaskColumn extends Base
|
class CommentCreationMoveTaskColumn extends Base
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||||
/**
|
/**
|
||||||
* Set a category automatically according to the color
|
* Set a category automatically according to the color
|
||||||
*
|
*
|
||||||
* @package action
|
* @package Kanboard\Action
|
||||||
* @author Frederic Guillot
|
* @author Frederic Guillot
|
||||||
*/
|
*/
|
||||||
class TaskAssignCategoryColor extends Base
|
class TaskAssignCategoryColor extends Base
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ namespace Kanboard\Action;
|
||||||
/**
|
/**
|
||||||
* Set a category automatically according to a label
|
* Set a category automatically according to a label
|
||||||
*
|
*
|
||||||
* @package action
|
* @package Kanboard\Action
|
||||||
* @author Frederic Guillot
|
* @author Frederic Guillot
|
||||||
*/
|
*/
|
||||||
class TaskAssignCategoryLabel extends Base
|
class TaskAssignCategoryLabel extends Base
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use Kanboard\Model\TaskLinkModel;
|
||||||
/**
|
/**
|
||||||
* Set a category automatically according to a task link
|
* Set a category automatically according to a task link
|
||||||
*
|
*
|
||||||
* @package action
|
* @package Kanboard\Action
|
||||||
* @author Olivier Maridat
|
* @author Olivier Maridat
|
||||||
* @author Frederic Guillot
|
* @author Frederic Guillot
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||||
/**
|
/**
|
||||||
* Assign a color to a specific category
|
* Assign a color to a specific category
|
||||||
*
|
*
|
||||||
* @package action
|
* @package Kanboard\Action
|
||||||
* @author Frederic Guillot
|
* @author Frederic Guillot
|
||||||
*/
|
*/
|
||||||
class TaskAssignColorCategory extends Base
|
class TaskAssignColorCategory extends Base
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||||
/**
|
/**
|
||||||
* Assign a color to a task
|
* Assign a color to a task
|
||||||
*
|
*
|
||||||
* @package action
|
* @package Kanboard\Action
|
||||||
* @author Frederic Guillot
|
* @author Frederic Guillot
|
||||||
*/
|
*/
|
||||||
class TaskAssignColorColumn extends Base
|
class TaskAssignColorColumn extends Base
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use Kanboard\Model\TaskLinkModel;
|
||||||
/**
|
/**
|
||||||
* Assign a color to a specific task link
|
* Assign a color to a specific task link
|
||||||
*
|
*
|
||||||
* @package action
|
* @package Kanboard\Action
|
||||||
* @author Frederic Guillot
|
* @author Frederic Guillot
|
||||||
*/
|
*/
|
||||||
class TaskAssignColorLink extends Base
|
class TaskAssignColorLink extends Base
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||||
/**
|
/**
|
||||||
* Assign a color to a priority
|
* Assign a color to a priority
|
||||||
*
|
*
|
||||||
* @package action
|
* @package Kanboard\Action
|
||||||
* @author Frederic Guillot
|
* @author Frederic Guillot
|
||||||
*/
|
*/
|
||||||
class TaskAssignColorPriority extends Base
|
class TaskAssignColorPriority extends Base
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||||
/**
|
/**
|
||||||
* Assign a color to a specific user
|
* Assign a color to a specific user
|
||||||
*
|
*
|
||||||
* @package action
|
* @package Kanboard\Action
|
||||||
* @author Frederic Guillot
|
* @author Frederic Guillot
|
||||||
*/
|
*/
|
||||||
class TaskAssignColorUser extends Base
|
class TaskAssignColorUser extends Base
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||||
/**
|
/**
|
||||||
* Assign a task to the logged user
|
* Assign a task to the logged user
|
||||||
*
|
*
|
||||||
* @package action
|
* @package Kanboard\Action
|
||||||
* @author Frederic Guillot
|
* @author Frederic Guillot
|
||||||
*/
|
*/
|
||||||
class TaskAssignCurrentUser extends Base
|
class TaskAssignCurrentUser extends Base
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||||
/**
|
/**
|
||||||
* Assign a task to the logged user on column change
|
* Assign a task to the logged user on column change
|
||||||
*
|
*
|
||||||
* @package action
|
* @package Kanboard\Action
|
||||||
* @author Frederic Guillot
|
* @author Frederic Guillot
|
||||||
*/
|
*/
|
||||||
class TaskAssignCurrentUserColumn extends Base
|
class TaskAssignCurrentUserColumn extends Base
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||||
/**
|
/**
|
||||||
* Set the due date of task
|
* Set the due date of task
|
||||||
*
|
*
|
||||||
* @package action
|
* @package Kanboard\Action
|
||||||
* @author Frederic Guillot
|
* @author Frederic Guillot
|
||||||
*/
|
*/
|
||||||
class TaskAssignDueDateOnCreation extends Base
|
class TaskAssignDueDateOnCreation extends Base
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||||
/**
|
/**
|
||||||
* Assign a task to a specific user
|
* Assign a task to a specific user
|
||||||
*
|
*
|
||||||
* @package action
|
* @package Kanboard\Action
|
||||||
* @author Frederic Guillot
|
* @author Frederic Guillot
|
||||||
*/
|
*/
|
||||||
class TaskAssignSpecificUser extends Base
|
class TaskAssignSpecificUser extends Base
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ namespace Kanboard\Action;
|
||||||
/**
|
/**
|
||||||
* Assign a task to someone
|
* Assign a task to someone
|
||||||
*
|
*
|
||||||
* @package action
|
* @package Kanboard\Actionv
|
||||||
* @author Frederic Guillot
|
* @author Frederic Guillot
|
||||||
*/
|
*/
|
||||||
class TaskAssignUser extends Base
|
class TaskAssignUser extends Base
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ namespace Kanboard\Action;
|
||||||
/**
|
/**
|
||||||
* Close automatically a task
|
* Close automatically a task
|
||||||
*
|
*
|
||||||
* @package action
|
* @package Kanboard\Action
|
||||||
* @author Frederic Guillot
|
* @author Frederic Guillot
|
||||||
*/
|
*/
|
||||||
class TaskClose extends Base
|
class TaskClose extends Base
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||||
/**
|
/**
|
||||||
* Close automatically a task in a specific column
|
* Close automatically a task in a specific column
|
||||||
*
|
*
|
||||||
* @package action
|
* @package Kanboard\Action
|
||||||
* @author Frederic Guillot
|
* @author Frederic Guillot
|
||||||
*/
|
*/
|
||||||
class TaskCloseColumn extends Base
|
class TaskCloseColumn extends Base
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||||
/**
|
/**
|
||||||
* Close automatically a task after when inactive
|
* Close automatically a task after when inactive
|
||||||
*
|
*
|
||||||
* @package action
|
* @package Kanboard\Action
|
||||||
* @author Frederic Guillot
|
* @author Frederic Guillot
|
||||||
*/
|
*/
|
||||||
class TaskCloseNoActivity extends Base
|
class TaskCloseNoActivity extends Base
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||||
/**
|
/**
|
||||||
* Close automatically a task after inactive and in an defined column
|
* Close automatically a task after inactive and in an defined column
|
||||||
*
|
*
|
||||||
* @package action
|
* @package Kanboard\Action
|
||||||
* @author Frederic Guillot
|
* @author Frederic Guillot
|
||||||
*/
|
*/
|
||||||
class TaskCloseNoActivityColumn extends Base
|
class TaskCloseNoActivityColumn extends Base
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ namespace Kanboard\Action;
|
||||||
/**
|
/**
|
||||||
* Create automatically a task from a webhook
|
* Create automatically a task from a webhook
|
||||||
*
|
*
|
||||||
* @package action
|
* @package Kanboard\Action
|
||||||
* @author Frederic Guillot
|
* @author Frederic Guillot
|
||||||
*/
|
*/
|
||||||
class TaskCreation extends Base
|
class TaskCreation extends Base
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||||
/**
|
/**
|
||||||
* Duplicate a task to another project
|
* Duplicate a task to another project
|
||||||
*
|
*
|
||||||
* @package action
|
* @package Kanboard\Action
|
||||||
* @author Frederic Guillot
|
* @author Frederic Guillot
|
||||||
*/
|
*/
|
||||||
class TaskDuplicateAnotherProject extends Base
|
class TaskDuplicateAnotherProject extends Base
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||||
/**
|
/**
|
||||||
* Email a task to someone
|
* Email a task to someone
|
||||||
*
|
*
|
||||||
* @package action
|
* @package Kanboard\Action
|
||||||
* @author Frederic Guillot
|
* @author Frederic Guillot
|
||||||
*/
|
*/
|
||||||
class TaskEmail extends Base
|
class TaskEmail extends Base
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||||
/**
|
/**
|
||||||
* Email a task with no activity
|
* Email a task with no activity
|
||||||
*
|
*
|
||||||
* @package action
|
* @package Kanboard\Action
|
||||||
* @author Frederic Guillot
|
* @author Frederic Guillot
|
||||||
*/
|
*/
|
||||||
class TaskEmailNoActivity extends Base
|
class TaskEmailNoActivity extends Base
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||||
/**
|
/**
|
||||||
* Move a task to another project
|
* Move a task to another project
|
||||||
*
|
*
|
||||||
* @package action
|
* @package Kanboard\Action
|
||||||
* @author Frederic Guillot
|
* @author Frederic Guillot
|
||||||
*/
|
*/
|
||||||
class TaskMoveAnotherProject extends Base
|
class TaskMoveAnotherProject extends Base
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||||
/**
|
/**
|
||||||
* Move a task to another column when an assignee is set
|
* Move a task to another column when an assignee is set
|
||||||
*
|
*
|
||||||
* @package action
|
* @package Kanboard\Action
|
||||||
* @author Francois Ferrand
|
* @author Francois Ferrand
|
||||||
*/
|
*/
|
||||||
class TaskMoveColumnAssigned extends Base
|
class TaskMoveColumnAssigned extends Base
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||||
/**
|
/**
|
||||||
* Move a task to another column when the category is changed
|
* Move a task to another column when the category is changed
|
||||||
*
|
*
|
||||||
* @package action
|
* @package Kanboard\Action
|
||||||
* @author Francois Ferrand
|
* @author Francois Ferrand
|
||||||
*/
|
*/
|
||||||
class TaskMoveColumnCategoryChange extends Base
|
class TaskMoveColumnCategoryChange extends Base
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,102 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Kanboard\Action;
|
||||||
|
|
||||||
|
use Kanboard\Model\TaskModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move a task to another column when the task is closed
|
||||||
|
*
|
||||||
|
* @package Kanboard\Action
|
||||||
|
* @author Frederic Guillot
|
||||||
|
*/
|
||||||
|
class TaskMoveColumnClosed extends Base
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get automatic action description
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDescription()
|
||||||
|
{
|
||||||
|
return t('Move the task to another column when closed');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of compatible events
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getCompatibleEvents()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
TaskModel::EVENT_CLOSE,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the required parameter for the action (defined by the user)
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getActionRequiredParameters()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'dest_column_id' => t('Destination column'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the required parameter for the event
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
public function getEventRequiredParameters()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'task_id',
|
||||||
|
'task' => array(
|
||||||
|
'project_id',
|
||||||
|
'column_id',
|
||||||
|
'swimlane_id',
|
||||||
|
'is_active',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the action (move the task to another column)
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param array $data Event data dictionary
|
||||||
|
* @return bool True if the action was executed or false when not executed
|
||||||
|
*/
|
||||||
|
public function doAction(array $data)
|
||||||
|
{
|
||||||
|
return $this->taskPositionModel->movePosition(
|
||||||
|
$data['task']['project_id'],
|
||||||
|
$data['task']['id'],
|
||||||
|
$this->getParam('dest_column_id'),
|
||||||
|
1,
|
||||||
|
$data['task']['swimlane_id'],
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the event data meet the action condition
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param array $data Event data dictionary
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function hasRequiredCondition(array $data)
|
||||||
|
{
|
||||||
|
return $data['task']['column_id'] != $this->getParam('dest_column_id') && $data['task']['is_active'] == 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||||
/**
|
/**
|
||||||
* Move a task to another column when an assignee is cleared
|
* Move a task to another column when an assignee is cleared
|
||||||
*
|
*
|
||||||
* @package action
|
* @package Kanboard\Action
|
||||||
* @author Francois Ferrand
|
* @author Francois Ferrand
|
||||||
*/
|
*/
|
||||||
class TaskMoveColumnUnAssigned extends Base
|
class TaskMoveColumnUnAssigned extends Base
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ namespace Kanboard\Action;
|
||||||
/**
|
/**
|
||||||
* Open automatically a task
|
* Open automatically a task
|
||||||
*
|
*
|
||||||
* @package action
|
* @package Kanboard\Action
|
||||||
* @author Frederic Guillot
|
* @author Frederic Guillot
|
||||||
*/
|
*/
|
||||||
class TaskOpen extends Base
|
class TaskOpen extends Base
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||||
/**
|
/**
|
||||||
* Set the start date of task
|
* Set the start date of task
|
||||||
*
|
*
|
||||||
* @package action
|
* @package Kanboard\Action
|
||||||
* @author Frederic Guillot
|
* @author Frederic Guillot
|
||||||
*/
|
*/
|
||||||
class TaskUpdateStartDate extends Base
|
class TaskUpdateStartDate extends Base
|
||||||
|
|
|
||||||
|
|
@ -16,15 +16,16 @@ class TaskPositionModel extends Base
|
||||||
* Move a task to another column or to another position
|
* Move a task to another column or to another position
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param integer $project_id Project id
|
* @param integer $project_id Project id
|
||||||
* @param integer $task_id Task id
|
* @param integer $task_id Task id
|
||||||
* @param integer $column_id Column id
|
* @param integer $column_id Column id
|
||||||
* @param integer $position Position (must be >= 1)
|
* @param integer $position Position (must be >= 1)
|
||||||
* @param integer $swimlane_id Swimlane id
|
* @param integer $swimlane_id Swimlane id
|
||||||
* @param boolean $fire_events Fire events
|
* @param boolean $fire_events Fire events
|
||||||
* @return boolean
|
* @param bool $onlyOpen Do not move closed tasks
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function movePosition($project_id, $task_id, $column_id, $position, $swimlane_id = 0, $fire_events = true)
|
public function movePosition($project_id, $task_id, $column_id, $position, $swimlane_id = 0, $fire_events = true, $onlyOpen = true)
|
||||||
{
|
{
|
||||||
if ($position < 1) {
|
if ($position < 1) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -32,7 +33,7 @@ class TaskPositionModel extends Base
|
||||||
|
|
||||||
$task = $this->taskFinderModel->getById($task_id);
|
$task = $this->taskFinderModel->getById($task_id);
|
||||||
|
|
||||||
if ($task['is_active'] == TaskModel::STATUS_CLOSED) {
|
if ($onlyOpen && $task['is_active'] == TaskModel::STATUS_CLOSED) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ namespace Kanboard\ServiceProvider;
|
||||||
|
|
||||||
use Kanboard\Action\TaskAssignColorPriority;
|
use Kanboard\Action\TaskAssignColorPriority;
|
||||||
use Kanboard\Action\TaskAssignDueDateOnCreation;
|
use Kanboard\Action\TaskAssignDueDateOnCreation;
|
||||||
|
use Kanboard\Action\TaskMoveColumnClosed;
|
||||||
use Pimple\Container;
|
use Pimple\Container;
|
||||||
use Pimple\ServiceProviderInterface;
|
use Pimple\ServiceProviderInterface;
|
||||||
use Kanboard\Core\Action\ActionManager;
|
use Kanboard\Core\Action\ActionManager;
|
||||||
|
|
@ -78,6 +79,7 @@ class ActionProvider implements ServiceProviderInterface
|
||||||
$container['actionManager']->register(new TaskMoveAnotherProject($container));
|
$container['actionManager']->register(new TaskMoveAnotherProject($container));
|
||||||
$container['actionManager']->register(new TaskMoveColumnAssigned($container));
|
$container['actionManager']->register(new TaskMoveColumnAssigned($container));
|
||||||
$container['actionManager']->register(new TaskMoveColumnCategoryChange($container));
|
$container['actionManager']->register(new TaskMoveColumnCategoryChange($container));
|
||||||
|
$container['actionManager']->register(new TaskMoveColumnClosed($container));
|
||||||
$container['actionManager']->register(new TaskMoveColumnUnAssigned($container));
|
$container['actionManager']->register(new TaskMoveColumnUnAssigned($container));
|
||||||
$container['actionManager']->register(new TaskOpen($container));
|
$container['actionManager']->register(new TaskOpen($container));
|
||||||
$container['actionManager']->register(new TaskUpdateStartDate($container));
|
$container['actionManager']->register(new TaskUpdateStartDate($container));
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,91 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Kanboard\Action\TaskMoveColumnClosed;
|
||||||
|
use Kanboard\EventBuilder\TaskEventBuilder;
|
||||||
|
use Kanboard\Model\ProjectModel;
|
||||||
|
use Kanboard\Model\TaskCreationModel;
|
||||||
|
use Kanboard\Model\TaskFinderModel;
|
||||||
|
use Kanboard\Model\TaskModel;
|
||||||
|
|
||||||
|
require_once __DIR__.'/../Base.php';
|
||||||
|
|
||||||
|
class TaskMoveColumnClosedTest extends Base
|
||||||
|
{
|
||||||
|
public function testSuccess()
|
||||||
|
{
|
||||||
|
$projectModel = new ProjectModel($this->container);
|
||||||
|
$taskCreationModel = new TaskCreationModel($this->container);
|
||||||
|
$taskFinderModel = new TaskFinderModel($this->container);
|
||||||
|
|
||||||
|
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
|
||||||
|
$this->assertEquals(2, $projectModel->create(array('name' => 'test2')));
|
||||||
|
$this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test', 'is_active' => 0)));
|
||||||
|
|
||||||
|
$event = TaskEventBuilder::getInstance($this->container)
|
||||||
|
->withTaskId(1)
|
||||||
|
->buildEvent();
|
||||||
|
|
||||||
|
$action = new TaskMoveColumnClosed($this->container);
|
||||||
|
$action->setProjectId(1);
|
||||||
|
$action->setParam('dest_column_id', 2);
|
||||||
|
|
||||||
|
$this->assertTrue($action->execute($event, TaskModel::EVENT_CLOSE));
|
||||||
|
|
||||||
|
$task = $taskFinderModel->getById(1);
|
||||||
|
$this->assertNotEmpty($task);
|
||||||
|
$this->assertEquals('test', $task['title']);
|
||||||
|
$this->assertEquals(2, $task['column_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testWhenTaskIsOpen()
|
||||||
|
{
|
||||||
|
$projectModel = new ProjectModel($this->container);
|
||||||
|
$taskCreationModel = new TaskCreationModel($this->container);
|
||||||
|
$taskFinderModel = new TaskFinderModel($this->container);
|
||||||
|
|
||||||
|
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
|
||||||
|
$this->assertEquals(2, $projectModel->create(array('name' => 'test2')));
|
||||||
|
$this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));
|
||||||
|
|
||||||
|
$event = TaskEventBuilder::getInstance($this->container)
|
||||||
|
->withTaskId(1)
|
||||||
|
->buildEvent();
|
||||||
|
|
||||||
|
$action = new TaskMoveColumnClosed($this->container);
|
||||||
|
$action->setProjectId(1);
|
||||||
|
$action->setParam('dest_column_id', 2);
|
||||||
|
|
||||||
|
$this->assertFalse($action->execute($event, TaskModel::EVENT_CLOSE));
|
||||||
|
|
||||||
|
$task = $taskFinderModel->getById(1);
|
||||||
|
$this->assertNotEmpty($task);
|
||||||
|
$this->assertEquals('test', $task['title']);
|
||||||
|
$this->assertEquals(1, $task['column_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testWhenTaskIsAlreadyInDestinationColumn()
|
||||||
|
{
|
||||||
|
$projectModel = new ProjectModel($this->container);
|
||||||
|
$taskCreationModel = new TaskCreationModel($this->container);
|
||||||
|
$taskFinderModel = new TaskFinderModel($this->container);
|
||||||
|
|
||||||
|
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
|
||||||
|
$this->assertEquals(2, $projectModel->create(array('name' => 'test2')));
|
||||||
|
$this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test', 'is_active' => 0, 'column_id' => 2)));
|
||||||
|
|
||||||
|
$event = TaskEventBuilder::getInstance($this->container)
|
||||||
|
->withTaskId(1)
|
||||||
|
->buildEvent();
|
||||||
|
|
||||||
|
$action = new TaskMoveColumnClosed($this->container);
|
||||||
|
$action->setProjectId(1);
|
||||||
|
$action->setParam('dest_column_id', 2);
|
||||||
|
|
||||||
|
$this->assertFalse($action->execute($event, TaskModel::EVENT_CLOSE));
|
||||||
|
|
||||||
|
$task = $taskFinderModel->getById(1);
|
||||||
|
$this->assertNotEmpty($task);
|
||||||
|
$this->assertEquals('test', $task['title']);
|
||||||
|
$this->assertEquals(2, $task['column_id']);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue