summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/Model/Task.php4
-rw-r--r--app/Templates/notification_task_due.php8
-rwxr-xr-xkanboard2
-rw-r--r--tests/units/TaskTest.php20
4 files changed, 30 insertions, 4 deletions
diff --git a/app/Model/Task.php b/app/Model/Task.php
index ddeb8a2b..84310d3c 100644
--- a/app/Model/Task.php
+++ b/app/Model/Task.php
@@ -69,7 +69,7 @@ class Task extends Base
* @access public
* @return array
*/
- public function getTasksDue()
+ public function getOverdueTasks()
{
$tasks = $this->db->table(self::TABLE)
->columns(
@@ -85,7 +85,7 @@ class Task extends Base
->join(User::TABLE, 'id', 'owner_id')
->eq(Project::TABLE.'.is_active', 1)
->eq(self::TABLE.'.is_active', 1)
- ->neq(self::TABLE.'.date_due', '')
+ ->neq(self::TABLE.'.date_due', 0)
->lte(self::TABLE.'.date_due', mktime(23, 59, 59))
->findAll();
diff --git a/app/Templates/notification_task_due.php b/app/Templates/notification_task_due.php
index 3a7089cf..25ecc9f1 100644
--- a/app/Templates/notification_task_due.php
+++ b/app/Templates/notification_task_due.php
@@ -2,7 +2,13 @@
<ul>
<?php foreach ($tasks as $task): ?>
- <li>(<strong>#<?= $task['id'] ?></strong>) <?= Helper\escape($task['title']) ?> (<strong><?= t('Assigned to %s', $task['assignee_name'] ?: $task['assignee_username']) ?></strong>)</li>
+ <li>
+ (<strong>#<?= $task['id'] ?></strong>)
+ <?= Helper\escape($task['title']) ?>
+ <?php if ($task['assignee_username']): ?>
+ (<strong><?= t('Assigned to %s', $task['assignee_name'] ?: $task['assignee_username']) ?></strong>)
+ <?php endif ?>
+ </li>
<?php endforeach ?>
</ul>
diff --git a/kanboard b/kanboard
index 6dc5f7e8..2c3ee7a9 100755
--- a/kanboard
+++ b/kanboard
@@ -53,7 +53,7 @@ $cli->register('send-notifications-due-tasks', function() use ($cli, $registry)
$notificationModel = new Notification($registry);
$taskModel = new Task($registry);
- $tasks = $taskModel->getTasksDue();
+ $tasks = $taskModel->getOverdueTasks();
// Group tasks by project
$projects = array();
diff --git a/tests/units/TaskTest.php b/tests/units/TaskTest.php
index 98553428..ad9f4cb8 100644
--- a/tests/units/TaskTest.php
+++ b/tests/units/TaskTest.php
@@ -24,6 +24,7 @@ class TaskTest extends Base
$this->assertEquals('yellow', $task['color_id']);
$this->assertEquals(time(), $task['date_creation']);
$this->assertEquals(time(), $task['date_modification']);
+ $this->assertEquals(0, $task['date_due']);
$this->assertEquals(2, $t->create(array('title' => 'Task #2', 'project_id' => 1)));
@@ -33,6 +34,7 @@ class TaskTest extends Base
$this->assertEquals(2, $task['position']);
$this->assertEquals(time(), $task['date_creation']);
$this->assertEquals(time(), $task['date_modification']);
+ $this->assertEquals(0, $task['date_due']);
$tasks = $t->getAll(1, 1);
$this->assertNotEmpty($tasks);
@@ -56,6 +58,24 @@ class TaskTest extends Base
$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()
{
$t = new Task($this->registry);