summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/Console/TransitionExport.php2
-rw-r--r--app/Controller/Task.php4
-rw-r--r--app/Controller/Taskmodification.php6
-rw-r--r--app/Core/Base.php1
-rw-r--r--app/Core/DateParser.php5
-rw-r--r--app/Core/Http/Request.php7
-rw-r--r--app/Model/TaskExport.php3
-rw-r--r--app/Model/Transition.php86
-rw-r--r--app/Model/TransitionExport.php76
-rw-r--r--app/ServiceProvider/ClassProvider.php1
-rw-r--r--tests/units/Helper/AppHelperTest.php1
-rw-r--r--tests/units/Model/CategoryTest.php2
-rw-r--r--tests/units/Model/CommentTest.php1
-rw-r--r--tests/units/Model/ConfigTest.php1
-rw-r--r--tests/units/Model/NotificationTest.php1
-rw-r--r--tests/units/Model/ProjectActivityTest.php2
-rw-r--r--tests/units/Model/ProjectDailyColumnStatsTest.php1
-rw-r--r--tests/units/Model/ProjectDailyStatsTest.php1
-rw-r--r--tests/units/Model/SubtaskTest.php3
-rw-r--r--tests/units/Model/SubtaskTimeTrackingTest.php2
-rw-r--r--tests/units/Model/SwimlaneTest.php1
-rw-r--r--tests/units/Model/TaskCreationTest.php1
-rw-r--r--tests/units/Model/TaskDuplicationTest.php1
-rw-r--r--tests/units/Model/TaskExportTest.php2
-rw-r--r--tests/units/Model/TaskFileTest.php1
-rw-r--r--tests/units/Model/TaskFilterTest.php1
-rw-r--r--tests/units/Model/TaskFinderTest.php3
-rw-r--r--tests/units/Model/TaskLinkTest.php1
-rw-r--r--tests/units/Model/TaskModificationTest.php1
-rw-r--r--tests/units/Model/TaskPermissionTest.php2
-rw-r--r--tests/units/Model/TransitionExportTest.php45
-rw-r--r--tests/units/Model/TransitionTest.php141
-rw-r--r--tests/units/Model/UserNotificationTest.php3
-rw-r--r--tests/units/Model/UserTest.php1
-rw-r--r--tests/units/Model/UserUnreadNotificationTest.php2
35 files changed, 298 insertions, 114 deletions
diff --git a/app/Console/TransitionExport.php b/app/Console/TransitionExport.php
index 9ae41417..d9f805a4 100644
--- a/app/Console/TransitionExport.php
+++ b/app/Console/TransitionExport.php
@@ -21,7 +21,7 @@ class TransitionExport extends Base
protected function execute(InputInterface $input, OutputInterface $output)
{
- $data = $this->transition->export(
+ $data = $this->transitionExport->export(
$input->getArgument('project_id'),
$input->getArgument('start_date'),
$input->getArgument('end_date')
diff --git a/app/Controller/Task.php b/app/Controller/Task.php
index 539d377b..5f35be55 100644
--- a/app/Controller/Task.php
+++ b/app/Controller/Task.php
@@ -2,6 +2,8 @@
namespace Kanboard\Controller;
+use Kanboard\Core\DateParser;
+
/**
* Task controller
*
@@ -62,7 +64,7 @@ class Task extends Base
'time_spent' => $task['time_spent'] ?: '',
);
- $values = $this->dateParser->format($values, array('date_started'), $this->config->get('application_datetime_format', 'm/d/Y H:i'));
+ $values = $this->dateParser->format($values, array('date_started'), $this->config->get('application_datetime_format', DateParser::DATE_TIME_FORMAT));
$this->response->html($this->helper->layout->task('task/show', array(
'project' => $this->project->getById($task['project_id']),
diff --git a/app/Controller/Taskmodification.php b/app/Controller/Taskmodification.php
index 306d34c0..5fcb810c 100644
--- a/app/Controller/Taskmodification.php
+++ b/app/Controller/Taskmodification.php
@@ -2,6 +2,8 @@
namespace Kanboard\Controller;
+use Kanboard\Core\DateParser;
+
/**
* Task Modification controller
*
@@ -83,8 +85,8 @@ class Taskmodification extends Base
$values = $this->hook->merge('controller:task-modification:form:default', $values, array('default_values' => $values));
}
- $values = $this->dateParser->format($values, array('date_due'), $this->config->get('application_date_format', 'm/d/Y'));
- $values = $this->dateParser->format($values, array('date_started'), $this->config->get('application_datetime_format', 'm/d/Y H:i'));
+ $values = $this->dateParser->format($values, array('date_due'), $this->config->get('application_date_format', DateParser::DATE_FORMAT));
+ $values = $this->dateParser->format($values, array('date_started'), $this->config->get('application_datetime_format', DateParser::DATE_TIME_FORMAT));
$this->response->html($this->helper->layout->task('task_modification/edit_task', array(
'project' => $project,
diff --git a/app/Core/Base.php b/app/Core/Base.php
index f1053114..dce3e3dc 100644
--- a/app/Core/Base.php
+++ b/app/Core/Base.php
@@ -111,6 +111,7 @@ use Pimple\Container;
* @property \Kanboard\Model\TaskStatus $taskStatus
* @property \Kanboard\Model\TaskMetadata $taskMetadata
* @property \Kanboard\Model\Transition $transition
+ * @property \Kanboard\Model\TransitionExport $transitionExport
* @property \Kanboard\Model\User $user
* @property \Kanboard\Model\UserImport $userImport
* @property \Kanboard\Model\UserLocking $userLocking
diff --git a/app/Core/DateParser.php b/app/Core/DateParser.php
index 20e79ff9..835eb3e3 100644
--- a/app/Core/DateParser.php
+++ b/app/Core/DateParser.php
@@ -12,6 +12,9 @@ use DateTime;
*/
class DateParser extends Base
{
+ const DATE_FORMAT = 'm/d/Y';
+ const DATE_TIME_FORMAT = 'm/d/Y H:i';
+
/**
* List of time formats
*
@@ -201,7 +204,7 @@ class DateParser extends Base
}
/**
- * Get a timetstamp from an ISO date format
+ * Get a timestamp from an ISO date format
*
* @access public
* @param string $value
diff --git a/app/Core/Http/Request.php b/app/Core/Http/Request.php
index 7f1399e6..e0df2d3c 100644
--- a/app/Core/Http/Request.php
+++ b/app/Core/Http/Request.php
@@ -29,7 +29,12 @@ class Request extends Base
* Constructor
*
* @access public
- * @param \Pimple\Container $container
+ * @param \Pimple\Container $container
+ * @param array $server
+ * @param array $get
+ * @param array $post
+ * @param array $files
+ * @param array $cookies
*/
public function __construct(Container $container, array $server = array(), array $get = array(), array $post = array(), array $files = array(), array $cookies = array())
{
diff --git a/app/Model/TaskExport.php b/app/Model/TaskExport.php
index ed179a4f..64f5e77a 100644
--- a/app/Model/TaskExport.php
+++ b/app/Model/TaskExport.php
@@ -2,6 +2,7 @@
namespace Kanboard\Model;
+use Kanboard\Core\DateParser;
use PDO;
/**
@@ -106,7 +107,7 @@ class TaskExport extends Base
$task['score'] = $task['score'] ?: 0;
$task['swimlane_id'] = isset($swimlanes[$task['swimlane_id']]) ? $swimlanes[$task['swimlane_id']] : '?';
- $task = $this->dateParser->format($task, array('date_due', 'date_modification', 'date_creation', 'date_started', 'date_completed'), 'Y-m-d');
+ $task = $this->dateParser->format($task, array('date_due', 'date_modification', 'date_creation', 'date_started', 'date_completed'), DateParser::DATE_FORMAT);
return $task;
}
diff --git a/app/Model/Transition.php b/app/Model/Transition.php
index aa76d58f..870d95fd 100644
--- a/app/Model/Transition.php
+++ b/app/Model/Transition.php
@@ -3,7 +3,7 @@
namespace Kanboard\Model;
/**
- * Transition model
+ * Transition
*
* @package model
* @author Frederic Guillot
@@ -21,20 +21,22 @@ class Transition extends Base
* Save transition event
*
* @access public
- * @param integer $user_id
- * @param array $task
- * @return boolean
+ * @param integer $user_id
+ * @param array $task_event
+ * @return bool
*/
- public function save($user_id, array $task)
+ public function save($user_id, array $task_event)
{
+ $time = time();
+
return $this->db->table(self::TABLE)->insert(array(
'user_id' => $user_id,
- 'project_id' => $task['project_id'],
- 'task_id' => $task['task_id'],
- 'src_column_id' => $task['src_column_id'],
- 'dst_column_id' => $task['dst_column_id'],
- 'date' => time(),
- 'time_spent' => time() - $task['date_moved']
+ 'project_id' => $task_event['project_id'],
+ 'task_id' => $task_event['task_id'],
+ 'src_column_id' => $task_event['src_column_id'],
+ 'dst_column_id' => $task_event['dst_column_id'],
+ 'date' => $time,
+ 'time_spent' => $time - $task_event['date_moved']
));
}
@@ -116,71 +118,11 @@ class Transition extends Base
->lte('date', $to)
->eq(self::TABLE.'.project_id', $project_id)
->desc('date')
+ ->desc(self::TABLE.'.id')
->join(Task::TABLE, 'id', 'task_id')
->join(User::TABLE, 'id', 'user_id')
->join(Column::TABLE.' as src', 'id', 'src_column_id', self::TABLE, 'src')
->join(Column::TABLE.' as dst', 'id', 'dst_column_id', self::TABLE, 'dst')
->findAll();
}
-
- /**
- * Get project export
- *
- * @access public
- * @param integer $project_id Project id
- * @param mixed $from Start date (timestamp or user formatted date)
- * @param mixed $to End date (timestamp or user formatted date)
- * @return array
- */
- public function export($project_id, $from, $to)
- {
- $results = array($this->getColumns());
- $transitions = $this->getAllByProjectAndDate($project_id, $from, $to);
-
- foreach ($transitions as $transition) {
- $results[] = $this->format($transition);
- }
-
- return $results;
- }
-
- /**
- * Get column titles
- *
- * @access public
- * @return string[]
- */
- public function getColumns()
- {
- return array(
- e('Id'),
- e('Task Title'),
- e('Source column'),
- e('Destination column'),
- e('Executer'),
- e('Date'),
- e('Time spent'),
- );
- }
-
- /**
- * Format the output of a transition array
- *
- * @access public
- * @param array $transition
- * @return array
- */
- public function format(array $transition)
- {
- $values = array();
- $values[] = $transition['id'];
- $values[] = $transition['title'];
- $values[] = $transition['src_column'];
- $values[] = $transition['dst_column'];
- $values[] = $transition['name'] ?: $transition['username'];
- $values[] = date('Y-m-d H:i', $transition['date']);
- $values[] = round($transition['time_spent'] / 3600, 2);
-
- return $values;
- }
}
diff --git a/app/Model/TransitionExport.php b/app/Model/TransitionExport.php
new file mode 100644
index 00000000..33becb82
--- /dev/null
+++ b/app/Model/TransitionExport.php
@@ -0,0 +1,76 @@
+<?php
+
+namespace Kanboard\Model;
+
+use Kanboard\Core\DateParser;
+
+/**
+ * Transition Export
+ *
+ * @package model
+ * @author Frederic Guillot
+ */
+class TransitionExport extends Base
+{
+ /**
+ * Get project export
+ *
+ * @access public
+ * @param integer $project_id Project id
+ * @param mixed $from Start date (timestamp or user formatted date)
+ * @param mixed $to End date (timestamp or user formatted date)
+ * @return array
+ */
+ public function export($project_id, $from, $to)
+ {
+ $results = array($this->getColumns());
+ $transitions = $this->transition->getAllByProjectAndDate($project_id, $from, $to);
+
+ foreach ($transitions as $transition) {
+ $results[] = $this->format($transition);
+ }
+
+ return $results;
+ }
+
+ /**
+ * Get column titles
+ *
+ * @access protected
+ * @return string[]
+ */
+ protected function getColumns()
+ {
+ return array(
+ e('Id'),
+ e('Task Title'),
+ e('Source column'),
+ e('Destination column'),
+ e('Executer'),
+ e('Date'),
+ e('Time spent'),
+ );
+ }
+
+ /**
+ * Format the output of a transition array
+ *
+ * @access protected
+ * @param array $transition
+ * @return array
+ */
+ protected function format(array $transition)
+ {
+ $values = array(
+ (int) $transition['id'],
+ $transition['title'],
+ $transition['src_column'],
+ $transition['dst_column'],
+ $transition['name'] ?: $transition['username'],
+ date($this->config->get('application_datetime_format', DateParser::DATE_TIME_FORMAT), $transition['date']),
+ round($transition['time_spent'] / 3600, 2)
+ );
+
+ return $values;
+ }
+}
diff --git a/app/ServiceProvider/ClassProvider.php b/app/ServiceProvider/ClassProvider.php
index 0f2fbab5..4f022571 100644
--- a/app/ServiceProvider/ClassProvider.php
+++ b/app/ServiceProvider/ClassProvider.php
@@ -74,6 +74,7 @@ class ClassProvider implements ServiceProviderInterface
'TaskImport',
'TaskMetadata',
'Transition',
+ 'TransitionExport',
'User',
'UserImport',
'UserLocking',
diff --git a/tests/units/Helper/AppHelperTest.php b/tests/units/Helper/AppHelperTest.php
index 0639b7aa..4fd486f0 100644
--- a/tests/units/Helper/AppHelperTest.php
+++ b/tests/units/Helper/AppHelperTest.php
@@ -4,7 +4,6 @@ require_once __DIR__.'/../Base.php';
use Kanboard\Core\Session\FlashMessage;
use Kanboard\Helper\App;
-use Kanboard\Model\Config;
class AppHelperTest extends Base
{
diff --git a/tests/units/Model/CategoryTest.php b/tests/units/Model/CategoryTest.php
index 85d9eaae..3a64e26c 100644
--- a/tests/units/Model/CategoryTest.php
+++ b/tests/units/Model/CategoryTest.php
@@ -2,12 +2,10 @@
require_once __DIR__.'/../Base.php';
-use Kanboard\Model\Task;
use Kanboard\Model\TaskCreation;
use Kanboard\Model\TaskFinder;
use Kanboard\Model\Project;
use Kanboard\Model\Category;
-use Kanboard\Model\User;
class CategoryTest extends Base
{
diff --git a/tests/units/Model/CommentTest.php b/tests/units/Model/CommentTest.php
index ec4e7a56..bb96e4f4 100644
--- a/tests/units/Model/CommentTest.php
+++ b/tests/units/Model/CommentTest.php
@@ -2,7 +2,6 @@
require_once __DIR__.'/../Base.php';
-use Kanboard\Model\Task;
use Kanboard\Model\TaskCreation;
use Kanboard\Model\Project;
use Kanboard\Model\Comment;
diff --git a/tests/units/Model/ConfigTest.php b/tests/units/Model/ConfigTest.php
index 447c9238..6ccdbef9 100644
--- a/tests/units/Model/ConfigTest.php
+++ b/tests/units/Model/ConfigTest.php
@@ -3,7 +3,6 @@
require_once __DIR__.'/../Base.php';
use Kanboard\Model\Config;
-use Kanboard\Core\Session\SessionManager;
class ConfigTest extends Base
{
diff --git a/tests/units/Model/NotificationTest.php b/tests/units/Model/NotificationTest.php
index 03ee5867..d5ec7735 100644
--- a/tests/units/Model/NotificationTest.php
+++ b/tests/units/Model/NotificationTest.php
@@ -6,7 +6,6 @@ use Kanboard\Model\TaskFinder;
use Kanboard\Model\TaskCreation;
use Kanboard\Model\Subtask;
use Kanboard\Model\Comment;
-use Kanboard\Model\User;
use Kanboard\Model\TaskFile;
use Kanboard\Model\Task;
use Kanboard\Model\Project;
diff --git a/tests/units/Model/ProjectActivityTest.php b/tests/units/Model/ProjectActivityTest.php
index 04d3004d..27ea039d 100644
--- a/tests/units/Model/ProjectActivityTest.php
+++ b/tests/units/Model/ProjectActivityTest.php
@@ -7,8 +7,6 @@ use Kanboard\Model\TaskFinder;
use Kanboard\Model\TaskCreation;
use Kanboard\Model\ProjectActivity;
use Kanboard\Model\Project;
-use Kanboard\Model\Subtask;
-use Kanboard\Model\Comment;
class ProjectActivityTest extends Base
{
diff --git a/tests/units/Model/ProjectDailyColumnStatsTest.php b/tests/units/Model/ProjectDailyColumnStatsTest.php
index 5e8ec3e8..1a0e826c 100644
--- a/tests/units/Model/ProjectDailyColumnStatsTest.php
+++ b/tests/units/Model/ProjectDailyColumnStatsTest.php
@@ -7,7 +7,6 @@ use Kanboard\Model\ProjectDailyColumnStats;
use Kanboard\Model\Config;
use Kanboard\Model\Task;
use Kanboard\Model\TaskCreation;
-use Kanboard\Model\TaskStatus;
class ProjectDailyColumnStatsTest extends Base
{
diff --git a/tests/units/Model/ProjectDailyStatsTest.php b/tests/units/Model/ProjectDailyStatsTest.php
index 9efdb199..573878c2 100644
--- a/tests/units/Model/ProjectDailyStatsTest.php
+++ b/tests/units/Model/ProjectDailyStatsTest.php
@@ -4,7 +4,6 @@ require_once __DIR__.'/../Base.php';
use Kanboard\Model\Project;
use Kanboard\Model\ProjectDailyStats;
-use Kanboard\Model\Task;
use Kanboard\Model\TaskCreation;
use Kanboard\Model\TaskStatus;
diff --git a/tests/units/Model/SubtaskTest.php b/tests/units/Model/SubtaskTest.php
index 78945fd1..eb9747d4 100644
--- a/tests/units/Model/SubtaskTest.php
+++ b/tests/units/Model/SubtaskTest.php
@@ -2,12 +2,9 @@
require_once __DIR__.'/../Base.php';
-use Kanboard\Model\Task;
use Kanboard\Model\TaskCreation;
use Kanboard\Model\Subtask;
use Kanboard\Model\Project;
-use Kanboard\Model\Category;
-use Kanboard\Model\User;
use Kanboard\Core\User\UserSession;
class SubtaskTest extends Base
diff --git a/tests/units/Model/SubtaskTimeTrackingTest.php b/tests/units/Model/SubtaskTimeTrackingTest.php
index 40461eea..9fa8d5b0 100644
--- a/tests/units/Model/SubtaskTimeTrackingTest.php
+++ b/tests/units/Model/SubtaskTimeTrackingTest.php
@@ -7,8 +7,6 @@ use Kanboard\Model\TaskCreation;
use Kanboard\Model\Subtask;
use Kanboard\Model\SubtaskTimeTracking;
use Kanboard\Model\Project;
-use Kanboard\Model\Category;
-use Kanboard\Model\User;
class SubtaskTimeTrackingTest extends Base
{
diff --git a/tests/units/Model/SwimlaneTest.php b/tests/units/Model/SwimlaneTest.php
index f8b496cf..71c13e40 100644
--- a/tests/units/Model/SwimlaneTest.php
+++ b/tests/units/Model/SwimlaneTest.php
@@ -3,7 +3,6 @@
require_once __DIR__.'/../Base.php';
use Kanboard\Model\Project;
-use Kanboard\Model\Task;
use Kanboard\Model\TaskCreation;
use Kanboard\Model\TaskFinder;
use Kanboard\Model\Swimlane;
diff --git a/tests/units/Model/TaskCreationTest.php b/tests/units/Model/TaskCreationTest.php
index 781a7147..04d23930 100644
--- a/tests/units/Model/TaskCreationTest.php
+++ b/tests/units/Model/TaskCreationTest.php
@@ -6,7 +6,6 @@ use Kanboard\Model\Config;
use Kanboard\Model\Task;
use Kanboard\Model\TaskCreation;
use Kanboard\Model\TaskFinder;
-use Kanboard\Model\TaskStatus;
use Kanboard\Model\Project;
class TaskCreationTest extends Base
diff --git a/tests/units/Model/TaskDuplicationTest.php b/tests/units/Model/TaskDuplicationTest.php
index 8649c6b0..5ceb357e 100644
--- a/tests/units/Model/TaskDuplicationTest.php
+++ b/tests/units/Model/TaskDuplicationTest.php
@@ -7,7 +7,6 @@ use Kanboard\Model\Task;
use Kanboard\Model\TaskCreation;
use Kanboard\Model\TaskDuplication;
use Kanboard\Model\TaskFinder;
-use Kanboard\Model\TaskStatus;
use Kanboard\Model\Project;
use Kanboard\Model\ProjectUserRole;
use Kanboard\Model\Category;
diff --git a/tests/units/Model/TaskExportTest.php b/tests/units/Model/TaskExportTest.php
index b40b0771..559d53ef 100644
--- a/tests/units/Model/TaskExportTest.php
+++ b/tests/units/Model/TaskExportTest.php
@@ -2,12 +2,10 @@
require_once __DIR__.'/../Base.php';
-use Kanboard\Model\Task;
use Kanboard\Model\TaskCreation;
use Kanboard\Model\TaskExport;
use Kanboard\Model\Project;
use Kanboard\Model\Category;
-use Kanboard\Model\User;
use Kanboard\Model\Swimlane;
class TaskExportTest extends Base
diff --git a/tests/units/Model/TaskFileTest.php b/tests/units/Model/TaskFileTest.php
index b7db96a9..b900e8f3 100644
--- a/tests/units/Model/TaskFileTest.php
+++ b/tests/units/Model/TaskFileTest.php
@@ -2,7 +2,6 @@
require_once __DIR__.'/../Base.php';
-use Kanboard\Model\Task;
use Kanboard\Model\TaskFile;
use Kanboard\Model\TaskCreation;
use Kanboard\Model\Project;
diff --git a/tests/units/Model/TaskFilterTest.php b/tests/units/Model/TaskFilterTest.php
index daa193b2..9e291c31 100644
--- a/tests/units/Model/TaskFilterTest.php
+++ b/tests/units/Model/TaskFilterTest.php
@@ -10,7 +10,6 @@ use Kanboard\Model\TaskLink;
use Kanboard\Core\DateParser;
use Kanboard\Model\Category;
use Kanboard\Model\Subtask;
-use Kanboard\Model\Config;
use Kanboard\Model\Swimlane;
class TaskFilterTest extends Base
diff --git a/tests/units/Model/TaskFinderTest.php b/tests/units/Model/TaskFinderTest.php
index b21a4ea3..0ed211ed 100644
--- a/tests/units/Model/TaskFinderTest.php
+++ b/tests/units/Model/TaskFinderTest.php
@@ -2,12 +2,9 @@
require_once __DIR__.'/../Base.php';
-use Kanboard\Model\Task;
use Kanboard\Model\TaskCreation;
use Kanboard\Model\TaskFinder;
use Kanboard\Model\Project;
-use Kanboard\Model\Category;
-use Kanboard\Model\User;
class TaskFinderTest extends Base
{
diff --git a/tests/units/Model/TaskLinkTest.php b/tests/units/Model/TaskLinkTest.php
index 192a4298..8dd71830 100644
--- a/tests/units/Model/TaskLinkTest.php
+++ b/tests/units/Model/TaskLinkTest.php
@@ -2,7 +2,6 @@
require_once __DIR__.'/../Base.php';
-use Kanboard\Model\Link;
use Kanboard\Model\TaskFinder;
use Kanboard\Model\TaskLink;
use Kanboard\Model\TaskCreation;
diff --git a/tests/units/Model/TaskModificationTest.php b/tests/units/Model/TaskModificationTest.php
index 119201f0..315125d5 100644
--- a/tests/units/Model/TaskModificationTest.php
+++ b/tests/units/Model/TaskModificationTest.php
@@ -6,7 +6,6 @@ use Kanboard\Model\Task;
use Kanboard\Model\TaskCreation;
use Kanboard\Model\TaskModification;
use Kanboard\Model\TaskFinder;
-use Kanboard\Model\TaskStatus;
use Kanboard\Model\Project;
class TaskModificationTest extends Base
diff --git a/tests/units/Model/TaskPermissionTest.php b/tests/units/Model/TaskPermissionTest.php
index 0b093bbb..82cd581e 100644
--- a/tests/units/Model/TaskPermissionTest.php
+++ b/tests/units/Model/TaskPermissionTest.php
@@ -2,12 +2,10 @@
require_once __DIR__.'/../Base.php';
-use Kanboard\Model\Task;
use Kanboard\Model\TaskCreation;
use Kanboard\Model\TaskFinder;
use Kanboard\Model\TaskPermission;
use Kanboard\Model\Project;
-use Kanboard\Model\Category;
use Kanboard\Model\User;
use Kanboard\Core\User\UserSession;
diff --git a/tests/units/Model/TransitionExportTest.php b/tests/units/Model/TransitionExportTest.php
new file mode 100644
index 00000000..98b4356d
--- /dev/null
+++ b/tests/units/Model/TransitionExportTest.php
@@ -0,0 +1,45 @@
+<?php
+
+require_once __DIR__.'/../Base.php';
+
+use Kanboard\Model\TaskCreation;
+use Kanboard\Model\Transition;
+use Kanboard\Model\TransitionExport;
+use Kanboard\Model\Project;
+
+class TransitionExportTest extends Base
+{
+ public function testExport()
+ {
+ $projectModel = new Project($this->container);
+ $taskCreationModel = new TaskCreation($this->container);
+ $transitionModel = new Transition($this->container);
+ $transitionExportModel = new TransitionExport($this->container);
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'test')));
+ $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));
+
+ $task_event = array(
+ 'project_id' => 1,
+ 'task_id' => 1,
+ 'src_column_id' => 1,
+ 'dst_column_id' => 2,
+ 'date_moved' => time() - 3600
+ );
+
+ $this->assertTrue($transitionModel->save(1, $task_event));
+
+ $export = $transitionExportModel->export(1, date('Y-m-d'), date('Y-m-d'));
+ $this->assertCount(2, $export);
+
+ $this->assertEquals(
+ array('Id', 'Task Title', 'Source column', 'Destination column', 'Executer', 'Date', 'Time spent'),
+ $export[0]
+ );
+
+ $this->assertEquals(
+ array(1, 'test', 'Backlog', 'Ready', 'admin', date('m/d/Y H:i', time()), 1.0),
+ $export[1]
+ );
+ }
+}
diff --git a/tests/units/Model/TransitionTest.php b/tests/units/Model/TransitionTest.php
new file mode 100644
index 00000000..0c262e78
--- /dev/null
+++ b/tests/units/Model/TransitionTest.php
@@ -0,0 +1,141 @@
+<?php
+
+require_once __DIR__.'/../Base.php';
+
+use Kanboard\Model\TaskCreation;
+use Kanboard\Model\Transition;
+use Kanboard\Model\Project;
+
+class TransitionTest extends Base
+{
+ public function testSave()
+ {
+ $projectModel = new Project($this->container);
+ $taskCreationModel = new TaskCreation($this->container);
+ $transitionModel = new Transition($this->container);
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'test')));
+ $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));
+
+ $task_event = array(
+ 'project_id' => 1,
+ 'task_id' => 1,
+ 'src_column_id' => 1,
+ 'dst_column_id' => 2,
+ 'date_moved' => time() - 3600
+ );
+
+ $this->assertTrue($transitionModel->save(1, $task_event));
+
+ $transitions = $transitionModel->getAllByTask(1);
+ $this->assertCount(1, $transitions);
+ $this->assertEquals('Backlog', $transitions[0]['src_column']);
+ $this->assertEquals('Ready', $transitions[0]['dst_column']);
+ $this->assertEquals('', $transitions[0]['name']);
+ $this->assertEquals('admin', $transitions[0]['username']);
+ $this->assertEquals(1, $transitions[0]['user_id']);
+ $this->assertEquals(time(), $transitions[0]['date'], '', 3);
+ $this->assertEquals(3600, $transitions[0]['time_spent']);
+ }
+
+ public function testGetTimeSpentByTask()
+ {
+ $projectModel = new Project($this->container);
+ $taskCreationModel = new TaskCreation($this->container);
+ $transitionModel = new Transition($this->container);
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'test')));
+ $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));
+
+ $task_event = array(
+ 'project_id' => 1,
+ 'task_id' => 1,
+ 'src_column_id' => 1,
+ 'dst_column_id' => 2,
+ 'date_moved' => time() - 3600
+ );
+
+ $this->assertTrue($transitionModel->save(1, $task_event));
+
+ $task_event = array(
+ 'project_id' => 1,
+ 'task_id' => 1,
+ 'src_column_id' => 2,
+ 'dst_column_id' => 3,
+ 'date_moved' => time() - 1200
+ );
+
+ $this->assertTrue($transitionModel->save(1, $task_event));
+
+ $expected = array(
+ '1' => 3600,
+ '2' => 1200,
+ );
+
+ $this->assertEquals($expected, $transitionModel->getTimeSpentByTask(1));
+ }
+
+ public function testGetAllByProject()
+ {
+ $projectModel = new Project($this->container);
+ $taskCreationModel = new TaskCreation($this->container);
+ $transitionModel = new Transition($this->container);
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'test')));
+ $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test1')));
+ $this->assertEquals(2, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test2')));
+
+ $task_event = array(
+ 'project_id' => 1,
+ 'src_column_id' => 1,
+ 'dst_column_id' => 2,
+ 'date_moved' => time() - 3600
+ );
+
+ $this->assertTrue($transitionModel->save(1, array('task_id' => 1) + $task_event));
+ $this->assertTrue($transitionModel->save(1, array('task_id' => 2) + $task_event));
+
+ $task_event = array(
+ 'project_id' => 1,
+ 'src_column_id' => 2,
+ 'dst_column_id' => 3,
+ 'date_moved' => time() - 1200
+ );
+
+ $this->assertTrue($transitionModel->save(1, array('task_id' => 1) + $task_event));
+ $this->assertTrue($transitionModel->save(1, array('task_id' => 2) + $task_event));
+
+ $transitions = $transitionModel->getAllByProjectAndDate(1, date('Y-m-d'), date('Y-m-d'));
+ $this->assertCount(4, $transitions);
+
+ $this->assertEquals(2, $transitions[0]['id']);
+ $this->assertEquals(1, $transitions[1]['id']);
+ $this->assertEquals(2, $transitions[2]['id']);
+ $this->assertEquals(1, $transitions[3]['id']);
+
+ $this->assertEquals('test2', $transitions[0]['title']);
+ $this->assertEquals('test1', $transitions[1]['title']);
+ $this->assertEquals('test2', $transitions[2]['title']);
+ $this->assertEquals('test1', $transitions[3]['title']);
+
+ $this->assertEquals('Ready', $transitions[0]['src_column']);
+ $this->assertEquals('Ready', $transitions[1]['src_column']);
+ $this->assertEquals('Backlog', $transitions[2]['src_column']);
+ $this->assertEquals('Backlog', $transitions[3]['src_column']);
+
+ $this->assertEquals('Work in progress', $transitions[0]['dst_column']);
+ $this->assertEquals('Work in progress', $transitions[1]['dst_column']);
+ $this->assertEquals('Ready', $transitions[2]['dst_column']);
+ $this->assertEquals('Ready', $transitions[3]['dst_column']);
+
+ $this->assertEquals('admin', $transitions[0]['username']);
+ $this->assertEquals('admin', $transitions[1]['username']);
+ $this->assertEquals('admin', $transitions[2]['username']);
+ $this->assertEquals('admin', $transitions[3]['username']);
+
+ $this->assertEquals(1200, $transitions[0]['time_spent']);
+ $this->assertEquals(1200, $transitions[1]['time_spent']);
+ $this->assertEquals(3600, $transitions[2]['time_spent']);
+ $this->assertEquals(3600, $transitions[3]['time_spent']);
+ }
+}
diff --git a/tests/units/Model/UserNotificationTest.php b/tests/units/Model/UserNotificationTest.php
index e1928661..53034e20 100644
--- a/tests/units/Model/UserNotificationTest.php
+++ b/tests/units/Model/UserNotificationTest.php
@@ -4,8 +4,6 @@ require_once __DIR__.'/../Base.php';
use Kanboard\Model\TaskFinder;
use Kanboard\Model\TaskCreation;
-use Kanboard\Model\Subtask;
-use Kanboard\Model\Comment;
use Kanboard\Model\User;
use Kanboard\Model\Group;
use Kanboard\Model\GroupMember;
@@ -16,7 +14,6 @@ use Kanboard\Model\ProjectUserRole;
use Kanboard\Model\ProjectGroupRole;
use Kanboard\Model\UserNotification;
use Kanboard\Model\UserNotificationFilter;
-use Kanboard\Model\UserNotificationType;
use Kanboard\Subscriber\UserNotificationSubscriber;
use Kanboard\Core\Security\Role;
diff --git a/tests/units/Model/UserTest.php b/tests/units/Model/UserTest.php
index e411da0c..7501f2e0 100644
--- a/tests/units/Model/UserTest.php
+++ b/tests/units/Model/UserTest.php
@@ -5,7 +5,6 @@ require_once __DIR__.'/../Base.php';
use Kanboard\Model\User;
use Kanboard\Model\Subtask;
use Kanboard\Model\Comment;
-use Kanboard\Model\Task;
use Kanboard\Model\TaskCreation;
use Kanboard\Model\TaskFinder;
use Kanboard\Model\Project;
diff --git a/tests/units/Model/UserUnreadNotificationTest.php b/tests/units/Model/UserUnreadNotificationTest.php
index 62889bf0..918ab411 100644
--- a/tests/units/Model/UserUnreadNotificationTest.php
+++ b/tests/units/Model/UserUnreadNotificationTest.php
@@ -4,8 +4,6 @@ require_once __DIR__.'/../Base.php';
use Kanboard\Model\TaskFinder;
use Kanboard\Model\TaskCreation;
-use Kanboard\Model\Subtask;
-use Kanboard\Model\Comment;
use Kanboard\Model\User;
use Kanboard\Model\Task;
use Kanboard\Model\Project;