diff options
author | Frédéric Guillot <fred@kanboard.net> | 2014-05-25 18:12:27 -0400 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2014-05-25 18:12:27 -0400 |
commit | b6c4c93fe7a8a86f9c2aca6a388cb897c6a968c5 (patch) | |
tree | fec5334559925259b86f96efc5a84e57c10a5a4a /tests/ActionTest.php | |
parent | 60a45dbb685eb3b810dcced4820afe9d1f1ffe2d (diff) |
Add more tests
Diffstat (limited to 'tests/ActionTest.php')
-rw-r--r-- | tests/ActionTest.php | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/tests/ActionTest.php b/tests/ActionTest.php index 2757a069..391f0e25 100644 --- a/tests/ActionTest.php +++ b/tests/ActionTest.php @@ -6,6 +6,7 @@ use Model\Action; use Model\Project; use Model\Board; use Model\Task; +use Model\Category; class ActionTest extends Base { @@ -45,7 +46,7 @@ class ActionTest extends Base $this->assertEquals(4, $actions[0]['params'][0]['value']); } - public function testExecuteAction() + public function testEventMoveColumn() { $task = new Task($this->db, $this->event); $board = new Board($this->db, $this->event); @@ -91,6 +92,56 @@ class ActionTest extends Base $this->assertEquals(0, $t1['is_active']); } + public function testEventMovePosition() + { + $task = new Task($this->db, $this->event); + $board = new Board($this->db, $this->event); + $project = new Project($this->db, $this->event); + $action = new Action($this->db, $this->event); + + // We create a project + $this->assertEquals(1, $project->create(array('name' => 'unit_test'))); + + // We create a task + $this->assertEquals(1, $task->create(array( + 'title' => 'unit_test', + 'project_id' => 1, + 'owner_id' => 1, + 'color_id' => 'red', + 'column_id' => 1, + ))); + + // We create a new action, when the category_id=2 then the color_id should be green + $this->assertTrue($action->create(array( + 'project_id' => 1, + 'event_name' => Task::EVENT_MOVE_POSITION, + 'action_name' => 'TaskClose', + 'params' => array( + 'column_id' => 1, + 'color_id' => 'green', + ) + ))); + + // We bind events + $action->attachEvents(); + + $this->assertTrue($this->event->hasListener(Task::EVENT_MOVE_POSITION, 'Action\TaskClose')); + + // Our task should have the color red and position=0 + $t1 = $task->getById(1); + $this->assertEquals(0, $t1['position']); + $this->assertEquals(1, $t1['is_active']); + + // We move our task + $task->move(1, 1, 2); + $this->assertEquals(Task::EVENT_CLOSE, $this->event->getLastTriggeredEvent()); + + // Our task should be green and have the position 2 + $t1 = $task->getById(1); + $this->assertEquals(2, $t1['position']); + $this->assertEquals(0, $t1['is_active']); + } + public function testExecuteMultipleActions() { $task = new Task($this->db, $this->event); @@ -161,4 +212,6 @@ class ActionTest extends Base $this->assertEquals(2, $t2['project_id']); $this->assertEquals('unit_test', $t2['title']); } + + } |