summaryrefslogtreecommitdiff
path: root/tests/units/Action/TaskAssignSpecificUserTest.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-01-03 16:43:13 -0500
committerFrederic Guillot <fred@kanboard.net>2016-01-03 16:43:13 -0500
commita296ba5b18487d312acca2513d461a210a460fae (patch)
treee5e22ffa7796a9734ec284826dd313219644a539 /tests/units/Action/TaskAssignSpecificUserTest.php
parentd578b612ea8853682f65ee74fd08f4893152d87a (diff)
Improve Automatic Actions plugin api
Diffstat (limited to 'tests/units/Action/TaskAssignSpecificUserTest.php')
-rw-r--r--tests/units/Action/TaskAssignSpecificUserTest.php72
1 files changed, 28 insertions, 44 deletions
diff --git a/tests/units/Action/TaskAssignSpecificUserTest.php b/tests/units/Action/TaskAssignSpecificUserTest.php
index a67335e8..67b2c397 100644
--- a/tests/units/Action/TaskAssignSpecificUserTest.php
+++ b/tests/units/Action/TaskAssignSpecificUserTest.php
@@ -3,69 +3,53 @@
require_once __DIR__.'/../Base.php';
use Kanboard\Event\GenericEvent;
-use Kanboard\Model\Task;
use Kanboard\Model\TaskCreation;
use Kanboard\Model\TaskFinder;
use Kanboard\Model\Project;
+use Kanboard\Model\Task;
use Kanboard\Action\TaskAssignSpecificUser;
class TaskAssignSpecificUserTest extends Base
{
- public function testBadProject()
+ public function testChangeUser()
{
- $action = new TaskAssignSpecificUser($this->container, 3, Task::EVENT_MOVE_COLUMN);
- $action->setParam('column_id', 5);
+ $projectModel = new Project($this->container);
+ $taskCreationModel = new TaskCreation($this->container);
+ $taskFinderModel = new TaskFinder($this->container);
- $event = array(
- 'project_id' => 2,
- 'task_id' => 3,
- 'column_id' => 5,
- );
+ $this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
+ $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test', 'owner_id' => 0)));
- $this->assertFalse($action->isExecutable($event));
- $this->assertFalse($action->execute(new GenericEvent($event)));
- }
+ $event = new GenericEvent(array('project_id' => 1, 'task_id' => 1, 'column_id' => 2));
- public function testBadColumn()
- {
- $action = new TaskAssignSpecificUser($this->container, 3, Task::EVENT_MOVE_COLUMN);
- $action->setParam('column_id', 5);
+ $action = new TaskAssignSpecificUser($this->container);
+ $action->setProjectId(1);
+ $action->setParam('column_id', 2);
+ $action->setParam('user_id', 1);
- $event = array(
- 'project_id' => 3,
- 'task_id' => 3,
- 'column_id' => 3,
- );
+ $this->assertTrue($action->execute($event, Task::EVENT_MOVE_COLUMN));
- $this->assertFalse($action->execute(new GenericEvent($event)));
+ $task = $taskFinderModel->getById(1);
+ $this->assertNotEmpty($task);
+ $this->assertEquals(1, $task['owner_id']);
}
- public function testExecute()
+ public function testWithWrongColumn()
{
- $action = new TaskAssignSpecificUser($this->container, 1, Task::EVENT_MOVE_COLUMN);
- $action->setParam('column_id', 2);
- $action->setParam('user_id', 1);
+ $projectModel = new Project($this->container);
+ $taskCreationModel = new TaskCreation($this->container);
+ $taskFinderModel = new TaskFinder($this->container);
- // We create a task in the first column
- $tc = new TaskCreation($this->container);
- $tf = new TaskFinder($this->container);
- $p = new Project($this->container);
- $this->assertEquals(1, $p->create(array('name' => 'test')));
- $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));
+ $this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
+ $this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));
- // We create an event to move the task to the 2nd column
- $event = array(
- 'project_id' => 1,
- 'task_id' => 1,
- 'column_id' => 2,
- );
+ $event = new GenericEvent(array('project_id' => 1, 'task_id' => 1, 'column_id' => 3));
- // Our event should be executed
- $this->assertTrue($action->execute(new GenericEvent($event)));
+ $action = new TaskAssignSpecificUser($this->container);
+ $action->setProjectId(1);
+ $action->setParam('column_id', 2);
+ $action->setParam('user_id', 1);
- // Our task should be assigned to the user 1
- $task = $tf->getById(1);
- $this->assertNotEmpty($task);
- $this->assertEquals(1, $task['owner_id']);
+ $this->assertFalse($action->execute($event, Task::EVENT_MOVE_COLUMN));
}
}