Create TaskDuplication model
This commit is contained in:
@@ -17,6 +17,7 @@ use Core\Tool;
|
|||||||
* @property \Model\Task $task
|
* @property \Model\Task $task
|
||||||
* @property \Model\TaskCreation $taskCreation
|
* @property \Model\TaskCreation $taskCreation
|
||||||
* @property \Model\TaskModification $taskModification
|
* @property \Model\TaskModification $taskModification
|
||||||
|
* @property \Model\TaskDuplication $taskDuplication
|
||||||
* @property \Model\TaskFinder $taskFinder
|
* @property \Model\TaskFinder $taskFinder
|
||||||
* @property \Model\TaskStatus $taskStatus
|
* @property \Model\TaskStatus $taskStatus
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -64,9 +64,7 @@ class TaskDuplicateAnotherProject extends Base
|
|||||||
*/
|
*/
|
||||||
public function doAction(array $data)
|
public function doAction(array $data)
|
||||||
{
|
{
|
||||||
$task = $this->taskFinder->getById($data['task_id']);
|
return (bool) $this->taskDuplication->duplicateToProject($data['task_id'], $this->getParam('project_id'));
|
||||||
$this->task->duplicateToAnotherProject($this->getParam('project_id'), $task);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -64,9 +64,7 @@ class TaskMoveAnotherProject extends Base
|
|||||||
*/
|
*/
|
||||||
public function doAction(array $data)
|
public function doAction(array $data)
|
||||||
{
|
{
|
||||||
$task = $this->taskFinder->getById($data['task_id']);
|
return $this->taskDuplication->moveToProject($data['task_id'], $this->getParam('project_id'));
|
||||||
$this->task->moveToAnotherProject($this->getParam('project_id'), $task);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ use Model\LastLogin;
|
|||||||
* @property \Model\Task $task
|
* @property \Model\Task $task
|
||||||
* @property \Model\TaskCreation $taskCreation
|
* @property \Model\TaskCreation $taskCreation
|
||||||
* @property \Model\TaskModification $taskModification
|
* @property \Model\TaskModification $taskModification
|
||||||
|
* @property \Model\TaskDuplication $taskDuplication
|
||||||
* @property \Model\TaskHistory $taskHistory
|
* @property \Model\TaskHistory $taskHistory
|
||||||
* @property \Model\TaskExport $taskExport
|
* @property \Model\TaskExport $taskExport
|
||||||
* @property \Model\TaskFinder $taskFinder
|
* @property \Model\TaskFinder $taskFinder
|
||||||
|
|||||||
@@ -352,7 +352,7 @@ class Task extends Base
|
|||||||
if ($this->request->getStringParam('confirmation') === 'yes') {
|
if ($this->request->getStringParam('confirmation') === 'yes') {
|
||||||
|
|
||||||
$this->checkCSRFParam();
|
$this->checkCSRFParam();
|
||||||
$task_id = $this->task->duplicateToSameProject($task);
|
$task_id = $this->taskDuplication->duplicate($task['id']);
|
||||||
|
|
||||||
if ($task_id) {
|
if ($task_id) {
|
||||||
$this->session->flash(t('Task created successfully.'));
|
$this->session->flash(t('Task created successfully.'));
|
||||||
@@ -428,7 +428,36 @@ class Task extends Base
|
|||||||
*/
|
*/
|
||||||
public function move()
|
public function move()
|
||||||
{
|
{
|
||||||
$this->toAnotherProject('move');
|
$task = $this->getTask();
|
||||||
|
$values = $task;
|
||||||
|
$errors = array();
|
||||||
|
$projects_list = $this->projectPermission->getMemberProjects($this->acl->getUserId());
|
||||||
|
|
||||||
|
unset($projects_list[$task['project_id']]);
|
||||||
|
|
||||||
|
if ($this->request->isPost()) {
|
||||||
|
|
||||||
|
$values = $this->request->getValues();
|
||||||
|
list($valid, $errors) = $this->taskValidator->validateProjectModification($values);
|
||||||
|
|
||||||
|
if ($valid) {
|
||||||
|
|
||||||
|
if ($this->taskDuplication->moveToProject($task['id'], $values['project_id'])) {
|
||||||
|
$this->session->flash(t('Task updated successfully.'));
|
||||||
|
$this->response->redirect('?controller=task&action=show&task_id='.$task['id']);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$this->session->flashError(t('Unable to update your task.'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->response->html($this->taskLayout('task_move_project', array(
|
||||||
|
'values' => $values,
|
||||||
|
'errors' => $errors,
|
||||||
|
'task' => $task,
|
||||||
|
'projects_list' => $projects_list,
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -437,16 +466,6 @@ class Task extends Base
|
|||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
public function copy()
|
public function copy()
|
||||||
{
|
|
||||||
$this->toAnotherProject('duplicate');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Common methods between the actions "move" and "copy"
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
*/
|
|
||||||
private function toAnotherProject($action)
|
|
||||||
{
|
{
|
||||||
$task = $this->getTask();
|
$task = $this->getTask();
|
||||||
$values = $task;
|
$values = $task;
|
||||||
@@ -461,7 +480,7 @@ class Task extends Base
|
|||||||
list($valid, $errors) = $this->taskValidator->validateProjectModification($values);
|
list($valid, $errors) = $this->taskValidator->validateProjectModification($values);
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
$task_id = $this->task->{$action.'ToAnotherProject'}($values['project_id'], $task);
|
$task_id = $this->taskDuplication->duplicateToProject($task['id'], $values['project_id']);
|
||||||
if ($task_id) {
|
if ($task_id) {
|
||||||
$this->session->flash(t('Task created successfully.'));
|
$this->session->flash(t('Task created successfully.'));
|
||||||
$this->response->redirect('?controller=task&action=show&task_id='.$task_id);
|
$this->response->redirect('?controller=task&action=show&task_id='.$task_id);
|
||||||
@@ -472,7 +491,7 @@ class Task extends Base
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->response->html($this->taskLayout('task_'.$action.'_project', array(
|
$this->response->html($this->taskLayout('task_duplicate_project', array(
|
||||||
'values' => $values,
|
'values' => $values,
|
||||||
'errors' => $errors,
|
'errors' => $errors,
|
||||||
'task' => $task,
|
'task' => $task,
|
||||||
|
|||||||
@@ -45,6 +45,34 @@ class Category extends Base
|
|||||||
return $this->db->table(self::TABLE)->eq('id', $category_id)->findOne();
|
return $this->db->table(self::TABLE)->eq('id', $category_id)->findOne();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the category name by the id
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param integer $category_id Category id
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getNameById($category_id)
|
||||||
|
{
|
||||||
|
return $this->db->table(self::TABLE)->eq('id', $category_id)->findOneColumn('name') ?: '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a category id by the project and the name
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param integer $project_id Project id
|
||||||
|
* @param string $category_name Category name
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
public function getIdByName($project_id, $category_name)
|
||||||
|
{
|
||||||
|
return (int) $this->db->table(self::TABLE)
|
||||||
|
->eq('project_id', $project_id)
|
||||||
|
->eq('name', $category_name)
|
||||||
|
->findOneColumn('id');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the list of all categories
|
* Return the list of all categories
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -193,22 +193,22 @@ class SubTask extends Base
|
|||||||
*/
|
*/
|
||||||
public function duplicate($src_task_id, $dst_task_id)
|
public function duplicate($src_task_id, $dst_task_id)
|
||||||
{
|
{
|
||||||
$subtasks = $this->db->table(self::TABLE)
|
return $this->db->transaction(function ($db) use ($src_task_id, $dst_task_id) {
|
||||||
->columns('title', 'time_estimated')
|
|
||||||
->eq('task_id', $src_task_id)
|
|
||||||
->findAll();
|
|
||||||
|
|
||||||
foreach ($subtasks as &$subtask) {
|
$subtasks = $db->table(self::TABLE)
|
||||||
|
->columns('title', 'time_estimated')
|
||||||
|
->eq('task_id', $src_task_id)
|
||||||
|
->findAll();
|
||||||
|
|
||||||
$subtask['task_id'] = $dst_task_id;
|
foreach ($subtasks as &$subtask) {
|
||||||
$subtask['time_spent'] = 0;
|
|
||||||
|
|
||||||
if (! $this->db->table(self::TABLE)->save($subtask)) {
|
$subtask['task_id'] = $dst_task_id;
|
||||||
return false;
|
|
||||||
|
if (! $db->table(self::TABLE)->save($subtask)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -57,136 +57,6 @@ class Task extends Base
|
|||||||
return $this->db->table(self::TABLE)->eq('id', $task_id)->remove();
|
return $this->db->table(self::TABLE)->eq('id', $task_id)->remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Move a task to another project
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @param integer $project_id Project id
|
|
||||||
* @param array $task Task data
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public function moveToAnotherProject($project_id, array $task)
|
|
||||||
{
|
|
||||||
$values = array();
|
|
||||||
|
|
||||||
// Clear values (categories are different for each project)
|
|
||||||
$values['category_id'] = 0;
|
|
||||||
$values['owner_id'] = 0;
|
|
||||||
|
|
||||||
// Check if the assigned user is allowed for the new project
|
|
||||||
if ($task['owner_id'] && $this->projectPermission->isUserAllowed($project_id, $task['owner_id'])) {
|
|
||||||
$values['owner_id'] = $task['owner_id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// We use the first column of the new project
|
|
||||||
$values['column_id'] = $this->board->getFirstColumn($project_id);
|
|
||||||
$values['position'] = $this->taskFinder->countByColumnId($project_id, $values['column_id']) + 1;
|
|
||||||
$values['project_id'] = $project_id;
|
|
||||||
|
|
||||||
// The task will be open (close event binding)
|
|
||||||
$values['is_active'] = 1;
|
|
||||||
|
|
||||||
if ($this->db->table(self::TABLE)->eq('id', $task['id'])->update($values)) {
|
|
||||||
return $task['id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generic method to duplicate a task
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @param array $task Task data
|
|
||||||
* @param array $override Task properties to override
|
|
||||||
* @return integer|boolean
|
|
||||||
*/
|
|
||||||
public function copy(array $task, array $override = array())
|
|
||||||
{
|
|
||||||
// Values to override
|
|
||||||
if (! empty($override)) {
|
|
||||||
$task = $override + $task;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->db->startTransaction();
|
|
||||||
|
|
||||||
// Assign new values
|
|
||||||
$values = array();
|
|
||||||
$values['title'] = $task['title'];
|
|
||||||
$values['description'] = $task['description'];
|
|
||||||
$values['date_creation'] = time();
|
|
||||||
$values['date_modification'] = $values['date_creation'];
|
|
||||||
$values['date_due'] = $task['date_due'];
|
|
||||||
$values['color_id'] = $task['color_id'];
|
|
||||||
$values['project_id'] = $task['project_id'];
|
|
||||||
$values['column_id'] = $task['column_id'];
|
|
||||||
$values['owner_id'] = 0;
|
|
||||||
$values['creator_id'] = $task['creator_id'];
|
|
||||||
$values['position'] = $this->taskFinder->countByColumnId($values['project_id'], $values['column_id']) + 1;
|
|
||||||
$values['score'] = $task['score'];
|
|
||||||
$values['category_id'] = 0;
|
|
||||||
|
|
||||||
// Check if the assigned user is allowed for the new project
|
|
||||||
if ($task['owner_id'] && $this->projectPermission->isUserAllowed($values['project_id'], $task['owner_id'])) {
|
|
||||||
$values['owner_id'] = $task['owner_id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the category exists
|
|
||||||
if ($task['category_id'] && $this->category->exists($task['category_id'], $task['project_id'])) {
|
|
||||||
$values['category_id'] = $task['category_id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save task
|
|
||||||
if (! $this->db->table(Task::TABLE)->save($values)) {
|
|
||||||
$this->db->cancelTransaction();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$task_id = $this->db->getConnection()->getLastId();
|
|
||||||
|
|
||||||
// Duplicate subtasks
|
|
||||||
if (! $this->subTask->duplicate($task['id'], $task_id)) {
|
|
||||||
$this->db->cancelTransaction();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->db->closeTransaction();
|
|
||||||
|
|
||||||
// Trigger events
|
|
||||||
$this->event->trigger(Task::EVENT_CREATE_UPDATE, array('task_id' => $task_id) + $values);
|
|
||||||
$this->event->trigger(Task::EVENT_CREATE, array('task_id' => $task_id) + $values);
|
|
||||||
|
|
||||||
return $task_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Duplicate a task to the same project
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @param array $task Task data
|
|
||||||
* @return integer|boolean
|
|
||||||
*/
|
|
||||||
public function duplicateToSameProject($task)
|
|
||||||
{
|
|
||||||
return $this->copy($task);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Duplicate a task to another project (always copy to the first column)
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @param integer $project_id Destination project id
|
|
||||||
* @param array $task Task data
|
|
||||||
* @return integer|boolean
|
|
||||||
*/
|
|
||||||
public function duplicateToAnotherProject($project_id, array $task)
|
|
||||||
{
|
|
||||||
return $this->copy($task, array(
|
|
||||||
'project_id' => $project_id,
|
|
||||||
'column_id' => $this->board->getFirstColumn($project_id),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a the task id from a text
|
* Get a the task id from a text
|
||||||
*
|
*
|
||||||
|
|||||||
145
app/Model/TaskDuplication.php
Normal file
145
app/Model/TaskDuplication.php
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Task Duplication
|
||||||
|
*
|
||||||
|
* @package model
|
||||||
|
* @author Frederic Guillot
|
||||||
|
*/
|
||||||
|
class TaskDuplication extends Base
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Fields to copy when duplicating a task
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $fields_to_duplicate = array(
|
||||||
|
'title',
|
||||||
|
'description',
|
||||||
|
'date_due',
|
||||||
|
'color_id',
|
||||||
|
'project_id',
|
||||||
|
'column_id',
|
||||||
|
'owner_id',
|
||||||
|
'score',
|
||||||
|
'category_id',
|
||||||
|
'time_estimated',
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Duplicate a task to the same project
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param integer $task_id Task id
|
||||||
|
* @return boolean|integer Duplicated task id
|
||||||
|
*/
|
||||||
|
public function duplicate($task_id)
|
||||||
|
{
|
||||||
|
return $this->save($task_id, $this->copyFields($task_id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Duplicate a task to another project
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param integer $task_id Task id
|
||||||
|
* @param integer $project_id Project id
|
||||||
|
* @return boolean|integer Duplicated task id
|
||||||
|
*/
|
||||||
|
public function duplicateToProject($task_id, $project_id)
|
||||||
|
{
|
||||||
|
$values = $this->copyFields($task_id);
|
||||||
|
$values['project_id'] = $project_id;
|
||||||
|
$values['column_id'] = $this->board->getFirstColumn($project_id);
|
||||||
|
|
||||||
|
$this->checkDestinationProjectValues($values);
|
||||||
|
|
||||||
|
return $this->save($task_id, $values);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move a task to another project
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param integer $task_id Task id
|
||||||
|
* @param integer $project_id Project id
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function moveToProject($task_id, $project_id)
|
||||||
|
{
|
||||||
|
$task = $this->taskFinder->getById($task_id);
|
||||||
|
|
||||||
|
$values = array();
|
||||||
|
$values['is_active'] = 1;
|
||||||
|
$values['project_id'] = $project_id;
|
||||||
|
$values['column_id'] = $this->board->getFirstColumn($project_id);
|
||||||
|
$values['position'] = $this->taskFinder->countByColumnId($project_id, $values['column_id']) + 1;
|
||||||
|
$values['owner_id'] = $task['owner_id'];
|
||||||
|
$values['category_id'] = $task['category_id'];
|
||||||
|
|
||||||
|
$this->checkDestinationProjectValues($values);
|
||||||
|
|
||||||
|
return $this->db->table(Task::TABLE)->eq('id', $task['id'])->update($values);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the assignee and the category are available in the destination project
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @param array $values
|
||||||
|
*/
|
||||||
|
private function checkDestinationProjectValues(&$values)
|
||||||
|
{
|
||||||
|
// Check if the assigned user is allowed for the destination project
|
||||||
|
if ($values['owner_id'] > 0 && ! $this->projectPermission->isUserAllowed($values['project_id'], $values['owner_id'])) {
|
||||||
|
$values['owner_id'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the category exists for the destination project
|
||||||
|
if ($values['category_id'] > 0) {
|
||||||
|
$category_name = $this->category->getNameById($values['category_id']);
|
||||||
|
$values['category_id'] = $this->category->getIdByName($values['project_id'], $category_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Duplicate fields for the new task
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @param integer $task_id Task id
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function copyFields($task_id)
|
||||||
|
{
|
||||||
|
$task = $this->taskFinder->getById($task_id);
|
||||||
|
$values = array();
|
||||||
|
|
||||||
|
foreach ($this->fields_to_duplicate as $field) {
|
||||||
|
$values[$field] = $task[$field];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $values;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the new task and duplicate subtasks
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @param integer $task_id Task id
|
||||||
|
* @param array $values Form values
|
||||||
|
* @return boolean|integer
|
||||||
|
*/
|
||||||
|
private function save($task_id, array $values)
|
||||||
|
{
|
||||||
|
$new_task_id = $this->taskCreation->create($values);
|
||||||
|
|
||||||
|
if ($new_task_id) {
|
||||||
|
$this->subTask->duplicate($task_id, $new_task_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $new_task_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -77,6 +77,7 @@ class ActionTaskDuplicateAnotherProject extends Base
|
|||||||
// Our event should be executed because we define a different project
|
// Our event should be executed because we define a different project
|
||||||
$action->setParam('column_id', 2);
|
$action->setParam('column_id', 2);
|
||||||
$action->setParam('project_id', 2);
|
$action->setParam('project_id', 2);
|
||||||
|
$this->assertTrue($action->hasRequiredCondition($event));
|
||||||
$this->assertTrue($action->execute($event));
|
$this->assertTrue($action->execute($event));
|
||||||
|
|
||||||
// Our task should be assigned to the project 1
|
// Our task should be assigned to the project 1
|
||||||
|
|||||||
@@ -32,6 +32,12 @@ class CategoryTest extends Base
|
|||||||
$this->assertEquals(2, $category['id']);
|
$this->assertEquals(2, $category['id']);
|
||||||
$this->assertEquals('Category #2', $category['name']);
|
$this->assertEquals('Category #2', $category['name']);
|
||||||
$this->assertEquals(1, $category['project_id']);
|
$this->assertEquals(1, $category['project_id']);
|
||||||
|
|
||||||
|
$this->assertEquals(2, $c->getIdByName(1, 'Category #2'));
|
||||||
|
$this->assertEquals(0, $c->getIdByName(2, 'Category #2'));
|
||||||
|
|
||||||
|
$this->assertEquals('Category #2', $c->getNameById(2));
|
||||||
|
$this->assertEquals('', $c->getNameById(23));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRemove()
|
public function testRemove()
|
||||||
|
|||||||
327
tests/units/TaskDuplicationTest.php
Normal file
327
tests/units/TaskDuplicationTest.php
Normal file
@@ -0,0 +1,327 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__.'/Base.php';
|
||||||
|
|
||||||
|
use Model\Task;
|
||||||
|
use Model\TaskCreation;
|
||||||
|
use Model\TaskDuplication;
|
||||||
|
use Model\TaskFinder;
|
||||||
|
use Model\TaskStatus;
|
||||||
|
use Model\Project;
|
||||||
|
use Model\ProjectPermission;
|
||||||
|
use Model\Category;
|
||||||
|
use Model\User;
|
||||||
|
|
||||||
|
class TaskDuplicationTest extends Base
|
||||||
|
{
|
||||||
|
public function testDuplicateSameProject()
|
||||||
|
{
|
||||||
|
$td = new TaskDuplication($this->container);
|
||||||
|
$tc = new TaskCreation($this->container);
|
||||||
|
$tf = new TaskFinder($this->container);
|
||||||
|
$p = new Project($this->container);
|
||||||
|
$c = new Category($this->container);
|
||||||
|
|
||||||
|
// We create a task and a project
|
||||||
|
$this->assertEquals(1, $p->create(array('name' => 'test1')));
|
||||||
|
|
||||||
|
// Some categories
|
||||||
|
$this->assertNotFalse($c->create(array('name' => 'Category #1', 'project_id' => 1)));
|
||||||
|
$this->assertNotFalse($c->create(array('name' => 'Category #2', 'project_id' => 1)));
|
||||||
|
$this->assertTrue($c->exists(1, 1));
|
||||||
|
$this->assertTrue($c->exists(2, 1));
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
1,
|
||||||
|
$tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1, 'category_id' => 2, 'time_spent' => 4.4)
|
||||||
|
));
|
||||||
|
|
||||||
|
$task = $tf->getById(1);
|
||||||
|
$this->assertNotEmpty($task);
|
||||||
|
$this->assertEquals(1, $task['position']);
|
||||||
|
$this->assertEquals(1, $task['project_id']);
|
||||||
|
$this->assertEquals(3, $task['column_id']);
|
||||||
|
$this->assertEquals(2, $task['category_id']);
|
||||||
|
$this->assertEquals(4.4, $task['time_spent']);
|
||||||
|
|
||||||
|
// We duplicate our task
|
||||||
|
$this->assertEquals(2, $td->duplicate(1));
|
||||||
|
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_CREATE));
|
||||||
|
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_CREATE_UPDATE));
|
||||||
|
|
||||||
|
// Check the values of the duplicated task
|
||||||
|
$task = $tf->getById(2);
|
||||||
|
$this->assertNotEmpty($task);
|
||||||
|
$this->assertEquals(Task::STATUS_OPEN, $task['is_active']);
|
||||||
|
$this->assertEquals(1, $task['project_id']);
|
||||||
|
$this->assertEquals(1, $task['owner_id']);
|
||||||
|
$this->assertEquals(2, $task['category_id']);
|
||||||
|
$this->assertEquals(3, $task['column_id']);
|
||||||
|
$this->assertEquals(2, $task['position']);
|
||||||
|
$this->assertEquals('test', $task['title']);
|
||||||
|
$this->assertEquals(0, $task['time_spent']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDuplicateAnotherProject()
|
||||||
|
{
|
||||||
|
$td = new TaskDuplication($this->container);
|
||||||
|
$tc = new TaskCreation($this->container);
|
||||||
|
$tf = new TaskFinder($this->container);
|
||||||
|
$p = new Project($this->container);
|
||||||
|
$c = new Category($this->container);
|
||||||
|
|
||||||
|
// We create 2 projects
|
||||||
|
$this->assertEquals(1, $p->create(array('name' => 'test1')));
|
||||||
|
$this->assertEquals(2, $p->create(array('name' => 'test2')));
|
||||||
|
|
||||||
|
$this->assertNotFalse($c->create(array('name' => 'Category #1', 'project_id' => 1)));
|
||||||
|
$this->assertTrue($c->exists(1, 1));
|
||||||
|
|
||||||
|
// We create a task
|
||||||
|
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 1, 'category_id' => 1)));
|
||||||
|
|
||||||
|
// We duplicate our task to the 2nd project
|
||||||
|
$this->assertEquals(2, $td->duplicateToProject(1, 2));
|
||||||
|
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_CREATE));
|
||||||
|
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_CREATE_UPDATE));
|
||||||
|
|
||||||
|
// Check the values of the duplicated task
|
||||||
|
$task = $tf->getById(2);
|
||||||
|
$this->assertNotEmpty($task);
|
||||||
|
$this->assertEquals(1, $task['owner_id']);
|
||||||
|
$this->assertEquals(0, $task['category_id']);
|
||||||
|
$this->assertEquals(5, $task['column_id']);
|
||||||
|
$this->assertEquals(1, $task['position']);
|
||||||
|
$this->assertEquals(2, $task['project_id']);
|
||||||
|
$this->assertEquals('test', $task['title']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDuplicateAnotherProjectWithCategory()
|
||||||
|
{
|
||||||
|
$td = new TaskDuplication($this->container);
|
||||||
|
$tc = new TaskCreation($this->container);
|
||||||
|
$tf = new TaskFinder($this->container);
|
||||||
|
$p = new Project($this->container);
|
||||||
|
$c = new Category($this->container);
|
||||||
|
|
||||||
|
// We create 2 projects
|
||||||
|
$this->assertEquals(1, $p->create(array('name' => 'test1')));
|
||||||
|
$this->assertEquals(2, $p->create(array('name' => 'test2')));
|
||||||
|
|
||||||
|
$this->assertNotFalse($c->create(array('name' => 'Category #1', 'project_id' => 1)));
|
||||||
|
$this->assertNotFalse($c->create(array('name' => 'Category #1', 'project_id' => 2)));
|
||||||
|
$this->assertTrue($c->exists(1, 1));
|
||||||
|
$this->assertTrue($c->exists(2, 2));
|
||||||
|
|
||||||
|
// We create a task
|
||||||
|
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'category_id' => 1)));
|
||||||
|
|
||||||
|
// We duplicate our task to the 2nd project
|
||||||
|
$this->assertEquals(2, $td->duplicateToProject(1, 2));
|
||||||
|
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_CREATE));
|
||||||
|
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_CREATE_UPDATE));
|
||||||
|
|
||||||
|
// Check the values of the duplicated task
|
||||||
|
$task = $tf->getById(2);
|
||||||
|
$this->assertNotEmpty($task);
|
||||||
|
$this->assertEquals(0, $task['owner_id']);
|
||||||
|
$this->assertEquals(2, $task['category_id']);
|
||||||
|
$this->assertEquals(5, $task['column_id']);
|
||||||
|
$this->assertEquals(1, $task['position']);
|
||||||
|
$this->assertEquals(2, $task['project_id']);
|
||||||
|
$this->assertEquals('test', $task['title']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDuplicateAnotherProjectWithUser()
|
||||||
|
{
|
||||||
|
$td = new TaskDuplication($this->container);
|
||||||
|
$tc = new TaskCreation($this->container);
|
||||||
|
$tf = new TaskFinder($this->container);
|
||||||
|
$p = new Project($this->container);
|
||||||
|
$pp = new ProjectPermission($this->container);
|
||||||
|
|
||||||
|
// We create 2 projects
|
||||||
|
$this->assertEquals(1, $p->create(array('name' => 'test1')));
|
||||||
|
$this->assertEquals(2, $p->create(array('name' => 'test2')));
|
||||||
|
|
||||||
|
// We create a task
|
||||||
|
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 2)));
|
||||||
|
|
||||||
|
// We duplicate our task to the 2nd project
|
||||||
|
$this->assertEquals(2, $td->duplicateToProject(1, 2));
|
||||||
|
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_CREATE));
|
||||||
|
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_CREATE_UPDATE));
|
||||||
|
|
||||||
|
// Check the values of the duplicated task
|
||||||
|
$task = $tf->getById(2);
|
||||||
|
$this->assertNotEmpty($task);
|
||||||
|
$this->assertEquals(0, $task['owner_id']);
|
||||||
|
$this->assertEquals(5, $task['column_id']);
|
||||||
|
$this->assertEquals(1, $task['position']);
|
||||||
|
$this->assertEquals(2, $task['project_id']);
|
||||||
|
$this->assertEquals('test', $task['title']);
|
||||||
|
|
||||||
|
// We create a new user for our project
|
||||||
|
$user = new User($this->container);
|
||||||
|
$this->assertNotFalse($user->create(array('username' => 'unittest#1', 'password' => 'unittest')));
|
||||||
|
$this->assertTrue($pp->allowUser(1, 2));
|
||||||
|
$this->assertTrue($pp->allowUser(2, 2));
|
||||||
|
$this->assertTrue($pp->isUserAllowed(1, 2));
|
||||||
|
$this->assertTrue($pp->isUserAllowed(2, 2));
|
||||||
|
|
||||||
|
// We duplicate our task to the 2nd project
|
||||||
|
$this->assertEquals(3, $td->duplicateToProject(1, 2));
|
||||||
|
|
||||||
|
// Check the values of the duplicated task
|
||||||
|
$task = $tf->getById(3);
|
||||||
|
$this->assertNotEmpty($task);
|
||||||
|
$this->assertEquals(2, $task['position']);
|
||||||
|
$this->assertEquals(2, $task['owner_id']);
|
||||||
|
$this->assertEquals(2, $task['project_id']);
|
||||||
|
|
||||||
|
// We duplicate a task with a not allowed user
|
||||||
|
$this->assertEquals(4, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 3)));
|
||||||
|
$this->assertEquals(5, $td->duplicateToProject(4, 2));
|
||||||
|
|
||||||
|
$task = $tf->getById(5);
|
||||||
|
$this->assertNotEmpty($task);
|
||||||
|
$this->assertEquals(3, $task['position']);
|
||||||
|
$this->assertEquals(0, $task['owner_id']);
|
||||||
|
$this->assertEquals(2, $task['project_id']);
|
||||||
|
$this->assertEquals(5, $task['column_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testMoveAnotherProject()
|
||||||
|
{
|
||||||
|
$td = new TaskDuplication($this->container);
|
||||||
|
$tc = new TaskCreation($this->container);
|
||||||
|
$tf = new TaskFinder($this->container);
|
||||||
|
$p = new Project($this->container);
|
||||||
|
$pp = new ProjectPermission($this->container);
|
||||||
|
$user = new User($this->container);
|
||||||
|
|
||||||
|
// We create 2 projects
|
||||||
|
$this->assertEquals(1, $p->create(array('name' => 'test1')));
|
||||||
|
$this->assertEquals(2, $p->create(array('name' => 'test2')));
|
||||||
|
|
||||||
|
// We create a task
|
||||||
|
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'owner_id' => 1, 'category_id' => 10, 'position' => 333)));
|
||||||
|
|
||||||
|
// We duplicate our task to the 2nd project
|
||||||
|
$this->assertTrue($td->moveToProject(1, 2));
|
||||||
|
|
||||||
|
// Check the values of the moved task
|
||||||
|
$task = $tf->getById(1);
|
||||||
|
$this->assertNotEmpty($task);
|
||||||
|
$this->assertEquals(1, $task['owner_id']);
|
||||||
|
$this->assertEquals(0, $task['category_id']);
|
||||||
|
$this->assertEquals(2, $task['project_id']);
|
||||||
|
$this->assertEquals(5, $task['column_id']);
|
||||||
|
$this->assertEquals(1, $task['position']);
|
||||||
|
$this->assertEquals('test', $task['title']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testMoveAnotherProjectWithCategory()
|
||||||
|
{
|
||||||
|
$td = new TaskDuplication($this->container);
|
||||||
|
$tc = new TaskCreation($this->container);
|
||||||
|
$tf = new TaskFinder($this->container);
|
||||||
|
$p = new Project($this->container);
|
||||||
|
$c = new Category($this->container);
|
||||||
|
|
||||||
|
// We create 2 projects
|
||||||
|
$this->assertEquals(1, $p->create(array('name' => 'test1')));
|
||||||
|
$this->assertEquals(2, $p->create(array('name' => 'test2')));
|
||||||
|
|
||||||
|
$this->assertNotFalse($c->create(array('name' => 'Category #1', 'project_id' => 1)));
|
||||||
|
$this->assertNotFalse($c->create(array('name' => 'Category #1', 'project_id' => 2)));
|
||||||
|
$this->assertTrue($c->exists(1, 1));
|
||||||
|
$this->assertTrue($c->exists(2, 2));
|
||||||
|
|
||||||
|
// We create a task
|
||||||
|
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'category_id' => 1)));
|
||||||
|
|
||||||
|
// We move our task to the 2nd project
|
||||||
|
$this->assertTrue($td->moveToProject(1, 2));
|
||||||
|
|
||||||
|
// Check the values of the duplicated task
|
||||||
|
$task = $tf->getById(1);
|
||||||
|
$this->assertNotEmpty($task);
|
||||||
|
$this->assertEquals(0, $task['owner_id']);
|
||||||
|
$this->assertEquals(2, $task['category_id']);
|
||||||
|
$this->assertEquals(5, $task['column_id']);
|
||||||
|
$this->assertEquals(1, $task['position']);
|
||||||
|
$this->assertEquals(2, $task['project_id']);
|
||||||
|
$this->assertEquals('test', $task['title']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testMoveAnotherProjectWithUser()
|
||||||
|
{
|
||||||
|
$td = new TaskDuplication($this->container);
|
||||||
|
$tc = new TaskCreation($this->container);
|
||||||
|
$tf = new TaskFinder($this->container);
|
||||||
|
$p = new Project($this->container);
|
||||||
|
$pp = new ProjectPermission($this->container);
|
||||||
|
$user = new User($this->container);
|
||||||
|
|
||||||
|
// We create 2 projects
|
||||||
|
$this->assertEquals(1, $p->create(array('name' => 'test1')));
|
||||||
|
$this->assertEquals(2, $p->create(array('name' => 'test2')));
|
||||||
|
|
||||||
|
// We create a new user for our project
|
||||||
|
$this->assertNotFalse($user->create(array('username' => 'unittest#1', 'password' => 'unittest')));
|
||||||
|
$this->assertTrue($pp->allowUser(1, 2));
|
||||||
|
$this->assertTrue($pp->allowUser(2, 2));
|
||||||
|
$this->assertTrue($pp->isUserAllowed(1, 2));
|
||||||
|
$this->assertTrue($pp->isUserAllowed(2, 2));
|
||||||
|
|
||||||
|
// We create a task
|
||||||
|
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 2)));
|
||||||
|
|
||||||
|
// We move our task to the 2nd project
|
||||||
|
$this->assertTrue($td->moveToProject(1, 2));
|
||||||
|
|
||||||
|
// Check the values of the moved task
|
||||||
|
$task = $tf->getById(1);
|
||||||
|
$this->assertNotEmpty($task);
|
||||||
|
$this->assertEquals(1, $task['position']);
|
||||||
|
$this->assertEquals(2, $task['owner_id']);
|
||||||
|
$this->assertEquals(2, $task['project_id']);
|
||||||
|
$this->assertEquals(5, $task['column_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testMoveAnotherProjectWithForbiddenUser()
|
||||||
|
{
|
||||||
|
$td = new TaskDuplication($this->container);
|
||||||
|
$tc = new TaskCreation($this->container);
|
||||||
|
$tf = new TaskFinder($this->container);
|
||||||
|
$p = new Project($this->container);
|
||||||
|
$pp = new ProjectPermission($this->container);
|
||||||
|
$user = new User($this->container);
|
||||||
|
|
||||||
|
// We create 2 projects
|
||||||
|
$this->assertEquals(1, $p->create(array('name' => 'test1')));
|
||||||
|
$this->assertEquals(2, $p->create(array('name' => 'test2')));
|
||||||
|
|
||||||
|
// We create a new user for our project
|
||||||
|
$this->assertNotFalse($user->create(array('username' => 'unittest#1', 'password' => 'unittest')));
|
||||||
|
$this->assertTrue($pp->allowUser(1, 2));
|
||||||
|
$this->assertTrue($pp->allowUser(2, 2));
|
||||||
|
$this->assertTrue($pp->isUserAllowed(1, 2));
|
||||||
|
$this->assertTrue($pp->isUserAllowed(2, 2));
|
||||||
|
|
||||||
|
// We create a task
|
||||||
|
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 3)));
|
||||||
|
|
||||||
|
// We move our task to the 2nd project
|
||||||
|
$this->assertTrue($td->moveToProject(1, 2));
|
||||||
|
|
||||||
|
// Check the values of the moved task
|
||||||
|
$task = $tf->getById(1);
|
||||||
|
$this->assertNotEmpty($task);
|
||||||
|
$this->assertEquals(1, $task['position']);
|
||||||
|
$this->assertEquals(0, $task['owner_id']);
|
||||||
|
$this->assertEquals(2, $task['project_id']);
|
||||||
|
$this->assertEquals(5, $task['column_id']);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,124 +26,4 @@ class TaskTest extends Base
|
|||||||
$this->assertTrue($t->remove(1));
|
$this->assertTrue($t->remove(1));
|
||||||
$this->assertFalse($t->remove(1234));
|
$this->assertFalse($t->remove(1234));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDuplicateToTheSameProject()
|
|
||||||
{
|
|
||||||
$t = new Task($this->container);
|
|
||||||
$tc = new TaskCreation($this->container);
|
|
||||||
$tf = new TaskFinder($this->container);
|
|
||||||
$p = new Project($this->container);
|
|
||||||
$c = new Category($this->container);
|
|
||||||
|
|
||||||
// We create a task and a project
|
|
||||||
$this->assertEquals(1, $p->create(array('name' => 'test1')));
|
|
||||||
|
|
||||||
// Some categories
|
|
||||||
$this->assertNotFalse($c->create(array('name' => 'Category #1', 'project_id' => 1)));
|
|
||||||
$this->assertNotFalse($c->create(array('name' => 'Category #2', 'project_id' => 1)));
|
|
||||||
$this->assertTrue($c->exists(1, 1));
|
|
||||||
$this->assertTrue($c->exists(2, 1));
|
|
||||||
|
|
||||||
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1, 'category_id' => 2)));
|
|
||||||
|
|
||||||
$task = $tf->getById(1);
|
|
||||||
$this->assertNotEmpty($task);
|
|
||||||
$this->assertEquals(1, $task['position']);
|
|
||||||
|
|
||||||
// We duplicate our task
|
|
||||||
$this->assertEquals(2, $t->duplicateToSameProject($task));
|
|
||||||
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_CREATE));
|
|
||||||
|
|
||||||
// Check the values of the duplicated task
|
|
||||||
$task = $tf->getById(2);
|
|
||||||
$this->assertNotEmpty($task);
|
|
||||||
$this->assertEquals(Task::STATUS_OPEN, $task['is_active']);
|
|
||||||
$this->assertEquals(1, $task['project_id']);
|
|
||||||
$this->assertEquals(1, $task['owner_id']);
|
|
||||||
$this->assertEquals(2, $task['category_id']);
|
|
||||||
$this->assertEquals(3, $task['column_id']);
|
|
||||||
$this->assertEquals(2, $task['position']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testDuplicateToAnotherProject()
|
|
||||||
{
|
|
||||||
$t = new Task($this->container);
|
|
||||||
$tc = new TaskCreation($this->container);
|
|
||||||
$tf = new TaskFinder($this->container);
|
|
||||||
$p = new Project($this->container);
|
|
||||||
$c = new Category($this->container);
|
|
||||||
|
|
||||||
// We create 2 projects
|
|
||||||
$this->assertEquals(1, $p->create(array('name' => 'test1')));
|
|
||||||
$this->assertEquals(2, $p->create(array('name' => 'test2')));
|
|
||||||
|
|
||||||
$this->assertNotFalse($c->create(array('name' => 'Category #1', 'project_id' => 1)));
|
|
||||||
$this->assertTrue($c->exists(1, 1));
|
|
||||||
|
|
||||||
// We create a task
|
|
||||||
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 1, 'category_id' => 1)));
|
|
||||||
$task = $tf->getById(1);
|
|
||||||
|
|
||||||
// We duplicate our task to the 2nd project
|
|
||||||
$this->assertEquals(2, $t->duplicateToAnotherProject(2, $task));
|
|
||||||
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_CREATE));
|
|
||||||
|
|
||||||
// Check the values of the duplicated task
|
|
||||||
$task = $tf->getById(2);
|
|
||||||
$this->assertNotEmpty($task);
|
|
||||||
$this->assertEquals(1, $task['owner_id']);
|
|
||||||
$this->assertEquals(0, $task['category_id']);
|
|
||||||
$this->assertEquals(5, $task['column_id']);
|
|
||||||
$this->assertEquals(1, $task['position']);
|
|
||||||
$this->assertEquals(2, $task['project_id']);
|
|
||||||
$this->assertEquals('test', $task['title']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testMoveToAnotherProject()
|
|
||||||
{
|
|
||||||
$t = new Task($this->container);
|
|
||||||
$tc = new TaskCreation($this->container);
|
|
||||||
$tf = new TaskFinder($this->container);
|
|
||||||
$p = new Project($this->container);
|
|
||||||
$pp = new ProjectPermission($this->container);
|
|
||||||
$user = new User($this->container);
|
|
||||||
|
|
||||||
// We create a regular user
|
|
||||||
$user->create(array('username' => 'unittest1', 'password' => 'unittest'));
|
|
||||||
$user->create(array('username' => 'unittest2', 'password' => 'unittest'));
|
|
||||||
|
|
||||||
// We create 2 projects
|
|
||||||
$this->assertEquals(1, $p->create(array('name' => 'test1')));
|
|
||||||
$this->assertEquals(2, $p->create(array('name' => 'test2')));
|
|
||||||
|
|
||||||
// We create a task
|
|
||||||
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 1, 'category_id' => 10, 'position' => 333)));
|
|
||||||
$this->assertEquals(2, $tc->create(array('title' => 'test2', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 3, 'category_id' => 10, 'position' => 333)));
|
|
||||||
|
|
||||||
// We duplicate our task to the 2nd project
|
|
||||||
$task = $tf->getById(1);
|
|
||||||
$this->assertEquals(1, $t->moveToAnotherProject(2, $task));
|
|
||||||
//$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_CREATE));
|
|
||||||
|
|
||||||
// Check the values of the duplicated task
|
|
||||||
$task = $tf->getById(1);
|
|
||||||
$this->assertNotEmpty($task);
|
|
||||||
$this->assertEquals(1, $task['owner_id']);
|
|
||||||
$this->assertEquals(0, $task['category_id']);
|
|
||||||
$this->assertEquals(2, $task['project_id']);
|
|
||||||
$this->assertEquals(5, $task['column_id']);
|
|
||||||
$this->assertEquals(1, $task['position']);
|
|
||||||
$this->assertEquals('test', $task['title']);
|
|
||||||
|
|
||||||
// We allow only one user on the second project
|
|
||||||
$this->assertTrue($pp->allowUser(2, 2));
|
|
||||||
|
|
||||||
// The owner should be reseted
|
|
||||||
$task = $tf->getById(2);
|
|
||||||
$this->assertEquals(2, $t->moveToAnotherProject(2, $task));
|
|
||||||
|
|
||||||
$task = $tf->getById(2);
|
|
||||||
$this->assertNotEmpty($task);
|
|
||||||
$this->assertEquals(0, $task['owner_id']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user