diff options
author | Frédéric Guillot <fred@kanboard.net> | 2014-09-28 14:26:40 -0400 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2014-09-28 14:26:40 -0400 |
commit | 03fa01ac7b036820ee232d893ec63241918c6012 (patch) | |
tree | 295e82e6552ffb044554a11afa95318a4e180f87 /tests/units/ActionTaskCloseTest.php | |
parent | 0c8de6a3f58cde2696ac276b3456f3577d312e2b (diff) |
Improve automatic actions (check for compatible events/actions/parameters)
Diffstat (limited to 'tests/units/ActionTaskCloseTest.php')
-rw-r--r-- | tests/units/ActionTaskCloseTest.php | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/tests/units/ActionTaskCloseTest.php b/tests/units/ActionTaskCloseTest.php index a3a1eecc..73ff57f3 100644 --- a/tests/units/ActionTaskCloseTest.php +++ b/tests/units/ActionTaskCloseTest.php @@ -4,12 +4,51 @@ require_once __DIR__.'/Base.php'; use Model\Task; use Model\Project; +use Model\GithubWebhook; class ActionTaskCloseTest extends Base { + public function testExecutable() + { + $action = new Action\TaskClose($this->registry, 3, Task::EVENT_MOVE_COLUMN); + $action->setParam('column_id', 5); + + $event = array( + 'project_id' => 3, + 'task_id' => 3, + 'column_id' => 5, + ); + + $this->assertTrue($action->isExecutable($event)); + + $action = new Action\TaskClose($this->registry, 3, GithubWebhook::EVENT_COMMIT); + + $event = array( + 'project_id' => 3, + 'task_id' => 3, + ); + + $this->assertTrue($action->isExecutable($event)); + } + + public function testBadEvent() + { + $action = new Action\TaskClose($this->registry, 3, Task::EVENT_UPDATE); + $action->setParam('column_id', 5); + + $event = array( + 'project_id' => 3, + 'task_id' => 3, + 'column_id' => 5, + ); + + $this->assertFalse($action->isExecutable($event)); + $this->assertFalse($action->execute($event)); + } + public function testBadProject() { - $action = new Action\TaskClose(3, new Task($this->registry)); + $action = new Action\TaskClose($this->registry, 3, Task::EVENT_MOVE_COLUMN); $action->setParam('column_id', 5); $event = array( @@ -24,7 +63,7 @@ class ActionTaskCloseTest extends Base public function testBadColumn() { - $action = new Action\TaskClose(3, new Task($this->registry)); + $action = new Action\TaskClose($this->registry, 3, Task::EVENT_MOVE_COLUMN); $action->setParam('column_id', 5); $event = array( @@ -38,7 +77,7 @@ class ActionTaskCloseTest extends Base public function testExecute() { - $action = new Action\TaskClose(1, new Task($this->registry)); + $action = new Action\TaskClose($this->registry, 1, Task::EVENT_MOVE_COLUMN); $action->setParam('column_id', 2); // We create a task in the first column |