summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-06-20 16:50:52 -0400
committerFrederic Guillot <fred@kanboard.net>2015-06-20 16:50:52 -0400
commitb6b733b22f9e9f38786166c1274b135a99bce02a (patch)
tree6a861a141cefd42ebd7571d2e9f3a649ed19e6c7 /tests
parenta409bf3ff496f9df496bc9eebe7200b9849bd2ee (diff)
Close all subtasks when a task is closed
Diffstat (limited to 'tests')
-rw-r--r--tests/units/SubtaskTest.php22
-rw-r--r--tests/units/TaskStatusTest.php24
2 files changed, 46 insertions, 0 deletions
diff --git a/tests/units/SubtaskTest.php b/tests/units/SubtaskTest.php
index 791f8089..2abd81d9 100644
--- a/tests/units/SubtaskTest.php
+++ b/tests/units/SubtaskTest.php
@@ -11,6 +11,28 @@ use Model\User;
class SubTaskTest extends Base
{
+ public function testCloseAll()
+ {
+ $tc = new TaskCreation($this->container);
+ $s = new Subtask($this->container);
+ $p = new Project($this->container);
+
+ $this->assertEquals(1, $p->create(array('name' => 'test1')));
+ $this->assertEquals(1, $tc->create(array('title' => 'test 1', 'project_id' => 1)));
+
+ $this->assertEquals(1, $s->create(array('title' => 'subtask #1', 'task_id' => 1)));
+ $this->assertEquals(2, $s->create(array('title' => 'subtask #2', 'task_id' => 1)));
+
+ $this->assertTrue($s->closeAll(1));
+
+ $subtasks = $s->getAll(1);
+ $this->assertNotEmpty($subtasks);
+
+ foreach ($subtasks as $subtask) {
+ $this->assertEquals(Subtask::STATUS_DONE, $subtask['status']);
+ }
+ }
+
public function testMoveUp()
{
$tc = new TaskCreation($this->container);
diff --git a/tests/units/TaskStatusTest.php b/tests/units/TaskStatusTest.php
index 5c59698b..c1f79142 100644
--- a/tests/units/TaskStatusTest.php
+++ b/tests/units/TaskStatusTest.php
@@ -2,6 +2,7 @@
require_once __DIR__.'/Base.php';
+use Model\Subtask;
use Model\Task;
use Model\TaskCreation;
use Model\TaskFinder;
@@ -74,4 +75,27 @@ class TaskStatusTest extends Base
$this->assertArrayHasKey('task_id', $event);
$this->assertNotEmpty($event['task_id']);
}
+
+ public function testThatAllSubtasksAreClosed()
+ {
+ $ts = new TaskStatus($this->container);
+ $tc = new TaskCreation($this->container);
+ $s = new Subtask($this->container);
+ $p = new Project($this->container);
+
+ $this->assertEquals(1, $p->create(array('name' => 'test1')));
+ $this->assertEquals(1, $tc->create(array('title' => 'test 1', 'project_id' => 1)));
+
+ $this->assertEquals(1, $s->create(array('title' => 'subtask #1', 'task_id' => 1)));
+ $this->assertEquals(2, $s->create(array('title' => 'subtask #2', 'task_id' => 1)));
+
+ $this->assertTrue($ts->close(1));
+
+ $subtasks = $s->getAll(1);
+ $this->assertNotEmpty($subtasks);
+
+ foreach ($subtasks as $subtask) {
+ $this->assertEquals(Subtask::STATUS_DONE, $subtask['status']);
+ }
+ }
}