Move some Task model methods to the TaskFinder class
This commit is contained in:
@@ -64,7 +64,7 @@ class TaskDuplicateAnotherProject extends Base
|
|||||||
*/
|
*/
|
||||||
public function doAction(array $data)
|
public function doAction(array $data)
|
||||||
{
|
{
|
||||||
$task = $this->task->getById($data['task_id']);
|
$task = $this->taskFinder->getById($data['task_id']);
|
||||||
$this->task->duplicateToAnotherProject($this->getParam('project_id'), $task);
|
$this->task->duplicateToAnotherProject($this->getParam('project_id'), $task);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class TaskMoveAnotherProject extends Base
|
|||||||
*/
|
*/
|
||||||
public function doAction(array $data)
|
public function doAction(array $data)
|
||||||
{
|
{
|
||||||
$task = $this->task->getById($data['task_id']);
|
$task = $this->taskFinder->getById($data['task_id']);
|
||||||
$this->task->moveToAnotherProject($this->getParam('project_id'), $task);
|
$this->task->moveToAnotherProject($this->getParam('project_id'), $task);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -276,7 +276,7 @@ abstract class Base
|
|||||||
*/
|
*/
|
||||||
protected function getTask()
|
protected function getTask()
|
||||||
{
|
{
|
||||||
$task = $this->task->getDetails($this->request->getIntegerParam('task_id'));
|
$task = $this->taskFinder->getDetails($this->request->getIntegerParam('task_id'));
|
||||||
|
|
||||||
if (! $task) {
|
if (! $task) {
|
||||||
$this->notfound();
|
$this->notfound();
|
||||||
|
|||||||
@@ -447,7 +447,7 @@ class Project extends Base
|
|||||||
$limit = 25;
|
$limit = 25;
|
||||||
|
|
||||||
$tasks = $this->taskFinder->getClosedTasks($project['id'], $offset, $limit, $order, $direction);
|
$tasks = $this->taskFinder->getClosedTasks($project['id'], $offset, $limit, $order, $direction);
|
||||||
$nb_tasks = $this->task->countByProjectId($project['id'], array(TaskModel::STATUS_CLOSED));
|
$nb_tasks = $this->taskFinder->countByProjectId($project['id'], array(TaskModel::STATUS_CLOSED));
|
||||||
|
|
||||||
$this->response->html($this->template->layout('project_tasks', array(
|
$this->response->html($this->template->layout('project_tasks', array(
|
||||||
'pagination' => array(
|
'pagination' => array(
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class Task extends Base
|
|||||||
$this->forbidden(true);
|
$this->forbidden(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$task = $this->task->getDetails($this->request->getIntegerParam('task_id'));
|
$task = $this->taskFinder->getDetails($this->request->getIntegerParam('task_id'));
|
||||||
|
|
||||||
if (! $task) {
|
if (! $task) {
|
||||||
$this->notfound(true);
|
$this->notfound(true);
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class CommentHistoryListener implements Listener
|
|||||||
|
|
||||||
if ($creator_id && isset($data['task_id']) && isset($data['id'])) {
|
if ($creator_id && isset($data['task_id']) && isset($data['id'])) {
|
||||||
|
|
||||||
$task = $this->model->task->getById($data['task_id']);
|
$task = $this->model->taskFinder->getById($data['task_id']);
|
||||||
|
|
||||||
$this->model->create(
|
$this->model->create(
|
||||||
$task['project_id'],
|
$task['project_id'],
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class CommentNotificationListener extends BaseNotificationListener
|
|||||||
{
|
{
|
||||||
$values = array();
|
$values = array();
|
||||||
$values['comment'] = $this->notification->comment->getById($data['id']);
|
$values['comment'] = $this->notification->comment->getById($data['id']);
|
||||||
$values['task'] = $this->notification->task->getDetails($values['comment']['task_id']);
|
$values['task'] = $this->notification->taskFinder->getDetails($values['comment']['task_id']);
|
||||||
|
|
||||||
return $values;
|
return $values;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class FileNotificationListener extends BaseNotificationListener
|
|||||||
{
|
{
|
||||||
$values = array();
|
$values = array();
|
||||||
$values['file'] = $data;
|
$values['file'] = $data;
|
||||||
$values['task'] = $this->notification->task->getDetails($data['task_id']);
|
$values['task'] = $this->notification->taskFinder->getDetails($data['task_id']);
|
||||||
|
|
||||||
return $values;
|
return $values;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class SubTaskNotificationListener extends BaseNotificationListener
|
|||||||
{
|
{
|
||||||
$values = array();
|
$values = array();
|
||||||
$values['subtask'] = $this->notification->subtask->getById($data['id'], true);
|
$values['subtask'] = $this->notification->subtask->getById($data['id'], true);
|
||||||
$values['task'] = $this->notification->task->getDetails($data['task_id']);
|
$values['task'] = $this->notification->taskFinder->getDetails($data['task_id']);
|
||||||
|
|
||||||
return $values;
|
return $values;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class SubtaskHistoryListener implements Listener
|
|||||||
|
|
||||||
if ($creator_id && isset($data['task_id']) && isset($data['id'])) {
|
if ($creator_id && isset($data['task_id']) && isset($data['id'])) {
|
||||||
|
|
||||||
$task = $this->model->task->getById($data['task_id']);
|
$task = $this->model->taskFinder->getById($data['task_id']);
|
||||||
|
|
||||||
$this->model->create(
|
$this->model->create(
|
||||||
$task['project_id'],
|
$task['project_id'],
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class TaskNotificationListener extends BaseNotificationListener
|
|||||||
public function getTemplateData(array $data)
|
public function getTemplateData(array $data)
|
||||||
{
|
{
|
||||||
$values = array();
|
$values = array();
|
||||||
$values['task'] = $this->notification->task->getDetails($data['task_id']);
|
$values['task'] = $this->notification->taskFinder->getDetails($data['task_id']);
|
||||||
|
|
||||||
return $values;
|
return $values;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ class Board extends Base
|
|||||||
public function get($project_id, array $filters = array())
|
public function get($project_id, array $filters = array())
|
||||||
{
|
{
|
||||||
$columns = $this->getColumns($project_id);
|
$columns = $this->getColumns($project_id);
|
||||||
$tasks = $this->taskFinder->getOpenTasks($project_id);
|
$tasks = $this->taskFinder->getTasksOnBoard($project_id);
|
||||||
|
|
||||||
foreach ($columns as &$column) {
|
foreach ($columns as &$column) {
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ class GithubWebhook extends Base
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$task = $this->task->getById($task_id);
|
$task = $this->taskFinder->getById($task_id);
|
||||||
|
|
||||||
if (! $task) {
|
if (! $task) {
|
||||||
continue;
|
continue;
|
||||||
@@ -148,7 +148,7 @@ class GithubWebhook extends Base
|
|||||||
*/
|
*/
|
||||||
public function handleIssueClosed(array $issue)
|
public function handleIssueClosed(array $issue)
|
||||||
{
|
{
|
||||||
$task = $this->task->getByReference($issue['number']);
|
$task = $this->taskFinder->getByReference($issue['number']);
|
||||||
|
|
||||||
if ($task) {
|
if ($task) {
|
||||||
$event = array(
|
$event = array(
|
||||||
@@ -169,7 +169,7 @@ class GithubWebhook extends Base
|
|||||||
*/
|
*/
|
||||||
public function handleIssueReopened(array $issue)
|
public function handleIssueReopened(array $issue)
|
||||||
{
|
{
|
||||||
$task = $this->task->getByReference($issue['number']);
|
$task = $this->taskFinder->getByReference($issue['number']);
|
||||||
|
|
||||||
if ($task) {
|
if ($task) {
|
||||||
$event = array(
|
$event = array(
|
||||||
@@ -191,7 +191,7 @@ class GithubWebhook extends Base
|
|||||||
public function handleIssueAssigned(array $issue)
|
public function handleIssueAssigned(array $issue)
|
||||||
{
|
{
|
||||||
$user = $this->user->getByUsername($issue['assignee']['login']);
|
$user = $this->user->getByUsername($issue['assignee']['login']);
|
||||||
$task = $this->task->getByReference($issue['number']);
|
$task = $this->taskFinder->getByReference($issue['number']);
|
||||||
|
|
||||||
if ($user && $task) {
|
if ($user && $task) {
|
||||||
|
|
||||||
@@ -214,7 +214,7 @@ class GithubWebhook extends Base
|
|||||||
*/
|
*/
|
||||||
public function handleIssueUnassigned(array $issue)
|
public function handleIssueUnassigned(array $issue)
|
||||||
{
|
{
|
||||||
$task = $this->task->getByReference($issue['number']);
|
$task = $this->taskFinder->getByReference($issue['number']);
|
||||||
|
|
||||||
if ($task) {
|
if ($task) {
|
||||||
|
|
||||||
@@ -238,7 +238,7 @@ class GithubWebhook extends Base
|
|||||||
*/
|
*/
|
||||||
public function handleIssueLabeled(array $issue, array $label)
|
public function handleIssueLabeled(array $issue, array $label)
|
||||||
{
|
{
|
||||||
$task = $this->task->getByReference($issue['number']);
|
$task = $this->taskFinder->getByReference($issue['number']);
|
||||||
|
|
||||||
if ($task) {
|
if ($task) {
|
||||||
|
|
||||||
@@ -262,7 +262,7 @@ class GithubWebhook extends Base
|
|||||||
*/
|
*/
|
||||||
public function handleIssueUnlabeled(array $issue, array $label)
|
public function handleIssueUnlabeled(array $issue, array $label)
|
||||||
{
|
{
|
||||||
$task = $this->task->getByReference($issue['number']);
|
$task = $this->taskFinder->getByReference($issue['number']);
|
||||||
|
|
||||||
if ($task) {
|
if ($task) {
|
||||||
|
|
||||||
|
|||||||
@@ -196,12 +196,12 @@ class Project extends Base
|
|||||||
$stats['nb_active_tasks'] = 0;
|
$stats['nb_active_tasks'] = 0;
|
||||||
|
|
||||||
foreach ($columns as &$column) {
|
foreach ($columns as &$column) {
|
||||||
$column['nb_active_tasks'] = $this->task->countByColumnId($project_id, $column['id']);
|
$column['nb_active_tasks'] = $this->taskFinder->countByColumnId($project_id, $column['id']);
|
||||||
$stats['nb_active_tasks'] += $column['nb_active_tasks'];
|
$stats['nb_active_tasks'] += $column['nb_active_tasks'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$stats['columns'] = $columns;
|
$stats['columns'] = $columns;
|
||||||
$stats['nb_tasks'] = $this->task->countByProjectId($project_id);
|
$stats['nb_tasks'] = $this->taskFinder->countByProjectId($project_id);
|
||||||
$stats['nb_inactive_tasks'] = $stats['nb_tasks'] - $stats['nb_active_tasks'];
|
$stats['nb_inactive_tasks'] = $stats['nb_tasks'] - $stats['nb_active_tasks'];
|
||||||
|
|
||||||
return $stats;
|
return $stats;
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
namespace Model;
|
namespace Model;
|
||||||
|
|
||||||
use PDO;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Task model
|
* Task model
|
||||||
*
|
*
|
||||||
@@ -41,163 +39,6 @@ class Task extends Base
|
|||||||
const EVENT_CREATE_UPDATE = 'task.create_update';
|
const EVENT_CREATE_UPDATE = 'task.create_update';
|
||||||
const EVENT_ASSIGNEE_CHANGE = 'task.assignee_change';
|
const EVENT_ASSIGNEE_CHANGE = 'task.assignee_change';
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a list of due tasks for all projects
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getOverdueTasks()
|
|
||||||
{
|
|
||||||
$tasks = $this->db->table(self::TABLE)
|
|
||||||
->columns(
|
|
||||||
self::TABLE.'.id',
|
|
||||||
self::TABLE.'.title',
|
|
||||||
self::TABLE.'.date_due',
|
|
||||||
self::TABLE.'.project_id',
|
|
||||||
Project::TABLE.'.name AS project_name',
|
|
||||||
User::TABLE.'.username AS assignee_username',
|
|
||||||
User::TABLE.'.name AS assignee_name'
|
|
||||||
)
|
|
||||||
->join(Project::TABLE, 'id', 'project_id')
|
|
||||||
->join(User::TABLE, 'id', 'owner_id')
|
|
||||||
->eq(Project::TABLE.'.is_active', 1)
|
|
||||||
->eq(self::TABLE.'.is_active', 1)
|
|
||||||
->neq(self::TABLE.'.date_due', 0)
|
|
||||||
->lte(self::TABLE.'.date_due', mktime(23, 59, 59))
|
|
||||||
->findAll();
|
|
||||||
|
|
||||||
return $tasks;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get task details (fetch more information from other tables)
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @param integer $task_id Task id
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getDetails($task_id)
|
|
||||||
{
|
|
||||||
$sql = '
|
|
||||||
SELECT
|
|
||||||
tasks.id,
|
|
||||||
tasks.reference,
|
|
||||||
tasks.title,
|
|
||||||
tasks.description,
|
|
||||||
tasks.date_creation,
|
|
||||||
tasks.date_completed,
|
|
||||||
tasks.date_modification,
|
|
||||||
tasks.date_due,
|
|
||||||
tasks.date_started,
|
|
||||||
tasks.time_estimated,
|
|
||||||
tasks.time_spent,
|
|
||||||
tasks.color_id,
|
|
||||||
tasks.project_id,
|
|
||||||
tasks.column_id,
|
|
||||||
tasks.owner_id,
|
|
||||||
tasks.creator_id,
|
|
||||||
tasks.position,
|
|
||||||
tasks.is_active,
|
|
||||||
tasks.score,
|
|
||||||
tasks.category_id,
|
|
||||||
project_has_categories.name AS category_name,
|
|
||||||
projects.name AS project_name,
|
|
||||||
columns.title AS column_title,
|
|
||||||
users.username AS assignee_username,
|
|
||||||
users.name AS assignee_name,
|
|
||||||
creators.username AS creator_username,
|
|
||||||
creators.name AS creator_name
|
|
||||||
FROM tasks
|
|
||||||
LEFT JOIN users ON users.id = tasks.owner_id
|
|
||||||
LEFT JOIN users AS creators ON creators.id = tasks.creator_id
|
|
||||||
LEFT JOIN project_has_categories ON project_has_categories.id = tasks.category_id
|
|
||||||
LEFT JOIN projects ON projects.id = tasks.project_id
|
|
||||||
LEFT JOIN columns ON columns.id = tasks.column_id
|
|
||||||
WHERE tasks.id = ?
|
|
||||||
';
|
|
||||||
|
|
||||||
$rq = $this->db->execute($sql, array($task_id));
|
|
||||||
return $rq->fetch(PDO::FETCH_ASSOC);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetch a task by the id
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @param integer $task_id Task id
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getById($task_id)
|
|
||||||
{
|
|
||||||
return $this->db->table(self::TABLE)->eq('id', $task_id)->findOne();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetch a task by the reference (external id)
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @param string $reference Task reference
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getByReference($reference)
|
|
||||||
{
|
|
||||||
return $this->db->table(self::TABLE)->eq('reference', $reference)->findOne();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all tasks for a given project and status
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @param integer $project_id Project id
|
|
||||||
* @param integer $status_id Status id
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getAll($project_id, $status_id = self::STATUS_OPEN)
|
|
||||||
{
|
|
||||||
return $this->db
|
|
||||||
->table(self::TABLE)
|
|
||||||
->eq('project_id', $project_id)
|
|
||||||
->eq('is_active', $status_id)
|
|
||||||
->findAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Count all tasks for a given project and status
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @param integer $project_id Project id
|
|
||||||
* @param array $status List of status id
|
|
||||||
* @return integer
|
|
||||||
*/
|
|
||||||
public function countByProjectId($project_id, array $status = array(self::STATUS_OPEN, self::STATUS_CLOSED))
|
|
||||||
{
|
|
||||||
return $this->db
|
|
||||||
->table(self::TABLE)
|
|
||||||
->eq('project_id', $project_id)
|
|
||||||
->in('is_active', $status)
|
|
||||||
->count();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Count the number of tasks for a given column and status
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @param integer $project_id Project id
|
|
||||||
* @param integer $column_id Column id
|
|
||||||
* @param array $status List of status id
|
|
||||||
* @return integer
|
|
||||||
*/
|
|
||||||
public function countByColumnId($project_id, $column_id, array $status = array(self::STATUS_OPEN))
|
|
||||||
{
|
|
||||||
return $this->db
|
|
||||||
->table(self::TABLE)
|
|
||||||
->eq('project_id', $project_id)
|
|
||||||
->eq('column_id', $column_id)
|
|
||||||
->in('is_active', $status)
|
|
||||||
->count();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare data before task creation or modification
|
* Prepare data before task creation or modification
|
||||||
*
|
*
|
||||||
@@ -233,7 +74,7 @@ class Task extends Base
|
|||||||
|
|
||||||
$values['date_creation'] = time();
|
$values['date_creation'] = time();
|
||||||
$values['date_modification'] = $values['date_creation'];
|
$values['date_modification'] = $values['date_creation'];
|
||||||
$values['position'] = $this->countByColumnId($values['project_id'], $values['column_id']) + 1;
|
$values['position'] = $this->taskFinder->countByColumnId($values['project_id'], $values['column_id']) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -288,7 +129,7 @@ class Task extends Base
|
|||||||
public function update(array $values, $trigger_events = true)
|
public function update(array $values, $trigger_events = true)
|
||||||
{
|
{
|
||||||
// Fetch original task
|
// Fetch original task
|
||||||
$original_task = $this->getById($values['id']);
|
$original_task = $this->taskFinder->getById($values['id']);
|
||||||
|
|
||||||
if (! $original_task) {
|
if (! $original_task) {
|
||||||
return false;
|
return false;
|
||||||
@@ -340,18 +181,6 @@ class Task extends Base
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return true if the project exists
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @param integer $task_id Task id
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public function exists($task_id)
|
|
||||||
{
|
|
||||||
return $this->db->table(self::TABLE)->eq('id', $task_id)->count() === 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mark a task closed
|
* Mark a task closed
|
||||||
*
|
*
|
||||||
@@ -361,7 +190,7 @@ class Task extends Base
|
|||||||
*/
|
*/
|
||||||
public function close($task_id)
|
public function close($task_id)
|
||||||
{
|
{
|
||||||
if (! $this->exists($task_id)) {
|
if (! $this->taskFinder->exists($task_id)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -374,7 +203,7 @@ class Task extends Base
|
|||||||
));
|
));
|
||||||
|
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$this->event->trigger(self::EVENT_CLOSE, array('task_id' => $task_id) + $this->getById($task_id));
|
$this->event->trigger(self::EVENT_CLOSE, array('task_id' => $task_id) + $this->taskFinder->getById($task_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
@@ -389,7 +218,7 @@ class Task extends Base
|
|||||||
*/
|
*/
|
||||||
public function open($task_id)
|
public function open($task_id)
|
||||||
{
|
{
|
||||||
if (! $this->exists($task_id)) {
|
if (! $this->taskFinder->exists($task_id)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,7 +231,7 @@ class Task extends Base
|
|||||||
));
|
));
|
||||||
|
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$this->event->trigger(self::EVENT_OPEN, array('task_id' => $task_id) + $this->getById($task_id));
|
$this->event->trigger(self::EVENT_OPEN, array('task_id' => $task_id) + $this->taskFinder->getById($task_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
@@ -417,7 +246,7 @@ class Task extends Base
|
|||||||
*/
|
*/
|
||||||
public function remove($task_id)
|
public function remove($task_id)
|
||||||
{
|
{
|
||||||
if (! $this->exists($task_id)) {
|
if (! $this->taskFinder->exists($task_id)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -541,7 +370,7 @@ class Task extends Base
|
|||||||
|
|
||||||
// We use the first column of the new project
|
// We use the first column of the new project
|
||||||
$values['column_id'] = $this->board->getFirstColumn($project_id);
|
$values['column_id'] = $this->board->getFirstColumn($project_id);
|
||||||
$values['position'] = $this->countByColumnId($project_id, $values['column_id']) + 1;
|
$values['position'] = $this->taskFinder->countByColumnId($project_id, $values['column_id']) + 1;
|
||||||
$values['project_id'] = $project_id;
|
$values['project_id'] = $project_id;
|
||||||
|
|
||||||
// The task will be open (close event binding)
|
// The task will be open (close event binding)
|
||||||
@@ -583,7 +412,7 @@ class Task extends Base
|
|||||||
$values['column_id'] = $task['column_id'];
|
$values['column_id'] = $task['column_id'];
|
||||||
$values['owner_id'] = 0;
|
$values['owner_id'] = 0;
|
||||||
$values['creator_id'] = $task['creator_id'];
|
$values['creator_id'] = $task['creator_id'];
|
||||||
$values['position'] = $this->countByColumnId($values['project_id'], $values['column_id']) + 1;
|
$values['position'] = $this->taskFinder->countByColumnId($values['project_id'], $values['column_id']) + 1;
|
||||||
$values['score'] = $task['score'];
|
$values['score'] = $task['score'];
|
||||||
$values['category_id'] = 0;
|
$values['category_id'] = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace Model;
|
namespace Model;
|
||||||
|
|
||||||
|
use PDO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Task Finder model
|
* Task Finder model
|
||||||
*
|
*
|
||||||
@@ -10,7 +12,13 @@ namespace Model;
|
|||||||
*/
|
*/
|
||||||
class TaskFinder extends Base
|
class TaskFinder extends Base
|
||||||
{
|
{
|
||||||
private function prepareRequest()
|
/**
|
||||||
|
* Common request to fetch a list of tasks
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @return \PicoDb\Table
|
||||||
|
*/
|
||||||
|
private function prepareRequestList()
|
||||||
{
|
{
|
||||||
return $this->db
|
return $this->db
|
||||||
->table(Task::TABLE)
|
->table(Task::TABLE)
|
||||||
@@ -42,9 +50,21 @@ class TaskFinder extends Base
|
|||||||
->join(User::TABLE, 'id', 'owner_id');
|
->join(User::TABLE, 'id', 'owner_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Task search with pagination
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param integer $project_id Project id
|
||||||
|
* @param string $search Search terms
|
||||||
|
* @param integer $offset Offset
|
||||||
|
* @param integer $limit Limit
|
||||||
|
* @param string $column Sorting column
|
||||||
|
* @param string $direction Sorting direction
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function search($project_id, $search, $offset = 0, $limit = 25, $column = 'tasks.id', $direction = 'DESC')
|
public function search($project_id, $search, $offset = 0, $limit = 25, $column = 'tasks.id', $direction = 'DESC')
|
||||||
{
|
{
|
||||||
return $this->prepareRequest()
|
return $this->prepareRequestList()
|
||||||
->eq('project_id', $project_id)
|
->eq('project_id', $project_id)
|
||||||
->like('title', '%'.$search.'%')
|
->like('title', '%'.$search.'%')
|
||||||
->offset($offset)
|
->offset($offset)
|
||||||
@@ -53,17 +73,20 @@ class TaskFinder extends Base
|
|||||||
->findAll();
|
->findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function countSearch($project_id, $search)
|
/**
|
||||||
{
|
* Get all completed tasks with pagination
|
||||||
return $this->db->table(Task::TABLE)
|
*
|
||||||
->eq('project_id', $project_id)
|
* @access public
|
||||||
->like('title', '%'.$search.'%')
|
* @param integer $project_id Project id
|
||||||
->count();
|
* @param integer $offset Offset
|
||||||
}
|
* @param integer $limit Limit
|
||||||
|
* @param string $column Sorting column
|
||||||
|
* @param string $direction Sorting direction
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function getClosedTasks($project_id, $offset = 0, $limit = 25, $column = 'tasks.date_completed', $direction = 'DESC')
|
public function getClosedTasks($project_id, $offset = 0, $limit = 25, $column = 'tasks.date_completed', $direction = 'DESC')
|
||||||
{
|
{
|
||||||
return $this->prepareRequest()
|
return $this->prepareRequestList()
|
||||||
->eq('project_id', $project_id)
|
->eq('project_id', $project_id)
|
||||||
->eq('is_active', Task::STATUS_CLOSED)
|
->eq('is_active', Task::STATUS_CLOSED)
|
||||||
->offset($offset)
|
->offset($offset)
|
||||||
@@ -72,12 +95,204 @@ class TaskFinder extends Base
|
|||||||
->findAll();
|
->findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getOpenTasks($project_id, $column = 'tasks.position', $direction = 'ASC')
|
/**
|
||||||
|
* Get all tasks shown on the board (sorted by position)
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param integer $project_id Project id
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getTasksOnBoard($project_id)
|
||||||
{
|
{
|
||||||
return $this->prepareRequest()
|
return $this->prepareRequestList()
|
||||||
->eq('project_id', $project_id)
|
->eq('project_id', $project_id)
|
||||||
->eq('is_active', Task::STATUS_OPEN)
|
->eq('is_active', Task::STATUS_OPEN)
|
||||||
->orderBy($column, $direction)
|
->asc('tasks.position')
|
||||||
->findAll();
|
->findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all tasks for a given project and status
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param integer $project_id Project id
|
||||||
|
* @param integer $status_id Status id
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getAll($project_id, $status_id = Task::STATUS_OPEN)
|
||||||
|
{
|
||||||
|
return $this->db
|
||||||
|
->table(Task::TABLE)
|
||||||
|
->eq('project_id', $project_id)
|
||||||
|
->eq('is_active', $status_id)
|
||||||
|
->findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of overdue tasks for all projects
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getOverdueTasks()
|
||||||
|
{
|
||||||
|
$tasks = $this->db->table(Task::TABLE)
|
||||||
|
->columns(
|
||||||
|
Task::TABLE.'.id',
|
||||||
|
Task::TABLE.'.title',
|
||||||
|
Task::TABLE.'.date_due',
|
||||||
|
Task::TABLE.'.project_id',
|
||||||
|
Project::TABLE.'.name AS project_name',
|
||||||
|
User::TABLE.'.username AS assignee_username',
|
||||||
|
User::TABLE.'.name AS assignee_name'
|
||||||
|
)
|
||||||
|
->join(Project::TABLE, 'id', 'project_id')
|
||||||
|
->join(User::TABLE, 'id', 'owner_id')
|
||||||
|
->eq(Project::TABLE.'.is_active', 1)
|
||||||
|
->eq(Task::TABLE.'.is_active', 1)
|
||||||
|
->neq(Task::TABLE.'.date_due', 0)
|
||||||
|
->lte(Task::TABLE.'.date_due', mktime(23, 59, 59))
|
||||||
|
->findAll();
|
||||||
|
|
||||||
|
return $tasks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch a task by the id
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param integer $task_id Task id
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getById($task_id)
|
||||||
|
{
|
||||||
|
return $this->db->table(Task::TABLE)->eq('id', $task_id)->findOne();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch a task by the reference (external id)
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string $reference Task reference
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getByReference($reference)
|
||||||
|
{
|
||||||
|
return $this->db->table(Task::TABLE)->eq('reference', $reference)->findOne();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get task details (fetch more information from other tables)
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param integer $task_id Task id
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getDetails($task_id)
|
||||||
|
{
|
||||||
|
$sql = '
|
||||||
|
SELECT
|
||||||
|
tasks.id,
|
||||||
|
tasks.reference,
|
||||||
|
tasks.title,
|
||||||
|
tasks.description,
|
||||||
|
tasks.date_creation,
|
||||||
|
tasks.date_completed,
|
||||||
|
tasks.date_modification,
|
||||||
|
tasks.date_due,
|
||||||
|
tasks.date_started,
|
||||||
|
tasks.time_estimated,
|
||||||
|
tasks.time_spent,
|
||||||
|
tasks.color_id,
|
||||||
|
tasks.project_id,
|
||||||
|
tasks.column_id,
|
||||||
|
tasks.owner_id,
|
||||||
|
tasks.creator_id,
|
||||||
|
tasks.position,
|
||||||
|
tasks.is_active,
|
||||||
|
tasks.score,
|
||||||
|
tasks.category_id,
|
||||||
|
project_has_categories.name AS category_name,
|
||||||
|
projects.name AS project_name,
|
||||||
|
columns.title AS column_title,
|
||||||
|
users.username AS assignee_username,
|
||||||
|
users.name AS assignee_name,
|
||||||
|
creators.username AS creator_username,
|
||||||
|
creators.name AS creator_name
|
||||||
|
FROM tasks
|
||||||
|
LEFT JOIN users ON users.id = tasks.owner_id
|
||||||
|
LEFT JOIN users AS creators ON creators.id = tasks.creator_id
|
||||||
|
LEFT JOIN project_has_categories ON project_has_categories.id = tasks.category_id
|
||||||
|
LEFT JOIN projects ON projects.id = tasks.project_id
|
||||||
|
LEFT JOIN columns ON columns.id = tasks.column_id
|
||||||
|
WHERE tasks.id = ?
|
||||||
|
';
|
||||||
|
|
||||||
|
$rq = $this->db->execute($sql, array($task_id));
|
||||||
|
return $rq->fetch(PDO::FETCH_ASSOC);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count all tasks for a given project and status
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param integer $project_id Project id
|
||||||
|
* @param array $status List of status id
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
public function countByProjectId($project_id, array $status = array(Task::STATUS_OPEN, Task::STATUS_CLOSED))
|
||||||
|
{
|
||||||
|
return $this->db
|
||||||
|
->table(Task::TABLE)
|
||||||
|
->eq('project_id', $project_id)
|
||||||
|
->in('is_active', $status)
|
||||||
|
->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count the number of tasks for a given column and status
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param integer $project_id Project id
|
||||||
|
* @param integer $column_id Column id
|
||||||
|
* @param array $status List of status id
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
public function countByColumnId($project_id, $column_id, array $status = array(Task::STATUS_OPEN))
|
||||||
|
{
|
||||||
|
return $this->db
|
||||||
|
->table(Task::TABLE)
|
||||||
|
->eq('project_id', $project_id)
|
||||||
|
->eq('column_id', $column_id)
|
||||||
|
->in('is_active', $status)
|
||||||
|
->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count the number of tasks for a custom search
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param integer $project_id Project id
|
||||||
|
* @param string $search Search terms
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
public function countSearch($project_id, $search)
|
||||||
|
{
|
||||||
|
return $this->db->table(Task::TABLE)
|
||||||
|
->eq('project_id', $project_id)
|
||||||
|
->like('title', '%'.$search.'%')
|
||||||
|
->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if the task exists
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param integer $task_id Task id
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function exists($task_id)
|
||||||
|
{
|
||||||
|
return $this->db->table(Task::TABLE)->eq('id', $task_id)->count() === 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
10
jsonrpc.php
10
jsonrpc.php
@@ -6,6 +6,7 @@ use JsonRPC\Server;
|
|||||||
use Model\Project;
|
use Model\Project;
|
||||||
use Model\ProjectPermission;
|
use Model\ProjectPermission;
|
||||||
use Model\Task;
|
use Model\Task;
|
||||||
|
use Model\TaskFinder;
|
||||||
use Model\TaskValidator;
|
use Model\TaskValidator;
|
||||||
use Model\User;
|
use Model\User;
|
||||||
use Model\Config;
|
use Model\Config;
|
||||||
@@ -24,6 +25,7 @@ $config->setupTimezone();
|
|||||||
$project = new Project($registry);
|
$project = new Project($registry);
|
||||||
$projectPermission = new ProjectPermission($registry);
|
$projectPermission = new ProjectPermission($registry);
|
||||||
$task = new Task($registry);
|
$task = new Task($registry);
|
||||||
|
$taskFinder = new TaskFinder($registry);
|
||||||
$taskValidator = new TaskValidator($registry);
|
$taskValidator = new TaskValidator($registry);
|
||||||
$user = new User($registry);
|
$user = new User($registry);
|
||||||
$category = new Category($registry);
|
$category = new Category($registry);
|
||||||
@@ -178,12 +180,12 @@ $server->register('createTask', function($title, $project_id, $color_id = '', $c
|
|||||||
return $valid && $task->create($values) !== false;
|
return $valid && $task->create($values) !== false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$server->register('getTask', function($task_id) use ($task) {
|
$server->register('getTask', function($task_id) use ($taskFinder) {
|
||||||
return $task->getById($task_id);
|
return $taskFinder->getById($task_id);
|
||||||
});
|
});
|
||||||
|
|
||||||
$server->register('getAllTasks', function($project_id, $status) use ($task) {
|
$server->register('getAllTasks', function($project_id, $status) use ($taskFinder) {
|
||||||
return $task->getAll($project_id, $status);
|
return $taskFinder->getAll($project_id, $status);
|
||||||
});
|
});
|
||||||
|
|
||||||
$server->register('updateTask', function($id, $title = null, $project_id = null, $color_id = null, $column_id = null, $owner_id = null, $creator_id = null, $date_due = null, $description = null, $category_id = null, $score = null) use ($task, $taskValidator) {
|
$server->register('updateTask', function($id, $title = null, $project_id = null, $color_id = null, $column_id = null, $owner_id = null, $creator_id = null, $date_due = null, $description = null, $category_id = null, $score = null) use ($task, $taskValidator) {
|
||||||
|
|||||||
3
kanboard
3
kanboard
@@ -7,6 +7,7 @@ use Core\Cli;
|
|||||||
use Core\Tool;
|
use Core\Tool;
|
||||||
use Model\Config;
|
use Model\Config;
|
||||||
use Model\Task;
|
use Model\Task;
|
||||||
|
use Model\TaskFinder;
|
||||||
use Model\TaskExport;
|
use Model\TaskExport;
|
||||||
use Model\Notification;
|
use Model\Notification;
|
||||||
|
|
||||||
@@ -47,7 +48,7 @@ $cli->register('export-csv', function() use ($cli, $registry) {
|
|||||||
$cli->register('send-notifications-due-tasks', function() use ($cli, $registry) {
|
$cli->register('send-notifications-due-tasks', function() use ($cli, $registry) {
|
||||||
|
|
||||||
$notificationModel = new Notification($registry);
|
$notificationModel = new Notification($registry);
|
||||||
$taskModel = new Task($registry);
|
$taskModel = new TaskFinder($registry);
|
||||||
$tasks = $taskModel->getOverdueTasks();
|
$tasks = $taskModel->getOverdueTasks();
|
||||||
|
|
||||||
// Group tasks by project
|
// Group tasks by project
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
require_once __DIR__.'/Base.php';
|
require_once __DIR__.'/Base.php';
|
||||||
|
|
||||||
use Model\Task;
|
use Model\Task;
|
||||||
|
use Model\TaskFinder;
|
||||||
use Model\Project;
|
use Model\Project;
|
||||||
use Model\Category;
|
use Model\Category;
|
||||||
|
|
||||||
@@ -30,6 +31,7 @@ class ActionTaskAssignColorCategory extends Base
|
|||||||
|
|
||||||
// We create a task in the first column
|
// We create a task in the first column
|
||||||
$t = new Task($this->registry);
|
$t = new Task($this->registry);
|
||||||
|
$tf = new TaskFinder($this->registry);
|
||||||
$p = new Project($this->registry);
|
$p = new Project($this->registry);
|
||||||
$c = new Category($this->registry);
|
$c = new Category($this->registry);
|
||||||
|
|
||||||
@@ -51,7 +53,7 @@ class ActionTaskAssignColorCategory extends Base
|
|||||||
$this->assertFalse($action->execute($event));
|
$this->assertFalse($action->execute($event));
|
||||||
|
|
||||||
// Our task should be assigned to the ategory_id=1 and have the green color
|
// Our task should be assigned to the ategory_id=1 and have the green color
|
||||||
$task = $t->getById(1);
|
$task = $tf->getById(1);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
$this->assertEquals(2, $task['category_id']);
|
$this->assertEquals(2, $task['category_id']);
|
||||||
$this->assertEquals('green', $task['color_id']);
|
$this->assertEquals('green', $task['color_id']);
|
||||||
@@ -69,7 +71,7 @@ class ActionTaskAssignColorCategory extends Base
|
|||||||
$this->assertTrue($action->execute($event));
|
$this->assertTrue($action->execute($event));
|
||||||
|
|
||||||
// Our task should have the blue color
|
// Our task should have the blue color
|
||||||
$task = $t->getById(1);
|
$task = $tf->getById(1);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
$this->assertEquals('blue', $task['color_id']);
|
$this->assertEquals('blue', $task['color_id']);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
require_once __DIR__.'/Base.php';
|
require_once __DIR__.'/Base.php';
|
||||||
|
|
||||||
use Model\Task;
|
use Model\Task;
|
||||||
|
use Model\TaskFinder;
|
||||||
use Model\Project;
|
use Model\Project;
|
||||||
|
|
||||||
class ActionTaskAssignColorUser extends Base
|
class ActionTaskAssignColorUser extends Base
|
||||||
@@ -29,6 +30,7 @@ class ActionTaskAssignColorUser extends Base
|
|||||||
|
|
||||||
// We create a task in the first column
|
// We create a task in the first column
|
||||||
$t = new Task($this->registry);
|
$t = new Task($this->registry);
|
||||||
|
$tf = new TaskFinder($this->registry);
|
||||||
$p = new Project($this->registry);
|
$p = new Project($this->registry);
|
||||||
$this->assertEquals(1, $p->create(array('name' => 'test')));
|
$this->assertEquals(1, $p->create(array('name' => 'test')));
|
||||||
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1, 'color_id' => 'green')));
|
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1, 'color_id' => 'green')));
|
||||||
@@ -44,7 +46,7 @@ class ActionTaskAssignColorUser extends Base
|
|||||||
$this->assertFalse($action->execute($event));
|
$this->assertFalse($action->execute($event));
|
||||||
|
|
||||||
// Our task should be assigned to nobody and have the green color
|
// Our task should be assigned to nobody and have the green color
|
||||||
$task = $t->getById(1);
|
$task = $tf->getById(1);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
$this->assertEquals(0, $task['owner_id']);
|
$this->assertEquals(0, $task['owner_id']);
|
||||||
$this->assertEquals('green', $task['color_id']);
|
$this->assertEquals('green', $task['color_id']);
|
||||||
@@ -60,7 +62,7 @@ class ActionTaskAssignColorUser extends Base
|
|||||||
$this->assertTrue($action->execute($event));
|
$this->assertTrue($action->execute($event));
|
||||||
|
|
||||||
// Our task should be assigned to nobody and have the blue color
|
// Our task should be assigned to nobody and have the blue color
|
||||||
$task = $t->getById(1);
|
$task = $tf->getById(1);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
$this->assertEquals(0, $task['owner_id']);
|
$this->assertEquals(0, $task['owner_id']);
|
||||||
$this->assertEquals('blue', $task['color_id']);
|
$this->assertEquals('blue', $task['color_id']);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
require_once __DIR__.'/Base.php';
|
require_once __DIR__.'/Base.php';
|
||||||
|
|
||||||
use Model\Task;
|
use Model\Task;
|
||||||
|
use Model\TaskFinder;
|
||||||
use Model\Project;
|
use Model\Project;
|
||||||
use Model\Acl;
|
use Model\Acl;
|
||||||
|
|
||||||
@@ -47,6 +48,7 @@ class ActionTaskAssignCurrentUser extends Base
|
|||||||
|
|
||||||
// We create a task in the first column
|
// We create a task in the first column
|
||||||
$t = new Task($this->registry);
|
$t = new Task($this->registry);
|
||||||
|
$tf = new TaskFinder($this->registry);
|
||||||
$p = new Project($this->registry);
|
$p = new Project($this->registry);
|
||||||
$a = new Acl($this->registry);
|
$a = new Acl($this->registry);
|
||||||
|
|
||||||
@@ -65,7 +67,7 @@ class ActionTaskAssignCurrentUser extends Base
|
|||||||
$this->assertTrue($action->execute($event));
|
$this->assertTrue($action->execute($event));
|
||||||
|
|
||||||
// Our task should be assigned to the user 5 (from the session)
|
// Our task should be assigned to the user 5 (from the session)
|
||||||
$task = $t->getById(1);
|
$task = $tf->getById(1);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
$this->assertEquals(1, $task['id']);
|
$this->assertEquals(1, $task['id']);
|
||||||
$this->assertEquals(5, $task['owner_id']);
|
$this->assertEquals(5, $task['owner_id']);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
require_once __DIR__.'/Base.php';
|
require_once __DIR__.'/Base.php';
|
||||||
|
|
||||||
use Model\Task;
|
use Model\Task;
|
||||||
|
use Model\TaskFinder;
|
||||||
use Model\Project;
|
use Model\Project;
|
||||||
|
|
||||||
class ActionTaskAssignSpecificUser extends Base
|
class ActionTaskAssignSpecificUser extends Base
|
||||||
@@ -44,6 +45,7 @@ class ActionTaskAssignSpecificUser extends Base
|
|||||||
|
|
||||||
// We create a task in the first column
|
// We create a task in the first column
|
||||||
$t = new Task($this->registry);
|
$t = new Task($this->registry);
|
||||||
|
$tf = new TaskFinder($this->registry);
|
||||||
$p = new Project($this->registry);
|
$p = new Project($this->registry);
|
||||||
$this->assertEquals(1, $p->create(array('name' => 'test')));
|
$this->assertEquals(1, $p->create(array('name' => 'test')));
|
||||||
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));
|
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));
|
||||||
@@ -59,7 +61,7 @@ class ActionTaskAssignSpecificUser extends Base
|
|||||||
$this->assertTrue($action->execute($event));
|
$this->assertTrue($action->execute($event));
|
||||||
|
|
||||||
// Our task should be assigned to the user 1
|
// Our task should be assigned to the user 1
|
||||||
$task = $t->getById(1);
|
$task = $tf->getById(1);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
$this->assertEquals(1, $task['owner_id']);
|
$this->assertEquals(1, $task['owner_id']);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
require_once __DIR__.'/Base.php';
|
require_once __DIR__.'/Base.php';
|
||||||
|
|
||||||
use Model\Task;
|
use Model\Task;
|
||||||
|
use Model\TaskFinder;
|
||||||
use Model\Project;
|
use Model\Project;
|
||||||
use Model\GithubWebhook;
|
use Model\GithubWebhook;
|
||||||
|
|
||||||
@@ -82,6 +83,7 @@ class ActionTaskCloseTest extends Base
|
|||||||
|
|
||||||
// We create a task in the first column
|
// We create a task in the first column
|
||||||
$t = new Task($this->registry);
|
$t = new Task($this->registry);
|
||||||
|
$tf = new TaskFinder($this->registry);
|
||||||
$p = new Project($this->registry);
|
$p = new Project($this->registry);
|
||||||
$this->assertEquals(1, $p->create(array('name' => 'test')));
|
$this->assertEquals(1, $p->create(array('name' => 'test')));
|
||||||
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));
|
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));
|
||||||
@@ -97,7 +99,7 @@ class ActionTaskCloseTest extends Base
|
|||||||
$this->assertTrue($action->execute($event));
|
$this->assertTrue($action->execute($event));
|
||||||
|
|
||||||
// Our task should be closed
|
// Our task should be closed
|
||||||
$task = $t->getById(1);
|
$task = $tf->getById(1);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
$this->assertEquals(0, $task['is_active']);
|
$this->assertEquals(0, $task['is_active']);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
require_once __DIR__.'/Base.php';
|
require_once __DIR__.'/Base.php';
|
||||||
|
|
||||||
use Model\Task;
|
use Model\Task;
|
||||||
|
use Model\TaskFinder;
|
||||||
use Model\Project;
|
use Model\Project;
|
||||||
|
|
||||||
class ActionTaskDuplicateAnotherProject extends Base
|
class ActionTaskDuplicateAnotherProject extends Base
|
||||||
@@ -42,6 +43,7 @@ class ActionTaskDuplicateAnotherProject extends Base
|
|||||||
|
|
||||||
// We create a task in the first column
|
// We create a task in the first column
|
||||||
$t = new Task($this->registry);
|
$t = new Task($this->registry);
|
||||||
|
$tf = new TaskFinder($this->registry);
|
||||||
$p = new Project($this->registry);
|
$p = new Project($this->registry);
|
||||||
$this->assertEquals(1, $p->create(array('name' => 'project 1')));
|
$this->assertEquals(1, $p->create(array('name' => 'project 1')));
|
||||||
$this->assertEquals(2, $p->create(array('name' => 'project 2')));
|
$this->assertEquals(2, $p->create(array('name' => 'project 2')));
|
||||||
@@ -60,7 +62,7 @@ class ActionTaskDuplicateAnotherProject extends Base
|
|||||||
$this->assertFalse($action->execute($event));
|
$this->assertFalse($action->execute($event));
|
||||||
|
|
||||||
// Our task should be assigned to the project 1
|
// Our task should be assigned to the project 1
|
||||||
$task = $t->getById(1);
|
$task = $tf->getById(1);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
$this->assertEquals(1, $task['project_id']);
|
$this->assertEquals(1, $task['project_id']);
|
||||||
|
|
||||||
@@ -77,12 +79,12 @@ class ActionTaskDuplicateAnotherProject extends Base
|
|||||||
$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
|
||||||
$task = $t->getById(1);
|
$task = $tf->getById(1);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
$this->assertEquals(1, $task['project_id']);
|
$this->assertEquals(1, $task['project_id']);
|
||||||
|
|
||||||
// We should have another task assigned to the project 2
|
// We should have another task assigned to the project 2
|
||||||
$task = $t->getById(2);
|
$task = $tf->getById(2);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
$this->assertEquals(2, $task['project_id']);
|
$this->assertEquals(2, $task['project_id']);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
require_once __DIR__.'/Base.php';
|
require_once __DIR__.'/Base.php';
|
||||||
|
|
||||||
use Model\Task;
|
use Model\Task;
|
||||||
|
use Model\TaskFinder;
|
||||||
use Model\Project;
|
use Model\Project;
|
||||||
|
|
||||||
class ActionTaskMoveAnotherProject extends Base
|
class ActionTaskMoveAnotherProject extends Base
|
||||||
@@ -42,6 +43,7 @@ class ActionTaskMoveAnotherProject extends Base
|
|||||||
|
|
||||||
// We create a task in the first column
|
// We create a task in the first column
|
||||||
$t = new Task($this->registry);
|
$t = new Task($this->registry);
|
||||||
|
$tf = new TaskFinder($this->registry);
|
||||||
$p = new Project($this->registry);
|
$p = new Project($this->registry);
|
||||||
$this->assertEquals(1, $p->create(array('name' => 'project 1')));
|
$this->assertEquals(1, $p->create(array('name' => 'project 1')));
|
||||||
$this->assertEquals(2, $p->create(array('name' => 'project 2')));
|
$this->assertEquals(2, $p->create(array('name' => 'project 2')));
|
||||||
@@ -60,7 +62,7 @@ class ActionTaskMoveAnotherProject extends Base
|
|||||||
$this->assertFalse($action->execute($event));
|
$this->assertFalse($action->execute($event));
|
||||||
|
|
||||||
// Our task should be assigned to the project 1
|
// Our task should be assigned to the project 1
|
||||||
$task = $t->getById(1);
|
$task = $tf->getById(1);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
$this->assertEquals(1, $task['project_id']);
|
$this->assertEquals(1, $task['project_id']);
|
||||||
|
|
||||||
@@ -77,7 +79,7 @@ class ActionTaskMoveAnotherProject extends Base
|
|||||||
$this->assertTrue($action->execute($event));
|
$this->assertTrue($action->execute($event));
|
||||||
|
|
||||||
// Our task should be assigned to the project 2
|
// Our task should be assigned to the project 2
|
||||||
$task = $t->getById(1);
|
$task = $tf->getById(1);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
$this->assertEquals(2, $task['project_id']);
|
$this->assertEquals(2, $task['project_id']);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use Model\Action;
|
|||||||
use Model\Project;
|
use Model\Project;
|
||||||
use Model\Board;
|
use Model\Board;
|
||||||
use Model\Task;
|
use Model\Task;
|
||||||
|
use Model\TaskFinder;
|
||||||
use Model\Category;
|
use Model\Category;
|
||||||
|
|
||||||
class ActionTest extends Base
|
class ActionTest extends Base
|
||||||
@@ -49,6 +50,7 @@ class ActionTest extends Base
|
|||||||
public function testEventMoveColumn()
|
public function testEventMoveColumn()
|
||||||
{
|
{
|
||||||
$task = new Task($this->registry);
|
$task = new Task($this->registry);
|
||||||
|
$tf = new TaskFinder($this->registry);
|
||||||
$board = new Board($this->registry);
|
$board = new Board($this->registry);
|
||||||
$project = new Project($this->registry);
|
$project = new Project($this->registry);
|
||||||
$action = new Action($this->registry);
|
$action = new Action($this->registry);
|
||||||
@@ -79,7 +81,7 @@ class ActionTest extends Base
|
|||||||
$action->attachEvents();
|
$action->attachEvents();
|
||||||
|
|
||||||
// Our task should be open
|
// Our task should be open
|
||||||
$t1 = $task->getById(1);
|
$t1 = $tf->getById(1);
|
||||||
$this->assertEquals(1, $t1['is_active']);
|
$this->assertEquals(1, $t1['is_active']);
|
||||||
$this->assertEquals(1, $t1['column_id']);
|
$this->assertEquals(1, $t1['column_id']);
|
||||||
|
|
||||||
@@ -90,7 +92,7 @@ class ActionTest extends Base
|
|||||||
$this->assertFalse($this->registry->shared('event')->isEventTriggered(Task::EVENT_UPDATE));
|
$this->assertFalse($this->registry->shared('event')->isEventTriggered(Task::EVENT_UPDATE));
|
||||||
|
|
||||||
// Our task should be closed
|
// Our task should be closed
|
||||||
$t1 = $task->getById(1);
|
$t1 = $tf->getById(1);
|
||||||
$this->assertEquals(4, $t1['column_id']);
|
$this->assertEquals(4, $t1['column_id']);
|
||||||
$this->assertEquals(0, $t1['is_active']);
|
$this->assertEquals(0, $t1['is_active']);
|
||||||
}
|
}
|
||||||
@@ -98,6 +100,7 @@ class ActionTest extends Base
|
|||||||
public function testExecuteMultipleActions()
|
public function testExecuteMultipleActions()
|
||||||
{
|
{
|
||||||
$task = new Task($this->registry);
|
$task = new Task($this->registry);
|
||||||
|
$tf = new TaskFinder($this->registry);
|
||||||
$board = new Board($this->registry);
|
$board = new Board($this->registry);
|
||||||
$project = new Project($this->registry);
|
$project = new Project($this->registry);
|
||||||
$action = new Action($this->registry);
|
$action = new Action($this->registry);
|
||||||
@@ -143,7 +146,7 @@ class ActionTest extends Base
|
|||||||
$this->assertTrue($this->registry->shared('event')->hasListener(Task::EVENT_MOVE_COLUMN, 'Action\TaskClose'));
|
$this->assertTrue($this->registry->shared('event')->hasListener(Task::EVENT_MOVE_COLUMN, 'Action\TaskClose'));
|
||||||
|
|
||||||
// Our task should be open, linked to the first project and in the first column
|
// Our task should be open, linked to the first project and in the first column
|
||||||
$t1 = $task->getById(1);
|
$t1 = $tf->getById(1);
|
||||||
$this->assertEquals(1, $t1['is_active']);
|
$this->assertEquals(1, $t1['is_active']);
|
||||||
$this->assertEquals(1, $t1['column_id']);
|
$this->assertEquals(1, $t1['column_id']);
|
||||||
$this->assertEquals(1, $t1['project_id']);
|
$this->assertEquals(1, $t1['project_id']);
|
||||||
@@ -155,12 +158,12 @@ class ActionTest extends Base
|
|||||||
$this->assertTrue($this->registry->shared('event')->isEventTriggered(Task::EVENT_MOVE_COLUMN));
|
$this->assertTrue($this->registry->shared('event')->isEventTriggered(Task::EVENT_MOVE_COLUMN));
|
||||||
|
|
||||||
// Our task should be closed
|
// Our task should be closed
|
||||||
$t1 = $task->getById(1);
|
$t1 = $tf->getById(1);
|
||||||
$this->assertEquals(4, $t1['column_id']);
|
$this->assertEquals(4, $t1['column_id']);
|
||||||
$this->assertEquals(0, $t1['is_active']);
|
$this->assertEquals(0, $t1['is_active']);
|
||||||
|
|
||||||
// Our task should be duplicated to the 2nd project
|
// Our task should be duplicated to the 2nd project
|
||||||
$t2 = $task->getById(2);
|
$t2 = $tf->getById(2);
|
||||||
$this->assertNotEmpty($t2);
|
$this->assertNotEmpty($t2);
|
||||||
$this->assertNotEquals(4, $t2['column_id']);
|
$this->assertNotEquals(4, $t2['column_id']);
|
||||||
$this->assertEquals(1, $t2['is_active']);
|
$this->assertEquals(1, $t2['is_active']);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
require_once __DIR__.'/Base.php';
|
require_once __DIR__.'/Base.php';
|
||||||
|
|
||||||
use Model\Task;
|
use Model\Task;
|
||||||
|
use Model\TaskFinder;
|
||||||
use Model\Project;
|
use Model\Project;
|
||||||
use Model\Category;
|
use Model\Category;
|
||||||
use Model\User;
|
use Model\User;
|
||||||
@@ -12,6 +13,7 @@ class CategoryTest extends Base
|
|||||||
public function testCreation()
|
public function testCreation()
|
||||||
{
|
{
|
||||||
$t = new Task($this->registry);
|
$t = new Task($this->registry);
|
||||||
|
$tf = new TaskFinder($this->registry);
|
||||||
$p = new Project($this->registry);
|
$p = new Project($this->registry);
|
||||||
$c = new Category($this->registry);
|
$c = new Category($this->registry);
|
||||||
|
|
||||||
@@ -20,7 +22,7 @@ class CategoryTest extends Base
|
|||||||
$this->assertEquals(2, $c->create(array('name' => 'Category #2', 'project_id' => 1)));
|
$this->assertEquals(2, $c->create(array('name' => 'Category #2', 'project_id' => 1)));
|
||||||
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'category_id' => 2)));
|
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'category_id' => 2)));
|
||||||
|
|
||||||
$task = $t->getById(1);
|
$task = $tf->getById(1);
|
||||||
$this->assertTrue(is_array($task));
|
$this->assertTrue(is_array($task));
|
||||||
$this->assertEquals(2, $task['category_id']);
|
$this->assertEquals(2, $task['category_id']);
|
||||||
|
|
||||||
@@ -34,6 +36,7 @@ class CategoryTest extends Base
|
|||||||
public function testRemove()
|
public function testRemove()
|
||||||
{
|
{
|
||||||
$t = new Task($this->registry);
|
$t = new Task($this->registry);
|
||||||
|
$tf = new TaskFinder($this->registry);
|
||||||
$p = new Project($this->registry);
|
$p = new Project($this->registry);
|
||||||
$c = new Category($this->registry);
|
$c = new Category($this->registry);
|
||||||
|
|
||||||
@@ -42,7 +45,7 @@ class CategoryTest extends Base
|
|||||||
$this->assertEquals(2, $c->create(array('name' => 'Category #2', 'project_id' => 1)));
|
$this->assertEquals(2, $c->create(array('name' => 'Category #2', 'project_id' => 1)));
|
||||||
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'category_id' => 2)));
|
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'category_id' => 2)));
|
||||||
|
|
||||||
$task = $t->getById(1);
|
$task = $tf->getById(1);
|
||||||
$this->assertTrue(is_array($task));
|
$this->assertTrue(is_array($task));
|
||||||
$this->assertEquals(2, $task['category_id']);
|
$this->assertEquals(2, $task['category_id']);
|
||||||
|
|
||||||
@@ -50,7 +53,7 @@ class CategoryTest extends Base
|
|||||||
$this->assertTrue($c->remove(2));
|
$this->assertTrue($c->remove(2));
|
||||||
|
|
||||||
// Make sure tasks assigned with that category are reseted
|
// Make sure tasks assigned with that category are reseted
|
||||||
$task = $t->getById(1);
|
$task = $tf->getById(1);
|
||||||
$this->assertTrue(is_array($task));
|
$this->assertTrue(is_array($task));
|
||||||
$this->assertEquals(0, $task['category_id']);
|
$this->assertEquals(0, $task['category_id']);
|
||||||
}
|
}
|
||||||
|
|||||||
32
tests/units/TaskFinderTest.php
Normal file
32
tests/units/TaskFinderTest.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__.'/Base.php';
|
||||||
|
|
||||||
|
use Model\Task;
|
||||||
|
use Model\TaskFinder;
|
||||||
|
use Model\Project;
|
||||||
|
use Model\ProjectPermission;
|
||||||
|
use Model\Category;
|
||||||
|
use Model\User;
|
||||||
|
|
||||||
|
class TaskFinderTest extends Base
|
||||||
|
{
|
||||||
|
public function testGetOverdueTasks()
|
||||||
|
{
|
||||||
|
$t = new Task($this->registry);
|
||||||
|
$tf = new TaskFinder($this->registry);
|
||||||
|
$p = new Project($this->registry);
|
||||||
|
|
||||||
|
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
||||||
|
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'date_due' => strtotime('-1 day'))));
|
||||||
|
$this->assertEquals(2, $t->create(array('title' => 'Task #2', 'project_id' => 1, 'date_due' => strtotime('+1 day'))));
|
||||||
|
$this->assertEquals(3, $t->create(array('title' => 'Task #3', 'project_id' => 1, 'date_due' => 0)));
|
||||||
|
$this->assertEquals(4, $t->create(array('title' => 'Task #3', 'project_id' => 1)));
|
||||||
|
|
||||||
|
$tasks = $tf->getOverdueTasks();
|
||||||
|
$this->assertNotEmpty($tasks);
|
||||||
|
$this->assertTrue(is_array($tasks));
|
||||||
|
$this->assertEquals(1, count($tasks));
|
||||||
|
$this->assertEquals('Task #1', $tasks[0]['title']);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
require_once __DIR__.'/Base.php';
|
require_once __DIR__.'/Base.php';
|
||||||
|
|
||||||
use Model\Task;
|
use Model\Task;
|
||||||
|
use Model\TaskFinder;
|
||||||
use Model\TaskPermission;
|
use Model\TaskPermission;
|
||||||
use Model\Project;
|
use Model\Project;
|
||||||
use Model\Category;
|
use Model\Category;
|
||||||
@@ -13,6 +14,7 @@ class TaskPermissionTest extends Base
|
|||||||
public function testPrepareCreation()
|
public function testPrepareCreation()
|
||||||
{
|
{
|
||||||
$t = new Task($this->registry);
|
$t = new Task($this->registry);
|
||||||
|
$tf = new TaskFinder($this->registry);
|
||||||
$tp = new TaskPermission($this->registry);
|
$tp = new TaskPermission($this->registry);
|
||||||
$p = new Project($this->registry);
|
$p = new Project($this->registry);
|
||||||
$u = new User($this->registry);
|
$u = new User($this->registry);
|
||||||
@@ -30,7 +32,7 @@ class TaskPermissionTest extends Base
|
|||||||
$this->assertNotEmpty($user);
|
$this->assertNotEmpty($user);
|
||||||
$u->updateSession($user);
|
$u->updateSession($user);
|
||||||
|
|
||||||
$task = $t->getbyId(1);
|
$task = $tf->getbyId(1);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
$this->assertTrue($tp->canRemoveTask($task));
|
$this->assertTrue($tp->canRemoveTask($task));
|
||||||
|
|
||||||
@@ -39,7 +41,7 @@ class TaskPermissionTest extends Base
|
|||||||
$this->assertNotEmpty($user);
|
$this->assertNotEmpty($user);
|
||||||
$u->updateSession($user);
|
$u->updateSession($user);
|
||||||
|
|
||||||
$task = $t->getbyId(1);
|
$task = $tf->getbyId(1);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
$this->assertFalse($tp->canRemoveTask($task));
|
$this->assertFalse($tp->canRemoveTask($task));
|
||||||
|
|
||||||
@@ -48,7 +50,7 @@ class TaskPermissionTest extends Base
|
|||||||
$this->assertNotEmpty($user);
|
$this->assertNotEmpty($user);
|
||||||
$u->updateSession($user);
|
$u->updateSession($user);
|
||||||
|
|
||||||
$task = $t->getbyId(2);
|
$task = $tf->getbyId(2);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
$this->assertTrue($tp->canRemoveTask($task));
|
$this->assertTrue($tp->canRemoveTask($task));
|
||||||
|
|
||||||
@@ -57,7 +59,7 @@ class TaskPermissionTest extends Base
|
|||||||
$this->assertNotEmpty($user);
|
$this->assertNotEmpty($user);
|
||||||
$u->updateSession($user);
|
$u->updateSession($user);
|
||||||
|
|
||||||
$task = $t->getbyId(2);
|
$task = $tf->getbyId(2);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
$this->assertTrue($tp->canRemoveTask($task));
|
$this->assertTrue($tp->canRemoveTask($task));
|
||||||
|
|
||||||
@@ -66,7 +68,7 @@ class TaskPermissionTest extends Base
|
|||||||
$this->assertNotEmpty($user);
|
$this->assertNotEmpty($user);
|
||||||
$u->updateSession($user);
|
$u->updateSession($user);
|
||||||
|
|
||||||
$task = $t->getbyId(3);
|
$task = $tf->getbyId(3);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
$this->assertTrue($tp->canRemoveTask($task));
|
$this->assertTrue($tp->canRemoveTask($task));
|
||||||
|
|
||||||
@@ -75,7 +77,7 @@ class TaskPermissionTest extends Base
|
|||||||
$this->assertNotEmpty($user);
|
$this->assertNotEmpty($user);
|
||||||
$u->updateSession($user);
|
$u->updateSession($user);
|
||||||
|
|
||||||
$task = $t->getbyId(3);
|
$task = $tf->getbyId(3);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
$this->assertFalse($tp->canRemoveTask($task));
|
$this->assertFalse($tp->canRemoveTask($task));
|
||||||
|
|
||||||
@@ -84,7 +86,7 @@ class TaskPermissionTest extends Base
|
|||||||
$this->assertNotEmpty($user);
|
$this->assertNotEmpty($user);
|
||||||
$u->updateSession($user);
|
$u->updateSession($user);
|
||||||
|
|
||||||
$task = $t->getbyId(4);
|
$task = $tf->getbyId(4);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
$this->assertTrue($tp->canRemoveTask($task));
|
$this->assertTrue($tp->canRemoveTask($task));
|
||||||
|
|
||||||
@@ -93,7 +95,7 @@ class TaskPermissionTest extends Base
|
|||||||
$this->assertNotEmpty($user);
|
$this->assertNotEmpty($user);
|
||||||
$u->updateSession($user);
|
$u->updateSession($user);
|
||||||
|
|
||||||
$task = $t->getbyId(4);
|
$task = $tf->getbyId(4);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
$this->assertFalse($tp->canRemoveTask($task));
|
$this->assertFalse($tp->canRemoveTask($task));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
require_once __DIR__.'/Base.php';
|
require_once __DIR__.'/Base.php';
|
||||||
|
|
||||||
use Model\Task;
|
use Model\Task;
|
||||||
|
use Model\TaskFinder;
|
||||||
use Model\Project;
|
use Model\Project;
|
||||||
use Model\ProjectPermission;
|
use Model\ProjectPermission;
|
||||||
use Model\Category;
|
use Model\Category;
|
||||||
@@ -13,6 +14,7 @@ class TaskTest extends Base
|
|||||||
public function testPrepareCreation()
|
public function testPrepareCreation()
|
||||||
{
|
{
|
||||||
$t = new Task($this->registry);
|
$t = new Task($this->registry);
|
||||||
|
$tf = new TaskFinder($this->registry);
|
||||||
$p = new Project($this->registry);
|
$p = new Project($this->registry);
|
||||||
|
|
||||||
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
||||||
@@ -91,6 +93,7 @@ class TaskTest extends Base
|
|||||||
public function testPrepareModification()
|
public function testPrepareModification()
|
||||||
{
|
{
|
||||||
$t = new Task($this->registry);
|
$t = new Task($this->registry);
|
||||||
|
$tf = new TaskFinder($this->registry);
|
||||||
$p = new Project($this->registry);
|
$p = new Project($this->registry);
|
||||||
|
|
||||||
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
||||||
@@ -110,12 +113,13 @@ class TaskTest extends Base
|
|||||||
public function testCreation()
|
public function testCreation()
|
||||||
{
|
{
|
||||||
$t = new Task($this->registry);
|
$t = new Task($this->registry);
|
||||||
|
$tf = new TaskFinder($this->registry);
|
||||||
$p = new Project($this->registry);
|
$p = new Project($this->registry);
|
||||||
|
|
||||||
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
||||||
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1)));
|
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1)));
|
||||||
|
|
||||||
$task = $t->getById(1);
|
$task = $tf->getById(1);
|
||||||
$this->assertEquals(1, $task['id']);
|
$this->assertEquals(1, $task['id']);
|
||||||
$this->assertEquals(1, $task['column_id']);
|
$this->assertEquals(1, $task['column_id']);
|
||||||
$this->assertEquals(1, $task['position']);
|
$this->assertEquals(1, $task['position']);
|
||||||
@@ -126,7 +130,7 @@ class TaskTest extends Base
|
|||||||
|
|
||||||
$this->assertEquals(2, $t->create(array('title' => 'Task #2', 'project_id' => 1)));
|
$this->assertEquals(2, $t->create(array('title' => 'Task #2', 'project_id' => 1)));
|
||||||
|
|
||||||
$task = $t->getById(2);
|
$task = $tf->getById(2);
|
||||||
$this->assertEquals(2, $task['id']);
|
$this->assertEquals(2, $task['id']);
|
||||||
$this->assertEquals(1, $task['column_id']);
|
$this->assertEquals(1, $task['column_id']);
|
||||||
$this->assertEquals(2, $task['position']);
|
$this->assertEquals(2, $task['position']);
|
||||||
@@ -134,19 +138,20 @@ class TaskTest extends Base
|
|||||||
$this->assertEquals(time(), $task['date_modification']);
|
$this->assertEquals(time(), $task['date_modification']);
|
||||||
$this->assertEquals(0, $task['date_due']);
|
$this->assertEquals(0, $task['date_due']);
|
||||||
|
|
||||||
$tasks = $t->getAll(1, 1);
|
$tasks = $tf->getAll(1, 1);
|
||||||
$this->assertNotEmpty($tasks);
|
$this->assertNotEmpty($tasks);
|
||||||
$this->assertTrue(is_array($tasks));
|
$this->assertTrue(is_array($tasks));
|
||||||
$this->assertEquals(1, $tasks[0]['id']);
|
$this->assertEquals(1, $tasks[0]['id']);
|
||||||
$this->assertEquals(2, $tasks[1]['id']);
|
$this->assertEquals(2, $tasks[1]['id']);
|
||||||
|
|
||||||
$tasks = $t->getAll(1, 0);
|
$tasks = $tf->getAll(1, 0);
|
||||||
$this->assertEmpty($tasks);
|
$this->assertEmpty($tasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRemove()
|
public function testRemove()
|
||||||
{
|
{
|
||||||
$t = new Task($this->registry);
|
$t = new Task($this->registry);
|
||||||
|
$tf = new TaskFinder($this->registry);
|
||||||
$p = new Project($this->registry);
|
$p = new Project($this->registry);
|
||||||
|
|
||||||
$this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
|
$this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
|
||||||
@@ -156,27 +161,10 @@ class TaskTest extends Base
|
|||||||
$this->assertFalse($t->remove(1234));
|
$this->assertFalse($t->remove(1234));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetOverdueTasks()
|
|
||||||
{
|
|
||||||
$t = new Task($this->registry);
|
|
||||||
$p = new Project($this->registry);
|
|
||||||
|
|
||||||
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
|
||||||
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'date_due' => strtotime('-1 day'))));
|
|
||||||
$this->assertEquals(2, $t->create(array('title' => 'Task #2', 'project_id' => 1, 'date_due' => strtotime('+1 day'))));
|
|
||||||
$this->assertEquals(3, $t->create(array('title' => 'Task #3', 'project_id' => 1, 'date_due' => 0)));
|
|
||||||
$this->assertEquals(4, $t->create(array('title' => 'Task #3', 'project_id' => 1)));
|
|
||||||
|
|
||||||
$tasks = $t->getOverdueTasks();
|
|
||||||
$this->assertNotEmpty($tasks);
|
|
||||||
$this->assertTrue(is_array($tasks));
|
|
||||||
$this->assertEquals(1, count($tasks));
|
|
||||||
$this->assertEquals('Task #1', $tasks[0]['title']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testMoveTaskWithColumnThatNotChange()
|
public function testMoveTaskWithColumnThatNotChange()
|
||||||
{
|
{
|
||||||
$t = new Task($this->registry);
|
$t = new Task($this->registry);
|
||||||
|
$tf = new TaskFinder($this->registry);
|
||||||
$p = new Project($this->registry);
|
$p = new Project($this->registry);
|
||||||
|
|
||||||
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
||||||
@@ -194,42 +182,42 @@ class TaskTest extends Base
|
|||||||
$this->assertTrue($t->movePosition(1, 3, 3, 2));
|
$this->assertTrue($t->movePosition(1, 3, 3, 2));
|
||||||
|
|
||||||
// Check tasks position
|
// Check tasks position
|
||||||
$task = $t->getById(1);
|
$task = $tf->getById(1);
|
||||||
$this->assertEquals(1, $task['id']);
|
$this->assertEquals(1, $task['id']);
|
||||||
$this->assertEquals(1, $task['column_id']);
|
$this->assertEquals(1, $task['column_id']);
|
||||||
$this->assertEquals(1, $task['position']);
|
$this->assertEquals(1, $task['position']);
|
||||||
|
|
||||||
$task = $t->getById(2);
|
$task = $tf->getById(2);
|
||||||
$this->assertEquals(2, $task['id']);
|
$this->assertEquals(2, $task['id']);
|
||||||
$this->assertEquals(1, $task['column_id']);
|
$this->assertEquals(1, $task['column_id']);
|
||||||
$this->assertEquals(2, $task['position']);
|
$this->assertEquals(2, $task['position']);
|
||||||
|
|
||||||
$task = $t->getById(3);
|
$task = $tf->getById(3);
|
||||||
$this->assertEquals(3, $task['id']);
|
$this->assertEquals(3, $task['id']);
|
||||||
$this->assertEquals(3, $task['column_id']);
|
$this->assertEquals(3, $task['column_id']);
|
||||||
$this->assertEquals(2, $task['position']);
|
$this->assertEquals(2, $task['position']);
|
||||||
|
|
||||||
$task = $t->getById(4);
|
$task = $tf->getById(4);
|
||||||
$this->assertEquals(4, $task['id']);
|
$this->assertEquals(4, $task['id']);
|
||||||
$this->assertEquals(2, $task['column_id']);
|
$this->assertEquals(2, $task['column_id']);
|
||||||
$this->assertEquals(1, $task['position']);
|
$this->assertEquals(1, $task['position']);
|
||||||
|
|
||||||
$task = $t->getById(5);
|
$task = $tf->getById(5);
|
||||||
$this->assertEquals(5, $task['id']);
|
$this->assertEquals(5, $task['id']);
|
||||||
$this->assertEquals(2, $task['column_id']);
|
$this->assertEquals(2, $task['column_id']);
|
||||||
$this->assertEquals(2, $task['position']);
|
$this->assertEquals(2, $task['position']);
|
||||||
|
|
||||||
$task = $t->getById(6);
|
$task = $tf->getById(6);
|
||||||
$this->assertEquals(6, $task['id']);
|
$this->assertEquals(6, $task['id']);
|
||||||
$this->assertEquals(2, $task['column_id']);
|
$this->assertEquals(2, $task['column_id']);
|
||||||
$this->assertEquals(3, $task['position']);
|
$this->assertEquals(3, $task['position']);
|
||||||
|
|
||||||
$task = $t->getById(7);
|
$task = $tf->getById(7);
|
||||||
$this->assertEquals(7, $task['id']);
|
$this->assertEquals(7, $task['id']);
|
||||||
$this->assertEquals(3, $task['column_id']);
|
$this->assertEquals(3, $task['column_id']);
|
||||||
$this->assertEquals(1, $task['position']);
|
$this->assertEquals(1, $task['position']);
|
||||||
|
|
||||||
$task = $t->getById(8);
|
$task = $tf->getById(8);
|
||||||
$this->assertEquals(8, $task['id']);
|
$this->assertEquals(8, $task['id']);
|
||||||
$this->assertEquals(1, $task['column_id']);
|
$this->assertEquals(1, $task['column_id']);
|
||||||
$this->assertEquals(3, $task['position']);
|
$this->assertEquals(3, $task['position']);
|
||||||
@@ -238,6 +226,7 @@ class TaskTest extends Base
|
|||||||
public function testMoveTaskWithBadPreviousPosition()
|
public function testMoveTaskWithBadPreviousPosition()
|
||||||
{
|
{
|
||||||
$t = new Task($this->registry);
|
$t = new Task($this->registry);
|
||||||
|
$tf = new TaskFinder($this->registry);
|
||||||
$p = new Project($this->registry);
|
$p = new Project($this->registry);
|
||||||
|
|
||||||
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
||||||
@@ -251,17 +240,17 @@ class TaskTest extends Base
|
|||||||
$this->assertTrue($t->movePosition(1, 1, 2, 3));
|
$this->assertTrue($t->movePosition(1, 1, 2, 3));
|
||||||
|
|
||||||
// Check tasks position
|
// Check tasks position
|
||||||
$task = $t->getById(2);
|
$task = $tf->getById(2);
|
||||||
$this->assertEquals(2, $task['id']);
|
$this->assertEquals(2, $task['id']);
|
||||||
$this->assertEquals(2, $task['column_id']);
|
$this->assertEquals(2, $task['column_id']);
|
||||||
$this->assertEquals(1, $task['position']);
|
$this->assertEquals(1, $task['position']);
|
||||||
|
|
||||||
$task = $t->getById(3);
|
$task = $tf->getById(3);
|
||||||
$this->assertEquals(3, $task['id']);
|
$this->assertEquals(3, $task['id']);
|
||||||
$this->assertEquals(2, $task['column_id']);
|
$this->assertEquals(2, $task['column_id']);
|
||||||
$this->assertEquals(2, $task['position']);
|
$this->assertEquals(2, $task['position']);
|
||||||
|
|
||||||
$task = $t->getById(1);
|
$task = $tf->getById(1);
|
||||||
$this->assertEquals(1, $task['id']);
|
$this->assertEquals(1, $task['id']);
|
||||||
$this->assertEquals(2, $task['column_id']);
|
$this->assertEquals(2, $task['column_id']);
|
||||||
$this->assertEquals(3, $task['position']);
|
$this->assertEquals(3, $task['position']);
|
||||||
@@ -270,6 +259,7 @@ class TaskTest extends Base
|
|||||||
public function testMoveTaskTop()
|
public function testMoveTaskTop()
|
||||||
{
|
{
|
||||||
$t = new Task($this->registry);
|
$t = new Task($this->registry);
|
||||||
|
$tf = new TaskFinder($this->registry);
|
||||||
$p = new Project($this->registry);
|
$p = new Project($this->registry);
|
||||||
|
|
||||||
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
||||||
@@ -282,22 +272,22 @@ class TaskTest extends Base
|
|||||||
$this->assertTrue($t->movePosition(1, 4, 1, 1));
|
$this->assertTrue($t->movePosition(1, 4, 1, 1));
|
||||||
|
|
||||||
// Check tasks position
|
// Check tasks position
|
||||||
$task = $t->getById(1);
|
$task = $tf->getById(1);
|
||||||
$this->assertEquals(1, $task['id']);
|
$this->assertEquals(1, $task['id']);
|
||||||
$this->assertEquals(1, $task['column_id']);
|
$this->assertEquals(1, $task['column_id']);
|
||||||
$this->assertEquals(2, $task['position']);
|
$this->assertEquals(2, $task['position']);
|
||||||
|
|
||||||
$task = $t->getById(2);
|
$task = $tf->getById(2);
|
||||||
$this->assertEquals(2, $task['id']);
|
$this->assertEquals(2, $task['id']);
|
||||||
$this->assertEquals(1, $task['column_id']);
|
$this->assertEquals(1, $task['column_id']);
|
||||||
$this->assertEquals(3, $task['position']);
|
$this->assertEquals(3, $task['position']);
|
||||||
|
|
||||||
$task = $t->getById(3);
|
$task = $tf->getById(3);
|
||||||
$this->assertEquals(3, $task['id']);
|
$this->assertEquals(3, $task['id']);
|
||||||
$this->assertEquals(1, $task['column_id']);
|
$this->assertEquals(1, $task['column_id']);
|
||||||
$this->assertEquals(4, $task['position']);
|
$this->assertEquals(4, $task['position']);
|
||||||
|
|
||||||
$task = $t->getById(4);
|
$task = $tf->getById(4);
|
||||||
$this->assertEquals(4, $task['id']);
|
$this->assertEquals(4, $task['id']);
|
||||||
$this->assertEquals(1, $task['column_id']);
|
$this->assertEquals(1, $task['column_id']);
|
||||||
$this->assertEquals(1, $task['position']);
|
$this->assertEquals(1, $task['position']);
|
||||||
@@ -306,6 +296,7 @@ class TaskTest extends Base
|
|||||||
public function testMoveTaskBottom()
|
public function testMoveTaskBottom()
|
||||||
{
|
{
|
||||||
$t = new Task($this->registry);
|
$t = new Task($this->registry);
|
||||||
|
$tf = new TaskFinder($this->registry);
|
||||||
$p = new Project($this->registry);
|
$p = new Project($this->registry);
|
||||||
|
|
||||||
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
||||||
@@ -318,22 +309,22 @@ class TaskTest extends Base
|
|||||||
$this->assertTrue($t->movePosition(1, 1, 1, 4));
|
$this->assertTrue($t->movePosition(1, 1, 1, 4));
|
||||||
|
|
||||||
// Check tasks position
|
// Check tasks position
|
||||||
$task = $t->getById(1);
|
$task = $tf->getById(1);
|
||||||
$this->assertEquals(1, $task['id']);
|
$this->assertEquals(1, $task['id']);
|
||||||
$this->assertEquals(1, $task['column_id']);
|
$this->assertEquals(1, $task['column_id']);
|
||||||
$this->assertEquals(4, $task['position']);
|
$this->assertEquals(4, $task['position']);
|
||||||
|
|
||||||
$task = $t->getById(2);
|
$task = $tf->getById(2);
|
||||||
$this->assertEquals(2, $task['id']);
|
$this->assertEquals(2, $task['id']);
|
||||||
$this->assertEquals(1, $task['column_id']);
|
$this->assertEquals(1, $task['column_id']);
|
||||||
$this->assertEquals(1, $task['position']);
|
$this->assertEquals(1, $task['position']);
|
||||||
|
|
||||||
$task = $t->getById(3);
|
$task = $tf->getById(3);
|
||||||
$this->assertEquals(3, $task['id']);
|
$this->assertEquals(3, $task['id']);
|
||||||
$this->assertEquals(1, $task['column_id']);
|
$this->assertEquals(1, $task['column_id']);
|
||||||
$this->assertEquals(2, $task['position']);
|
$this->assertEquals(2, $task['position']);
|
||||||
|
|
||||||
$task = $t->getById(4);
|
$task = $tf->getById(4);
|
||||||
$this->assertEquals(4, $task['id']);
|
$this->assertEquals(4, $task['id']);
|
||||||
$this->assertEquals(1, $task['column_id']);
|
$this->assertEquals(1, $task['column_id']);
|
||||||
$this->assertEquals(3, $task['position']);
|
$this->assertEquals(3, $task['position']);
|
||||||
@@ -342,6 +333,7 @@ class TaskTest extends Base
|
|||||||
public function testMovePosition()
|
public function testMovePosition()
|
||||||
{
|
{
|
||||||
$t = new Task($this->registry);
|
$t = new Task($this->registry);
|
||||||
|
$tf = new TaskFinder($this->registry);
|
||||||
$p = new Project($this->registry);
|
$p = new Project($this->registry);
|
||||||
|
|
||||||
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
||||||
@@ -361,7 +353,7 @@ class TaskTest extends Base
|
|||||||
|
|
||||||
$this->assertEquals($counter, $t->create($task));
|
$this->assertEquals($counter, $t->create($task));
|
||||||
|
|
||||||
$task = $t->getById($counter);
|
$task = $tf->getById($counter);
|
||||||
$this->assertNotFalse($task);
|
$this->assertNotFalse($task);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
$this->assertEquals($i, $task['position']);
|
$this->assertEquals($i, $task['position']);
|
||||||
@@ -372,68 +364,68 @@ class TaskTest extends Base
|
|||||||
$this->assertTrue($t->movePosition(1, 4, 2, 3));
|
$this->assertTrue($t->movePosition(1, 4, 2, 3));
|
||||||
|
|
||||||
// We check the new position of the task
|
// We check the new position of the task
|
||||||
$task = $t->getById(4);
|
$task = $tf->getById(4);
|
||||||
$this->assertEquals(4, $task['id']);
|
$this->assertEquals(4, $task['id']);
|
||||||
$this->assertEquals(2, $task['column_id']);
|
$this->assertEquals(2, $task['column_id']);
|
||||||
$this->assertEquals(3, $task['position']);
|
$this->assertEquals(3, $task['position']);
|
||||||
|
|
||||||
// The tasks before have the correct position
|
// The tasks before have the correct position
|
||||||
$task = $t->getById(3);
|
$task = $tf->getById(3);
|
||||||
$this->assertEquals(3, $task['id']);
|
$this->assertEquals(3, $task['id']);
|
||||||
$this->assertEquals(1, $task['column_id']);
|
$this->assertEquals(1, $task['column_id']);
|
||||||
$this->assertEquals(3, $task['position']);
|
$this->assertEquals(3, $task['position']);
|
||||||
|
|
||||||
$task = $t->getById(7);
|
$task = $tf->getById(7);
|
||||||
$this->assertEquals(7, $task['id']);
|
$this->assertEquals(7, $task['id']);
|
||||||
$this->assertEquals(2, $task['column_id']);
|
$this->assertEquals(2, $task['column_id']);
|
||||||
$this->assertEquals(2, $task['position']);
|
$this->assertEquals(2, $task['position']);
|
||||||
|
|
||||||
// The tasks after have the correct position
|
// The tasks after have the correct position
|
||||||
$task = $t->getById(5);
|
$task = $tf->getById(5);
|
||||||
$this->assertEquals(5, $task['id']);
|
$this->assertEquals(5, $task['id']);
|
||||||
$this->assertEquals(1, $task['column_id']);
|
$this->assertEquals(1, $task['column_id']);
|
||||||
$this->assertEquals(4, $task['position']);
|
$this->assertEquals(4, $task['position']);
|
||||||
|
|
||||||
$task = $t->getById(8);
|
$task = $tf->getById(8);
|
||||||
$this->assertEquals(8, $task['id']);
|
$this->assertEquals(8, $task['id']);
|
||||||
$this->assertEquals(2, $task['column_id']);
|
$this->assertEquals(2, $task['column_id']);
|
||||||
$this->assertEquals(4, $task['position']);
|
$this->assertEquals(4, $task['position']);
|
||||||
|
|
||||||
// The number of tasks per column
|
// The number of tasks per column
|
||||||
$this->assertEquals($task_per_column - 1, $t->countByColumnId(1, 1));
|
$this->assertEquals($task_per_column - 1, $tf->countByColumnId(1, 1));
|
||||||
$this->assertEquals($task_per_column + 1, $t->countByColumnId(1, 2));
|
$this->assertEquals($task_per_column + 1, $tf->countByColumnId(1, 2));
|
||||||
$this->assertEquals($task_per_column, $t->countByColumnId(1, 3));
|
$this->assertEquals($task_per_column, $tf->countByColumnId(1, 3));
|
||||||
$this->assertEquals($task_per_column, $t->countByColumnId(1, 4));
|
$this->assertEquals($task_per_column, $tf->countByColumnId(1, 4));
|
||||||
|
|
||||||
// We move task id #1, column 1, position 1 to the column 4, position 6 (last position)
|
// We move task id #1, column 1, position 1 to the column 4, position 6 (last position)
|
||||||
$this->assertTrue($t->movePosition(1, 1, 4, $task_per_column + 1));
|
$this->assertTrue($t->movePosition(1, 1, 4, $task_per_column + 1));
|
||||||
|
|
||||||
// We check the new position of the task
|
// We check the new position of the task
|
||||||
$task = $t->getById(1);
|
$task = $tf->getById(1);
|
||||||
$this->assertEquals(1, $task['id']);
|
$this->assertEquals(1, $task['id']);
|
||||||
$this->assertEquals(4, $task['column_id']);
|
$this->assertEquals(4, $task['column_id']);
|
||||||
$this->assertEquals($task_per_column + 1, $task['position']);
|
$this->assertEquals($task_per_column + 1, $task['position']);
|
||||||
|
|
||||||
// The tasks before have the correct position
|
// The tasks before have the correct position
|
||||||
$task = $t->getById(20);
|
$task = $tf->getById(20);
|
||||||
$this->assertEquals(20, $task['id']);
|
$this->assertEquals(20, $task['id']);
|
||||||
$this->assertEquals(4, $task['column_id']);
|
$this->assertEquals(4, $task['column_id']);
|
||||||
$this->assertEquals($task_per_column, $task['position']);
|
$this->assertEquals($task_per_column, $task['position']);
|
||||||
|
|
||||||
// The tasks after have the correct position
|
// The tasks after have the correct position
|
||||||
$task = $t->getById(2);
|
$task = $tf->getById(2);
|
||||||
$this->assertEquals(2, $task['id']);
|
$this->assertEquals(2, $task['id']);
|
||||||
$this->assertEquals(1, $task['column_id']);
|
$this->assertEquals(1, $task['column_id']);
|
||||||
$this->assertEquals(1, $task['position']);
|
$this->assertEquals(1, $task['position']);
|
||||||
|
|
||||||
// The number of tasks per column
|
// The number of tasks per column
|
||||||
$this->assertEquals($task_per_column - 2, $t->countByColumnId(1, 1));
|
$this->assertEquals($task_per_column - 2, $tf->countByColumnId(1, 1));
|
||||||
$this->assertEquals($task_per_column + 1, $t->countByColumnId(1, 2));
|
$this->assertEquals($task_per_column + 1, $tf->countByColumnId(1, 2));
|
||||||
$this->assertEquals($task_per_column, $t->countByColumnId(1, 3));
|
$this->assertEquals($task_per_column, $tf->countByColumnId(1, 3));
|
||||||
$this->assertEquals($task_per_column + 1, $t->countByColumnId(1, 4));
|
$this->assertEquals($task_per_column + 1, $tf->countByColumnId(1, 4));
|
||||||
|
|
||||||
// Our previous moved task should stay at the same place
|
// Our previous moved task should stay at the same place
|
||||||
$task = $t->getById(4);
|
$task = $tf->getById(4);
|
||||||
$this->assertEquals(4, $task['id']);
|
$this->assertEquals(4, $task['id']);
|
||||||
$this->assertEquals(2, $task['column_id']);
|
$this->assertEquals(2, $task['column_id']);
|
||||||
$this->assertEquals(3, $task['position']);
|
$this->assertEquals(3, $task['position']);
|
||||||
@@ -448,28 +440,28 @@ class TaskTest extends Base
|
|||||||
// Test position greater than the last position
|
// Test position greater than the last position
|
||||||
$this->assertTrue($t->movePosition(1, 11, 1, 22));
|
$this->assertTrue($t->movePosition(1, 11, 1, 22));
|
||||||
|
|
||||||
$task = $t->getById(11);
|
$task = $tf->getById(11);
|
||||||
$this->assertEquals(11, $task['id']);
|
$this->assertEquals(11, $task['id']);
|
||||||
$this->assertEquals(1, $task['column_id']);
|
$this->assertEquals(1, $task['column_id']);
|
||||||
$this->assertEquals($t->countByColumnId(1, 1), $task['position']);
|
$this->assertEquals($tf->countByColumnId(1, 1), $task['position']);
|
||||||
|
|
||||||
$task = $t->getById(5);
|
$task = $tf->getById(5);
|
||||||
$this->assertEquals(5, $task['id']);
|
$this->assertEquals(5, $task['id']);
|
||||||
$this->assertEquals(1, $task['column_id']);
|
$this->assertEquals(1, $task['column_id']);
|
||||||
$this->assertEquals($t->countByColumnId(1, 1) - 1, $task['position']);
|
$this->assertEquals($tf->countByColumnId(1, 1) - 1, $task['position']);
|
||||||
|
|
||||||
$task = $t->getById(4);
|
$task = $tf->getById(4);
|
||||||
$this->assertEquals(4, $task['id']);
|
$this->assertEquals(4, $task['id']);
|
||||||
$this->assertEquals(2, $task['column_id']);
|
$this->assertEquals(2, $task['column_id']);
|
||||||
$this->assertEquals(3, $task['position']);
|
$this->assertEquals(3, $task['position']);
|
||||||
|
|
||||||
$this->assertEquals($task_per_column - 1, $t->countByColumnId(1, 1));
|
$this->assertEquals($task_per_column - 1, $tf->countByColumnId(1, 1));
|
||||||
$this->assertEquals($task_per_column + 1, $t->countByColumnId(1, 2));
|
$this->assertEquals($task_per_column + 1, $tf->countByColumnId(1, 2));
|
||||||
$this->assertEquals($task_per_column - 1, $t->countByColumnId(1, 3));
|
$this->assertEquals($task_per_column - 1, $tf->countByColumnId(1, 3));
|
||||||
$this->assertEquals($task_per_column + 1, $t->countByColumnId(1, 4));
|
$this->assertEquals($task_per_column + 1, $tf->countByColumnId(1, 4));
|
||||||
|
|
||||||
// Our previous moved task should stay at the same place
|
// Our previous moved task should stay at the same place
|
||||||
$task = $t->getById(4);
|
$task = $tf->getById(4);
|
||||||
$this->assertEquals(4, $task['id']);
|
$this->assertEquals(4, $task['id']);
|
||||||
$this->assertEquals(2, $task['column_id']);
|
$this->assertEquals(2, $task['column_id']);
|
||||||
$this->assertEquals(3, $task['position']);
|
$this->assertEquals(3, $task['position']);
|
||||||
@@ -477,25 +469,26 @@ class TaskTest extends Base
|
|||||||
// Test moving task to position 1
|
// Test moving task to position 1
|
||||||
$this->assertTrue($t->movePosition(1, 14, 1, 1));
|
$this->assertTrue($t->movePosition(1, 14, 1, 1));
|
||||||
|
|
||||||
$task = $t->getById(14);
|
$task = $tf->getById(14);
|
||||||
$this->assertEquals(14, $task['id']);
|
$this->assertEquals(14, $task['id']);
|
||||||
$this->assertEquals(1, $task['column_id']);
|
$this->assertEquals(1, $task['column_id']);
|
||||||
$this->assertEquals(1, $task['position']);
|
$this->assertEquals(1, $task['position']);
|
||||||
|
|
||||||
$task = $t->getById(2);
|
$task = $tf->getById(2);
|
||||||
$this->assertEquals(2, $task['id']);
|
$this->assertEquals(2, $task['id']);
|
||||||
$this->assertEquals(1, $task['column_id']);
|
$this->assertEquals(1, $task['column_id']);
|
||||||
$this->assertEquals(2, $task['position']);
|
$this->assertEquals(2, $task['position']);
|
||||||
|
|
||||||
$this->assertEquals($task_per_column, $t->countByColumnId(1, 1));
|
$this->assertEquals($task_per_column, $tf->countByColumnId(1, 1));
|
||||||
$this->assertEquals($task_per_column + 1, $t->countByColumnId(1, 2));
|
$this->assertEquals($task_per_column + 1, $tf->countByColumnId(1, 2));
|
||||||
$this->assertEquals($task_per_column - 2, $t->countByColumnId(1, 3));
|
$this->assertEquals($task_per_column - 2, $tf->countByColumnId(1, 3));
|
||||||
$this->assertEquals($task_per_column + 1, $t->countByColumnId(1, 4));
|
$this->assertEquals($task_per_column + 1, $tf->countByColumnId(1, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDuplicateToTheSameProject()
|
public function testDuplicateToTheSameProject()
|
||||||
{
|
{
|
||||||
$t = new Task($this->registry);
|
$t = new Task($this->registry);
|
||||||
|
$tf = new TaskFinder($this->registry);
|
||||||
$p = new Project($this->registry);
|
$p = new Project($this->registry);
|
||||||
$c = new Category($this->registry);
|
$c = new Category($this->registry);
|
||||||
|
|
||||||
@@ -510,7 +503,7 @@ class TaskTest extends Base
|
|||||||
|
|
||||||
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1, 'category_id' => 2)));
|
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1, 'category_id' => 2)));
|
||||||
|
|
||||||
$task = $t->getById(1);
|
$task = $tf->getById(1);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
$this->assertEquals(1, $task['position']);
|
$this->assertEquals(1, $task['position']);
|
||||||
|
|
||||||
@@ -519,7 +512,7 @@ class TaskTest extends Base
|
|||||||
$this->assertTrue($this->registry->shared('event')->isEventTriggered(Task::EVENT_CREATE));
|
$this->assertTrue($this->registry->shared('event')->isEventTriggered(Task::EVENT_CREATE));
|
||||||
|
|
||||||
// Check the values of the duplicated task
|
// Check the values of the duplicated task
|
||||||
$task = $t->getById(2);
|
$task = $tf->getById(2);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
$this->assertEquals(Task::STATUS_OPEN, $task['is_active']);
|
$this->assertEquals(Task::STATUS_OPEN, $task['is_active']);
|
||||||
$this->assertEquals(1, $task['project_id']);
|
$this->assertEquals(1, $task['project_id']);
|
||||||
@@ -532,6 +525,7 @@ class TaskTest extends Base
|
|||||||
public function testDuplicateToAnotherProject()
|
public function testDuplicateToAnotherProject()
|
||||||
{
|
{
|
||||||
$t = new Task($this->registry);
|
$t = new Task($this->registry);
|
||||||
|
$tf = new TaskFinder($this->registry);
|
||||||
$p = new Project($this->registry);
|
$p = new Project($this->registry);
|
||||||
$c = new Category($this->registry);
|
$c = new Category($this->registry);
|
||||||
|
|
||||||
@@ -544,14 +538,14 @@ class TaskTest extends Base
|
|||||||
|
|
||||||
// We create a task
|
// We create a task
|
||||||
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 1, 'category_id' => 1)));
|
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 1, 'category_id' => 1)));
|
||||||
$task = $t->getById(1);
|
$task = $tf->getById(1);
|
||||||
|
|
||||||
// We duplicate our task to the 2nd project
|
// We duplicate our task to the 2nd project
|
||||||
$this->assertEquals(2, $t->duplicateToAnotherProject(2, $task));
|
$this->assertEquals(2, $t->duplicateToAnotherProject(2, $task));
|
||||||
$this->assertTrue($this->registry->shared('event')->isEventTriggered(Task::EVENT_CREATE));
|
$this->assertTrue($this->registry->shared('event')->isEventTriggered(Task::EVENT_CREATE));
|
||||||
|
|
||||||
// Check the values of the duplicated task
|
// Check the values of the duplicated task
|
||||||
$task = $t->getById(2);
|
$task = $tf->getById(2);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
$this->assertEquals(1, $task['owner_id']);
|
$this->assertEquals(1, $task['owner_id']);
|
||||||
$this->assertEquals(0, $task['category_id']);
|
$this->assertEquals(0, $task['category_id']);
|
||||||
@@ -564,6 +558,7 @@ class TaskTest extends Base
|
|||||||
public function testMoveToAnotherProject()
|
public function testMoveToAnotherProject()
|
||||||
{
|
{
|
||||||
$t = new Task($this->registry);
|
$t = new Task($this->registry);
|
||||||
|
$tf = new TaskFinder($this->registry);
|
||||||
$p = new Project($this->registry);
|
$p = new Project($this->registry);
|
||||||
$pp = new ProjectPermission($this->registry);
|
$pp = new ProjectPermission($this->registry);
|
||||||
$user = new User($this->registry);
|
$user = new User($this->registry);
|
||||||
@@ -581,12 +576,12 @@ class TaskTest extends Base
|
|||||||
$this->assertEquals(2, $t->create(array('title' => 'test2', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 3, 'category_id' => 10, 'position' => 333)));
|
$this->assertEquals(2, $t->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
|
// We duplicate our task to the 2nd project
|
||||||
$task = $t->getById(1);
|
$task = $tf->getById(1);
|
||||||
$this->assertEquals(1, $t->moveToAnotherProject(2, $task));
|
$this->assertEquals(1, $t->moveToAnotherProject(2, $task));
|
||||||
//$this->assertTrue($this->registry->shared('event')->isEventTriggered(Task::EVENT_CREATE));
|
//$this->assertTrue($this->registry->shared('event')->isEventTriggered(Task::EVENT_CREATE));
|
||||||
|
|
||||||
// Check the values of the duplicated task
|
// Check the values of the duplicated task
|
||||||
$task = $t->getById(1);
|
$task = $tf->getById(1);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
$this->assertEquals(1, $task['owner_id']);
|
$this->assertEquals(1, $task['owner_id']);
|
||||||
$this->assertEquals(0, $task['category_id']);
|
$this->assertEquals(0, $task['category_id']);
|
||||||
@@ -599,10 +594,10 @@ class TaskTest extends Base
|
|||||||
$this->assertTrue($pp->allowUser(2, 2));
|
$this->assertTrue($pp->allowUser(2, 2));
|
||||||
|
|
||||||
// The owner should be reseted
|
// The owner should be reseted
|
||||||
$task = $t->getById(2);
|
$task = $tf->getById(2);
|
||||||
$this->assertEquals(2, $t->moveToAnotherProject(2, $task));
|
$this->assertEquals(2, $t->moveToAnotherProject(2, $task));
|
||||||
|
|
||||||
$task = $t->getById(2);
|
$task = $tf->getById(2);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
$this->assertEquals(0, $task['owner_id']);
|
$this->assertEquals(0, $task['owner_id']);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ require_once __DIR__.'/Base.php';
|
|||||||
|
|
||||||
use Model\SubTask;
|
use Model\SubTask;
|
||||||
use Model\Task;
|
use Model\Task;
|
||||||
|
use Model\TaskFinder;
|
||||||
use Model\Project;
|
use Model\Project;
|
||||||
use Model\TimeTracking;
|
use Model\TimeTracking;
|
||||||
|
|
||||||
@@ -12,6 +13,7 @@ class TimeTrackingTest extends Base
|
|||||||
public function testCalculateTime()
|
public function testCalculateTime()
|
||||||
{
|
{
|
||||||
$t = new Task($this->registry);
|
$t = new Task($this->registry);
|
||||||
|
$tf = new TaskFinder($this->registry);
|
||||||
$p = new Project($this->registry);
|
$p = new Project($this->registry);
|
||||||
$s = new SubTask($this->registry);
|
$s = new SubTask($this->registry);
|
||||||
$ts = new TimeTracking($this->registry);
|
$ts = new TimeTracking($this->registry);
|
||||||
@@ -20,7 +22,7 @@ class TimeTrackingTest extends Base
|
|||||||
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'time_estimated' => 4.5)));
|
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'time_estimated' => 4.5)));
|
||||||
$this->assertTrue($t->update(array('id' => 1, 'time_spent' => 3.5)));
|
$this->assertTrue($t->update(array('id' => 1, 'time_spent' => 3.5)));
|
||||||
|
|
||||||
$task = $t->getById(1);
|
$task = $tf->getById(1);
|
||||||
$this->assertNotEmpty($task);
|
$this->assertNotEmpty($task);
|
||||||
$this->assertEquals(4.5, $task['time_estimated']);
|
$this->assertEquals(4.5, $task['time_estimated']);
|
||||||
$this->assertEquals(3.5, $task['time_spent']);
|
$this->assertEquals(3.5, $task['time_spent']);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ require_once __DIR__.'/Base.php';
|
|||||||
|
|
||||||
use Model\User;
|
use Model\User;
|
||||||
use Model\Task;
|
use Model\Task;
|
||||||
|
use Model\TaskFinder;
|
||||||
use Model\Project;
|
use Model\Project;
|
||||||
|
|
||||||
class UserTest extends Base
|
class UserTest extends Base
|
||||||
@@ -110,13 +111,14 @@ class UserTest extends Base
|
|||||||
{
|
{
|
||||||
$u = new User($this->registry);
|
$u = new User($this->registry);
|
||||||
$t = new Task($this->registry);
|
$t = new Task($this->registry);
|
||||||
|
$tf = new TaskFinder($this->registry);
|
||||||
$p = new Project($this->registry);
|
$p = new Project($this->registry);
|
||||||
|
|
||||||
$this->assertTrue($u->create(array('username' => 'toto', 'password' => '123456', 'name' => 'Toto')));
|
$this->assertTrue($u->create(array('username' => 'toto', 'password' => '123456', 'name' => 'Toto')));
|
||||||
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
||||||
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'owner_id' => 2)));
|
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'owner_id' => 2)));
|
||||||
|
|
||||||
$task = $t->getById(1);
|
$task = $tf->getById(1);
|
||||||
$this->assertEquals(1, $task['id']);
|
$this->assertEquals(1, $task['id']);
|
||||||
$this->assertEquals(2, $task['owner_id']);
|
$this->assertEquals(2, $task['owner_id']);
|
||||||
|
|
||||||
@@ -126,7 +128,7 @@ class UserTest extends Base
|
|||||||
$this->assertFalse($u->remove(55));
|
$this->assertFalse($u->remove(55));
|
||||||
|
|
||||||
// Make sure that assigned tasks are unassigned after removing the user
|
// Make sure that assigned tasks are unassigned after removing the user
|
||||||
$task = $t->getById(1);
|
$task = $tf->getById(1);
|
||||||
$this->assertEquals(1, $task['id']);
|
$this->assertEquals(1, $task['id']);
|
||||||
$this->assertEquals(0, $task['owner_id']);
|
$this->assertEquals(0, $task['owner_id']);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user