summaryrefslogtreecommitdiff
path: root/tests/ActionTaskCloseTest.php
diff options
context:
space:
mode:
authorFrédéric Guillot <fguillot@users.noreply.github.com>2014-03-11 21:12:53 -0400
committerFrédéric Guillot <fguillot@users.noreply.github.com>2014-03-11 21:12:53 -0400
commitc0ab45110688d698c1038d203017fda2385c5142 (patch)
tree57427ded9c096d3a558980b1b32de6e1b3242b62 /tests/ActionTaskCloseTest.php
parent66c7cf0caa5802c825e3f511158bb719cf82cafa (diff)
Add unit test for the "task close" action
Diffstat (limited to 'tests/ActionTaskCloseTest.php')
-rw-r--r--tests/ActionTaskCloseTest.php62
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/ActionTaskCloseTest.php b/tests/ActionTaskCloseTest.php
new file mode 100644
index 00000000..0d405739
--- /dev/null
+++ b/tests/ActionTaskCloseTest.php
@@ -0,0 +1,62 @@
+<?php
+
+require_once __DIR__.'/base.php';
+
+use Model\Task;
+
+class ActionTaskCloseTest extends Base
+{
+ public function testBadProject()
+ {
+ $action = new Action\TaskClose(3, new Task($this->db, $this->event));
+ $action->setParam('column_id', 5);
+
+ $event = array(
+ 'project_id' => 2,
+ 'task_id' => 3,
+ 'column_id' => 5,
+ );
+
+ $this->assertFalse($action->doAction($event));
+ }
+
+ public function testBadColumn()
+ {
+ $action = new Action\TaskClose(3, new Task($this->db, $this->event));
+ $action->setParam('column_id', 5);
+
+ $event = array(
+ 'project_id' => 3,
+ 'task_id' => 3,
+ 'column_id' => 3,
+ );
+
+ $this->assertFalse($action->doAction($event));
+ }
+
+ public function testExecute()
+ {
+ $action = new Action\TaskClose(1, new Task($this->db, $this->event));
+ $action->setParam('column_id', 2);
+
+ // We create a task in the first column
+ $task = new Task($this->db, $this->event);
+ $this->assertEquals(1, $p->create(array('name' => 'test')));
+ $this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));
+
+ // We create an event to move the task to the 2nd column
+ $event = array(
+ 'project_id' => 1,
+ 'task_id' => 1,
+ 'column_id' => 2,
+ );
+
+ // Our event should be executed
+ $this->assertTrue($action->doAction($event));
+
+ // Our task should be closed
+ $t = $task->getById(1);
+ $this->assertNotEmpty($t);
+ $this->assertEquals(0, $t['is_active']);
+ }
+}