From c0ab45110688d698c1038d203017fda2385c5142 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Tue, 11 Mar 2014 21:12:53 -0400 Subject: Add unit test for the "task close" action --- tests/ActionTaskCloseTest.php | 62 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 tests/ActionTaskCloseTest.php (limited to 'tests/ActionTaskCloseTest.php') 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 @@ +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']); + } +} -- cgit v1.2.3