summaryrefslogtreecommitdiff
path: root/tests/units/Model/ActionTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/units/Model/ActionTest.php')
-rw-r--r--tests/units/Model/ActionTest.php176
1 files changed, 88 insertions, 88 deletions
diff --git a/tests/units/Model/ActionTest.php b/tests/units/Model/ActionTest.php
index ed687846..5db18983 100644
--- a/tests/units/Model/ActionTest.php
+++ b/tests/units/Model/ActionTest.php
@@ -2,27 +2,27 @@
require_once __DIR__.'/../Base.php';
-use Kanboard\Model\Action;
-use Kanboard\Model\Project;
-use Kanboard\Model\Task;
-use Kanboard\Model\User;
-use Kanboard\Model\Column;
-use Kanboard\Model\Category;
-use Kanboard\Model\ProjectUserRole;
+use Kanboard\Model\ActionModel;
+use Kanboard\Model\ProjectModel;
+use Kanboard\Model\TaskModel;
+use Kanboard\Model\UserModel;
+use Kanboard\Model\ColumnModel;
+use Kanboard\Model\CategoryModel;
+use Kanboard\Model\ProjectUserRoleModel;
use Kanboard\Core\Security\Role;
class ActionTest extends Base
{
public function testCreate()
{
- $projectModel = new Project($this->container);
- $actionModel = new Action($this->container);
+ $projectModel = new ProjectModel($this->container);
+ $actionModel = new ActionModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test')));
$this->assertEquals(1, $actionModel->create(array(
'project_id' => 1,
- 'event_name' => Task::EVENT_CREATE,
+ 'event_name' => TaskModel::EVENT_CREATE,
'action_name' => '\Kanboard\Action\TaskAssignColorColumn',
'params' => array('column_id' => 1, 'color_id' => 'red'),
)));
@@ -30,14 +30,14 @@ class ActionTest extends Base
public function testRemove()
{
- $projectModel = new Project($this->container);
- $actionModel = new Action($this->container);
+ $projectModel = new ProjectModel($this->container);
+ $actionModel = new ActionModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test')));
$this->assertEquals(1, $actionModel->create(array(
'project_id' => 1,
- 'event_name' => Task::EVENT_CREATE,
+ 'event_name' => TaskModel::EVENT_CREATE,
'action_name' => '\Kanboard\Action\TaskAssignColorColumn',
'params' => array('column_id' => 1, 'color_id' => 'red'),
)));
@@ -49,14 +49,14 @@ class ActionTest extends Base
public function testGetById()
{
- $projectModel = new Project($this->container);
- $actionModel = new Action($this->container);
+ $projectModel = new ProjectModel($this->container);
+ $actionModel = new ActionModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test')));
$this->assertEquals(1, $actionModel->create(array(
'project_id' => 1,
- 'event_name' => Task::EVENT_CREATE,
+ 'event_name' => TaskModel::EVENT_CREATE,
'action_name' => '\Kanboard\Action\TaskAssignColorColumn',
'params' => array('column_id' => 1, 'color_id' => 'red'),
)));
@@ -65,28 +65,28 @@ class ActionTest extends Base
$this->assertNotEmpty($action);
$this->assertEquals(1, $action['project_id']);
$this->assertEquals('\Kanboard\Action\TaskAssignColorColumn', $action['action_name']);
- $this->assertEquals(Task::EVENT_CREATE, $action['event_name']);
+ $this->assertEquals(TaskModel::EVENT_CREATE, $action['event_name']);
$this->assertEquals(array('column_id' => 1, 'color_id' => 'red'), $action['params']);
}
public function testGetAll()
{
- $projectModel = new Project($this->container);
- $actionModel = new Action($this->container);
+ $projectModel = new ProjectModel($this->container);
+ $actionModel = new ActionModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(2, $projectModel->create(array('name' => 'test2')));
$this->assertEquals(1, $actionModel->create(array(
'project_id' => 1,
- 'event_name' => Task::EVENT_CREATE,
+ 'event_name' => TaskModel::EVENT_CREATE,
'action_name' => '\Kanboard\Action\TaskAssignColorColumn',
'params' => array('column_id' => 1, 'color_id' => 'red'),
)));
$this->assertEquals(2, $actionModel->create(array(
'project_id' => 2,
- 'event_name' => Task::EVENT_MOVE_COLUMN,
+ 'event_name' => TaskModel::EVENT_MOVE_COLUMN,
'action_name' => '\Kanboard\Action\TaskAssignColorColumn',
'params' => array('column_id' => 6, 'color_id' => 'blue'),
)));
@@ -96,33 +96,33 @@ class ActionTest extends Base
$this->assertEquals(1, $actions[0]['project_id']);
$this->assertEquals('\Kanboard\Action\TaskAssignColorColumn', $actions[0]['action_name']);
- $this->assertEquals(Task::EVENT_CREATE, $actions[0]['event_name']);
+ $this->assertEquals(TaskModel::EVENT_CREATE, $actions[0]['event_name']);
$this->assertEquals(array('column_id' => 1, 'color_id' => 'red'), $actions[0]['params']);
$this->assertEquals(2, $actions[1]['project_id']);
$this->assertEquals('\Kanboard\Action\TaskAssignColorColumn', $actions[1]['action_name']);
- $this->assertEquals(Task::EVENT_MOVE_COLUMN, $actions[1]['event_name']);
+ $this->assertEquals(TaskModel::EVENT_MOVE_COLUMN, $actions[1]['event_name']);
$this->assertEquals(array('column_id' => 6, 'color_id' => 'blue'), $actions[1]['params']);
}
public function testGetAllByProject()
{
- $projectModel = new Project($this->container);
- $actionModel = new Action($this->container);
+ $projectModel = new ProjectModel($this->container);
+ $actionModel = new ActionModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(2, $projectModel->create(array('name' => 'test2')));
$this->assertEquals(1, $actionModel->create(array(
'project_id' => 1,
- 'event_name' => Task::EVENT_CREATE,
+ 'event_name' => TaskModel::EVENT_CREATE,
'action_name' => '\Kanboard\Action\TaskAssignColorColumn',
'params' => array('column_id' => 1, 'color_id' => 'red'),
)));
$this->assertEquals(2, $actionModel->create(array(
'project_id' => 2,
- 'event_name' => Task::EVENT_MOVE_COLUMN,
+ 'event_name' => TaskModel::EVENT_MOVE_COLUMN,
'action_name' => '\Kanboard\Action\TaskAssignColorColumn',
'params' => array('column_id' => 6, 'color_id' => 'blue'),
)));
@@ -132,7 +132,7 @@ class ActionTest extends Base
$this->assertEquals(1, $actions[0]['project_id']);
$this->assertEquals('\Kanboard\Action\TaskAssignColorColumn', $actions[0]['action_name']);
- $this->assertEquals(Task::EVENT_CREATE, $actions[0]['event_name']);
+ $this->assertEquals(TaskModel::EVENT_CREATE, $actions[0]['event_name']);
$this->assertEquals(array('column_id' => 1, 'color_id' => 'red'), $actions[0]['params']);
@@ -141,16 +141,16 @@ class ActionTest extends Base
$this->assertEquals(2, $actions[0]['project_id']);
$this->assertEquals('\Kanboard\Action\TaskAssignColorColumn', $actions[0]['action_name']);
- $this->assertEquals(Task::EVENT_MOVE_COLUMN, $actions[0]['event_name']);
+ $this->assertEquals(TaskModel::EVENT_MOVE_COLUMN, $actions[0]['event_name']);
$this->assertEquals(array('column_id' => 6, 'color_id' => 'blue'), $actions[0]['params']);
}
public function testGetAllByUser()
{
- $projectModel = new Project($this->container);
- $projectUserRoleModel = new ProjectUserRole($this->container);
- $userModel = new User($this->container);
- $actionModel = new Action($this->container);
+ $projectModel = new ProjectModel($this->container);
+ $projectUserRoleModel = new ProjectUserRoleModel($this->container);
+ $userModel = new UserModel($this->container);
+ $actionModel = new ActionModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(2, $projectModel->create(array('name' => 'test2')));
@@ -165,21 +165,21 @@ class ActionTest extends Base
$this->assertEquals(1, $actionModel->create(array(
'project_id' => 1,
- 'event_name' => Task::EVENT_CREATE,
+ 'event_name' => TaskModel::EVENT_CREATE,
'action_name' => '\Kanboard\Action\TaskAssignColorColumn',
'params' => array('column_id' => 1, 'color_id' => 'red'),
)));
$this->assertEquals(2, $actionModel->create(array(
'project_id' => 2,
- 'event_name' => Task::EVENT_MOVE_COLUMN,
+ 'event_name' => TaskModel::EVENT_MOVE_COLUMN,
'action_name' => '\Kanboard\Action\TaskAssignColorColumn',
'params' => array('column_id' => 6, 'color_id' => 'blue'),
)));
$this->assertEquals(3, $actionModel->create(array(
'project_id' => 3,
- 'event_name' => Task::EVENT_MOVE_COLUMN,
+ 'event_name' => TaskModel::EVENT_MOVE_COLUMN,
'action_name' => '\Kanboard\Action\TaskAssignColorColumn',
'params' => array('column_id' => 10, 'color_id' => 'green'),
)));
@@ -192,7 +192,7 @@ class ActionTest extends Base
$this->assertEquals(1, $actions[0]['project_id']);
$this->assertEquals('\Kanboard\Action\TaskAssignColorColumn', $actions[0]['action_name']);
- $this->assertEquals(Task::EVENT_CREATE, $actions[0]['event_name']);
+ $this->assertEquals(TaskModel::EVENT_CREATE, $actions[0]['event_name']);
$this->assertEquals(array('column_id' => 1, 'color_id' => 'red'), $actions[0]['params']);
$actions = $actionModel->getAllByUser(3);
@@ -200,21 +200,21 @@ class ActionTest extends Base
$this->assertEquals(2, $actions[0]['project_id']);
$this->assertEquals('\Kanboard\Action\TaskAssignColorColumn', $actions[0]['action_name']);
- $this->assertEquals(Task::EVENT_MOVE_COLUMN, $actions[0]['event_name']);
+ $this->assertEquals(TaskModel::EVENT_MOVE_COLUMN, $actions[0]['event_name']);
$this->assertEquals(array('column_id' => 6, 'color_id' => 'blue'), $actions[0]['params']);
}
public function testDuplicateWithColumnAndColorParameter()
{
- $projectModel = new Project($this->container);
- $actionModel = new Action($this->container);
+ $projectModel = new ProjectModel($this->container);
+ $actionModel = new ActionModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(2, $projectModel->create(array('name' => 'test2')));
$this->assertEquals(1, $actionModel->create(array(
'project_id' => 1,
- 'event_name' => Task::EVENT_CREATE,
+ 'event_name' => TaskModel::EVENT_CREATE,
'action_name' => '\Kanboard\Action\TaskAssignColorColumn',
'params' => array('column_id' => 1, 'color_id' => 'red'),
)));
@@ -226,21 +226,21 @@ class ActionTest extends Base
$this->assertEquals(2, $actions[0]['project_id']);
$this->assertEquals('\Kanboard\Action\TaskAssignColorColumn', $actions[0]['action_name']);
- $this->assertEquals(Task::EVENT_CREATE, $actions[0]['event_name']);
+ $this->assertEquals(TaskModel::EVENT_CREATE, $actions[0]['event_name']);
$this->assertEquals(array('column_id' => 5, 'color_id' => 'red'), $actions[0]['params']);
}
public function testDuplicateWithColumnsParameter()
{
- $projectModel = new Project($this->container);
- $actionModel = new Action($this->container);
+ $projectModel = new ProjectModel($this->container);
+ $actionModel = new ActionModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(2, $projectModel->create(array('name' => 'test2')));
$this->assertEquals(1, $actionModel->create(array(
'project_id' => 1,
- 'event_name' => Task::EVENT_CREATE,
+ 'event_name' => TaskModel::EVENT_CREATE,
'action_name' => '\Kanboard\Action\TaskAssignColorColumn',
'params' => array('src_column_id' => 1, 'dst_column_id' => 2, 'dest_column_id' => 3),
)));
@@ -252,15 +252,15 @@ class ActionTest extends Base
$this->assertEquals(2, $actions[0]['project_id']);
$this->assertEquals('\Kanboard\Action\TaskAssignColorColumn', $actions[0]['action_name']);
- $this->assertEquals(Task::EVENT_CREATE, $actions[0]['event_name']);
+ $this->assertEquals(TaskModel::EVENT_CREATE, $actions[0]['event_name']);
$this->assertEquals(array('src_column_id' => 5, 'dst_column_id' => 6, 'dest_column_id' => 7), $actions[0]['params']);
}
public function testDuplicateWithColumnParameterNotfound()
{
- $projectModel = new Project($this->container);
- $actionModel = new Action($this->container);
- $columnModel = new Column($this->container);
+ $projectModel = new ProjectModel($this->container);
+ $actionModel = new ActionModel($this->container);
+ $columnModel = new ColumnModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(2, $projectModel->create(array('name' => 'test2')));
@@ -269,14 +269,14 @@ class ActionTest extends Base
$this->assertEquals(1, $actionModel->create(array(
'project_id' => 1,
- 'event_name' => Task::EVENT_CREATE,
+ 'event_name' => TaskModel::EVENT_CREATE,
'action_name' => '\Kanboard\Action\TaskAssignColorColumn',
'params' => array('column_id' => 1, 'color_id' => 'red'),
)));
$this->assertEquals(2, $actionModel->create(array(
'project_id' => 1,
- 'event_name' => Task::EVENT_MOVE_COLUMN,
+ 'event_name' => TaskModel::EVENT_MOVE_COLUMN,
'action_name' => '\Kanboard\Action\TaskAssignColorColumn',
'params' => array('column_id' => 2, 'color_id' => 'green'),
)));
@@ -288,14 +288,14 @@ class ActionTest extends Base
$this->assertEquals(2, $actions[0]['project_id']);
$this->assertEquals('\Kanboard\Action\TaskAssignColorColumn', $actions[0]['action_name']);
- $this->assertEquals(Task::EVENT_CREATE, $actions[0]['event_name']);
+ $this->assertEquals(TaskModel::EVENT_CREATE, $actions[0]['event_name']);
$this->assertEquals(array('column_id' => 5, 'color_id' => 'red'), $actions[0]['params']);
}
public function testDuplicateWithProjectParameter()
{
- $projectModel = new Project($this->container);
- $actionModel = new Action($this->container);
+ $projectModel = new ProjectModel($this->container);
+ $actionModel = new ActionModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(2, $projectModel->create(array('name' => 'test2')));
@@ -303,7 +303,7 @@ class ActionTest extends Base
$this->assertEquals(1, $actionModel->create(array(
'project_id' => 1,
- 'event_name' => Task::EVENT_CLOSE,
+ 'event_name' => TaskModel::EVENT_CLOSE,
'action_name' => '\Kanboard\Action\TaskDuplicateAnotherProject',
'params' => array('column_id' => 1, 'project_id' => 3),
)));
@@ -315,21 +315,21 @@ class ActionTest extends Base
$this->assertEquals(2, $actions[0]['project_id']);
$this->assertEquals('\Kanboard\Action\TaskDuplicateAnotherProject', $actions[0]['action_name']);
- $this->assertEquals(Task::EVENT_CLOSE, $actions[0]['event_name']);
+ $this->assertEquals(TaskModel::EVENT_CLOSE, $actions[0]['event_name']);
$this->assertEquals(array('column_id' => 5, 'project_id' => 3), $actions[0]['params']);
}
public function testDuplicateWithProjectParameterIdenticalToDestination()
{
- $projectModel = new Project($this->container);
- $actionModel = new Action($this->container);
+ $projectModel = new ProjectModel($this->container);
+ $actionModel = new ActionModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(2, $projectModel->create(array('name' => 'test2')));
$this->assertEquals(1, $actionModel->create(array(
'project_id' => 1,
- 'event_name' => Task::EVENT_CLOSE,
+ 'event_name' => TaskModel::EVENT_CLOSE,
'action_name' => '\Kanboard\Action\TaskDuplicateAnotherProject',
'params' => array('column_id' => 1, 'project_id' => 2),
)));
@@ -342,10 +342,10 @@ class ActionTest extends Base
public function testDuplicateWithUserParameter()
{
- $projectUserRoleModel = new ProjectUserRole($this->container);
- $userModel = new User($this->container);
- $projectModel = new Project($this->container);
- $actionModel = new Action($this->container);
+ $projectUserRoleModel = new ProjectUserRoleModel($this->container);
+ $userModel = new UserModel($this->container);
+ $projectModel = new ProjectModel($this->container);
+ $actionModel = new ActionModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(2, $projectModel->create(array('name' => 'test2')));
@@ -357,7 +357,7 @@ class ActionTest extends Base
$this->assertEquals(1, $actionModel->create(array(
'project_id' => 1,
- 'event_name' => Task::EVENT_MOVE_COLUMN,
+ 'event_name' => TaskModel::EVENT_MOVE_COLUMN,
'action_name' => '\Kanboard\Action\TaskAssignSpecificUser',
'params' => array('column_id' => 1, 'user_id' => 2),
)));
@@ -369,16 +369,16 @@ class ActionTest extends Base
$this->assertEquals(2, $actions[0]['project_id']);
$this->assertEquals('\Kanboard\Action\TaskAssignSpecificUser', $actions[0]['action_name']);
- $this->assertEquals(Task::EVENT_MOVE_COLUMN, $actions[0]['event_name']);
+ $this->assertEquals(TaskModel::EVENT_MOVE_COLUMN, $actions[0]['event_name']);
$this->assertEquals(array('column_id' => 5, 'user_id' => 2), $actions[0]['params']);
}
public function testDuplicateWithUserParameterButNotAssignable()
{
- $projectUserRoleModel = new ProjectUserRole($this->container);
- $userModel = new User($this->container);
- $projectModel = new Project($this->container);
- $actionModel = new Action($this->container);
+ $projectUserRoleModel = new ProjectUserRoleModel($this->container);
+ $userModel = new UserModel($this->container);
+ $projectModel = new ProjectModel($this->container);
+ $actionModel = new ActionModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(2, $projectModel->create(array('name' => 'test2')));
@@ -390,7 +390,7 @@ class ActionTest extends Base
$this->assertEquals(1, $actionModel->create(array(
'project_id' => 1,
- 'event_name' => Task::EVENT_MOVE_COLUMN,
+ 'event_name' => TaskModel::EVENT_MOVE_COLUMN,
'action_name' => '\Kanboard\Action\TaskAssignSpecificUser',
'params' => array('column_id' => 1, 'user_id' => 2),
)));
@@ -403,10 +403,10 @@ class ActionTest extends Base
public function testDuplicateWithUserParameterButNotAvailable()
{
- $projectUserRoleModel = new ProjectUserRole($this->container);
- $userModel = new User($this->container);
- $projectModel = new Project($this->container);
- $actionModel = new Action($this->container);
+ $projectUserRoleModel = new ProjectUserRoleModel($this->container);
+ $userModel = new UserModel($this->container);
+ $projectModel = new ProjectModel($this->container);
+ $actionModel = new ActionModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(2, $projectModel->create(array('name' => 'test2')));
@@ -417,7 +417,7 @@ class ActionTest extends Base
$this->assertEquals(1, $actionModel->create(array(
'project_id' => 1,
- 'event_name' => Task::EVENT_MOVE_COLUMN,
+ 'event_name' => TaskModel::EVENT_MOVE_COLUMN,
'action_name' => '\Kanboard\Action\TaskAssignSpecificUser',
'params' => array('column_id' => 1, 'owner_id' => 2),
)));
@@ -430,9 +430,9 @@ class ActionTest extends Base
public function testDuplicateWithCategoryParameter()
{
- $projectModel = new Project($this->container);
- $actionModel = new Action($this->container);
- $categoryModel = new Category($this->container);
+ $projectModel = new ProjectModel($this->container);
+ $actionModel = new ActionModel($this->container);
+ $categoryModel = new CategoryModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(2, $projectModel->create(array('name' => 'test2')));
@@ -442,7 +442,7 @@ class ActionTest extends Base
$this->assertEquals(1, $actionModel->create(array(
'project_id' => 1,
- 'event_name' => Task::EVENT_CREATE_UPDATE,
+ 'event_name' => TaskModel::EVENT_CREATE_UPDATE,
'action_name' => '\Kanboard\Action\TaskAssignColorCategory',
'params' => array('column_id' => 1, 'category_id' => 1),
)));
@@ -454,15 +454,15 @@ class ActionTest extends Base
$this->assertEquals(2, $actions[0]['project_id']);
$this->assertEquals('\Kanboard\Action\TaskAssignColorCategory', $actions[0]['action_name']);
- $this->assertEquals(Task::EVENT_CREATE_UPDATE, $actions[0]['event_name']);
+ $this->assertEquals(TaskModel::EVENT_CREATE_UPDATE, $actions[0]['event_name']);
$this->assertEquals(array('column_id' => 5, 'category_id' => 2), $actions[0]['params']);
}
public function testDuplicateWithCategoryParameterButDifferentName()
{
- $projectModel = new Project($this->container);
- $actionModel = new Action($this->container);
- $categoryModel = new Category($this->container);
+ $projectModel = new ProjectModel($this->container);
+ $actionModel = new ActionModel($this->container);
+ $categoryModel = new CategoryModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(2, $projectModel->create(array('name' => 'test2')));
@@ -472,7 +472,7 @@ class ActionTest extends Base
$this->assertEquals(1, $actionModel->create(array(
'project_id' => 1,
- 'event_name' => Task::EVENT_CREATE_UPDATE,
+ 'event_name' => TaskModel::EVENT_CREATE_UPDATE,
'action_name' => '\Kanboard\Action\TaskAssignColorCategory',
'params' => array('column_id' => 1, 'category_id' => 1),
)));
@@ -485,9 +485,9 @@ class ActionTest extends Base
public function testDuplicateWithCategoryParameterButNotFound()
{
- $projectModel = new Project($this->container);
- $actionModel = new Action($this->container);
- $categoryModel = new Category($this->container);
+ $projectModel = new ProjectModel($this->container);
+ $actionModel = new ActionModel($this->container);
+ $categoryModel = new CategoryModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(2, $projectModel->create(array('name' => 'test2')));
@@ -496,7 +496,7 @@ class ActionTest extends Base
$this->assertEquals(1, $actionModel->create(array(
'project_id' => 1,
- 'event_name' => Task::EVENT_CREATE_UPDATE,
+ 'event_name' => TaskModel::EVENT_CREATE_UPDATE,
'action_name' => '\Kanboard\Action\TaskAssignColorCategory',
'params' => array('column_id' => 1, 'category_id' => 1),
)));