From 4a230d331ec220fc32a48525afb308af0d9787fa Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 26 Jun 2016 10:25:13 -0400 Subject: Added application and project roles validation for API procedure calls --- tests/integration/ActionProcedureTest.php | 66 +++++ tests/integration/ActionTest.php | 66 ----- tests/integration/AppProcedureTest.php | 54 ++++ tests/integration/AppTest.php | 54 ---- tests/integration/BaseIntegrationTest.php | 122 -------- tests/integration/BaseProcedureTest.php | 122 ++++++++ tests/integration/BoardProcedureTest.php | 25 ++ tests/integration/BoardTest.php | 25 -- tests/integration/CategoryProcedureTest.php | 76 +++++ tests/integration/CategoryTest.php | 76 ----- tests/integration/ColumnProcedureTest.php | 69 +++++ tests/integration/ColumnTest.php | 69 ----- tests/integration/CommentProcedureTest.php | 63 +++++ tests/integration/CommentTest.php | 63 ----- tests/integration/GroupMemberProcedureTest.php | 53 ++++ tests/integration/GroupMemberTest.php | 53 ---- tests/integration/GroupProcedureTest.php | 50 ++++ tests/integration/GroupTest.php | 50 ---- tests/integration/LinkProcedureTest.php | 70 +++++ tests/integration/LinkTest.php | 70 ----- tests/integration/MeProcedureTest.php | 68 +++++ tests/integration/MeTest.php | 73 ----- tests/integration/OverdueTaskProcedureTest.php | 43 +++ tests/integration/OverdueTaskTest.php | 43 --- tests/integration/ProcedureAuthorizationTest.php | 306 +++++++++++++++++++++ .../integration/ProjectPermissionProcedureTest.php | 89 ++++++ tests/integration/ProjectPermissionTest.php | 89 ------ tests/integration/ProjectProcedureTest.php | 89 ++++++ tests/integration/ProjectTest.php | 89 ------ tests/integration/SubtaskProcedureTest.php | 64 +++++ tests/integration/SubtaskTest.php | 64 ----- tests/integration/SwimlaneProcedureTest.php | 93 +++++++ tests/integration/SwimlaneTest.php | 93 ------- tests/integration/TaskFileProcedureTest.php | 67 +++++ tests/integration/TaskFileTest.php | 67 ----- tests/integration/TaskLinkProcedureTest.php | 68 +++++ tests/integration/TaskLinkTest.php | 68 ----- tests/integration/TaskProcedureTest.php | 55 ++++ tests/integration/TaskTest.php | 55 ---- tests/integration/UserProcedureTest.php | 63 +++++ tests/integration/UserTest.php | 63 ----- 41 files changed, 1653 insertions(+), 1352 deletions(-) create mode 100644 tests/integration/ActionProcedureTest.php delete mode 100644 tests/integration/ActionTest.php create mode 100644 tests/integration/AppProcedureTest.php delete mode 100644 tests/integration/AppTest.php delete mode 100644 tests/integration/BaseIntegrationTest.php create mode 100644 tests/integration/BaseProcedureTest.php create mode 100644 tests/integration/BoardProcedureTest.php delete mode 100644 tests/integration/BoardTest.php create mode 100644 tests/integration/CategoryProcedureTest.php delete mode 100644 tests/integration/CategoryTest.php create mode 100644 tests/integration/ColumnProcedureTest.php delete mode 100644 tests/integration/ColumnTest.php create mode 100644 tests/integration/CommentProcedureTest.php delete mode 100644 tests/integration/CommentTest.php create mode 100644 tests/integration/GroupMemberProcedureTest.php delete mode 100644 tests/integration/GroupMemberTest.php create mode 100644 tests/integration/GroupProcedureTest.php delete mode 100644 tests/integration/GroupTest.php create mode 100644 tests/integration/LinkProcedureTest.php delete mode 100644 tests/integration/LinkTest.php create mode 100644 tests/integration/MeProcedureTest.php delete mode 100644 tests/integration/MeTest.php create mode 100644 tests/integration/OverdueTaskProcedureTest.php delete mode 100644 tests/integration/OverdueTaskTest.php create mode 100644 tests/integration/ProcedureAuthorizationTest.php create mode 100644 tests/integration/ProjectPermissionProcedureTest.php delete mode 100644 tests/integration/ProjectPermissionTest.php create mode 100644 tests/integration/ProjectProcedureTest.php delete mode 100644 tests/integration/ProjectTest.php create mode 100644 tests/integration/SubtaskProcedureTest.php delete mode 100644 tests/integration/SubtaskTest.php create mode 100644 tests/integration/SwimlaneProcedureTest.php delete mode 100644 tests/integration/SwimlaneTest.php create mode 100644 tests/integration/TaskFileProcedureTest.php delete mode 100644 tests/integration/TaskFileTest.php create mode 100644 tests/integration/TaskLinkProcedureTest.php delete mode 100644 tests/integration/TaskLinkTest.php create mode 100644 tests/integration/TaskProcedureTest.php delete mode 100644 tests/integration/TaskTest.php create mode 100644 tests/integration/UserProcedureTest.php delete mode 100644 tests/integration/UserTest.php (limited to 'tests/integration') diff --git a/tests/integration/ActionProcedureTest.php b/tests/integration/ActionProcedureTest.php new file mode 100644 index 00000000..432de3d3 --- /dev/null +++ b/tests/integration/ActionProcedureTest.php @@ -0,0 +1,66 @@ +app->getAvailableActions(); + $this->assertNotEmpty($actions); + $this->assertInternalType('array', $actions); + $this->assertArrayHasKey('\Kanboard\Action\TaskCloseColumn', $actions); + } + + public function testGetAvailableActionEvents() + { + $events = $this->app->getAvailableActionEvents(); + $this->assertNotEmpty($events); + $this->assertInternalType('array', $events); + $this->assertArrayHasKey('task.move.column', $events); + } + + public function testGetCompatibleActionEvents() + { + $events = $this->app->getCompatibleActionEvents('\Kanboard\Action\TaskCloseColumn'); + $this->assertNotEmpty($events); + $this->assertInternalType('array', $events); + $this->assertArrayHasKey('task.move.column', $events); + } + + public function testCRUD() + { + $this->assertCreateTeamProject(); + $this->assertCreateAction(); + $this->assertGetActions(); + $this->assertRemoveAction(); + } + + public function assertCreateAction() + { + $actionId = $this->app->createAction($this->projectId, 'task.move.column', '\Kanboard\Action\TaskCloseColumn', array('column_id' => 1)); + $this->assertNotFalse($actionId); + $this->assertTrue($actionId > 0); + } + + public function assertGetActions() + { + $actions = $this->app->getActions($this->projectId); + $this->assertNotEmpty($actions); + $this->assertInternalType('array', $actions); + $this->assertArrayHasKey('id', $actions[0]); + $this->assertArrayHasKey('project_id', $actions[0]); + $this->assertArrayHasKey('event_name', $actions[0]); + $this->assertArrayHasKey('action_name', $actions[0]); + $this->assertArrayHasKey('params', $actions[0]); + $this->assertArrayHasKey('column_id', $actions[0]['params']); + } + + public function assertRemoveAction() + { + $actionId = $this->app->createAction($this->projectId, 'task.move.column', '\Kanboard\Action\TaskCloseColumn', array('column_id' => 1)); + $this->assertTrue($this->app->removeAction($actionId)); + } +} diff --git a/tests/integration/ActionTest.php b/tests/integration/ActionTest.php deleted file mode 100644 index 7a5adc4a..00000000 --- a/tests/integration/ActionTest.php +++ /dev/null @@ -1,66 +0,0 @@ -app->getAvailableActions(); - $this->assertNotEmpty($actions); - $this->assertInternalType('array', $actions); - $this->assertArrayHasKey('\Kanboard\Action\TaskCloseColumn', $actions); - } - - public function testGetAvailableActionEvents() - { - $events = $this->app->getAvailableActionEvents(); - $this->assertNotEmpty($events); - $this->assertInternalType('array', $events); - $this->assertArrayHasKey('task.move.column', $events); - } - - public function testGetCompatibleActionEvents() - { - $events = $this->app->getCompatibleActionEvents('\Kanboard\Action\TaskCloseColumn'); - $this->assertNotEmpty($events); - $this->assertInternalType('array', $events); - $this->assertArrayHasKey('task.move.column', $events); - } - - public function testCRUD() - { - $this->assertCreateTeamProject(); - $this->assertCreateAction(); - $this->assertGetActions(); - $this->assertRemoveAction(); - } - - public function assertCreateAction() - { - $actionId = $this->app->createAction($this->projectId, 'task.move.column', '\Kanboard\Action\TaskCloseColumn', array('column_id' => 1)); - $this->assertNotFalse($actionId); - $this->assertTrue($actionId > 0); - } - - public function assertGetActions() - { - $actions = $this->app->getActions($this->projectId); - $this->assertNotEmpty($actions); - $this->assertInternalType('array', $actions); - $this->assertArrayHasKey('id', $actions[0]); - $this->assertArrayHasKey('project_id', $actions[0]); - $this->assertArrayHasKey('event_name', $actions[0]); - $this->assertArrayHasKey('action_name', $actions[0]); - $this->assertArrayHasKey('params', $actions[0]); - $this->assertArrayHasKey('column_id', $actions[0]['params']); - } - - public function assertRemoveAction() - { - $actionId = $this->app->createAction($this->projectId, 'task.move.column', '\Kanboard\Action\TaskCloseColumn', array('column_id' => 1)); - $this->assertTrue($this->app->removeAction($actionId)); - } -} diff --git a/tests/integration/AppProcedureTest.php b/tests/integration/AppProcedureTest.php new file mode 100644 index 00000000..06135dac --- /dev/null +++ b/tests/integration/AppProcedureTest.php @@ -0,0 +1,54 @@ +assertEquals('UTC', $this->app->getTimezone()); + } + + public function testGetVersion() + { + $this->assertEquals('master', $this->app->getVersion()); + } + + public function testGetApplicationRoles() + { + $roles = $this->app->getApplicationRoles(); + $this->assertCount(3, $roles); + $this->assertEquals('Administrator', $roles['app-admin']); + $this->assertEquals('Manager', $roles['app-manager']); + $this->assertEquals('User', $roles['app-user']); + } + + public function testGetProjectRoles() + { + $roles = $this->app->getProjectRoles(); + $this->assertCount(3, $roles); + $this->assertEquals('Project Manager', $roles['project-manager']); + $this->assertEquals('Project Member', $roles['project-member']); + $this->assertEquals('Project Viewer', $roles['project-viewer']); + } + + public function testGetDefaultColor() + { + $this->assertEquals('yellow', $this->user->getDefaultTaskColor()); + } + + public function testGetDefaultColors() + { + $colors = $this->user->getDefaultTaskColors(); + $this->assertNotEmpty($colors); + $this->assertArrayHasKey('red', $colors); + } + + public function testGetColorList() + { + $colors = $this->user->getColorList(); + $this->assertNotEmpty($colors); + $this->assertArrayHasKey('red', $colors); + $this->assertEquals('Red', $colors['red']); + } +} diff --git a/tests/integration/AppTest.php b/tests/integration/AppTest.php deleted file mode 100644 index 287e6299..00000000 --- a/tests/integration/AppTest.php +++ /dev/null @@ -1,54 +0,0 @@ -assertEquals('UTC', $this->app->getTimezone()); - } - - public function testGetVersion() - { - $this->assertEquals('master', $this->app->getVersion()); - } - - public function testGetApplicationRoles() - { - $roles = $this->app->getApplicationRoles(); - $this->assertCount(3, $roles); - $this->assertEquals('Administrator', $roles['app-admin']); - $this->assertEquals('Manager', $roles['app-manager']); - $this->assertEquals('User', $roles['app-user']); - } - - public function testGetProjectRoles() - { - $roles = $this->app->getProjectRoles(); - $this->assertCount(3, $roles); - $this->assertEquals('Project Manager', $roles['project-manager']); - $this->assertEquals('Project Member', $roles['project-member']); - $this->assertEquals('Project Viewer', $roles['project-viewer']); - } - - public function testGetDefaultColor() - { - $this->assertEquals('yellow', $this->user->getDefaultTaskColor()); - } - - public function testGetDefaultColors() - { - $colors = $this->user->getDefaultTaskColors(); - $this->assertNotEmpty($colors); - $this->assertArrayHasKey('red', $colors); - } - - public function testGetColorList() - { - $colors = $this->user->getColorList(); - $this->assertNotEmpty($colors); - $this->assertArrayHasKey('red', $colors); - $this->assertEquals('Red', $colors['red']); - } -} diff --git a/tests/integration/BaseIntegrationTest.php b/tests/integration/BaseIntegrationTest.php deleted file mode 100644 index cd837173..00000000 --- a/tests/integration/BaseIntegrationTest.php +++ /dev/null @@ -1,122 +0,0 @@ -setUpAppClient(); - $this->setUpAdminUser(); - $this->setUpManagerUser(); - $this->setUpStandardUser(); - } - - public function setUpAppClient() - { - $this->app = new JsonRPC\Client(API_URL); - $this->app->authentication('jsonrpc', API_KEY); - $this->app->getHttpClient()->withDebug()->withTimeout(10); - } - - public function setUpAdminUser() - { - $this->adminUserId = $this->getUserId('superuser'); - - if (! $this->adminUserId) { - $this->adminUserId = $this->app->createUser('superuser', 'password', 'Admin User', 'user@localhost', 'app-admin'); - $this->assertNotFalse($this->adminUserId); - } - - $this->admin = new JsonRPC\Client(API_URL); - $this->admin->authentication('superuser', 'password'); - $this->admin->getHttpClient()->withDebug(); - } - - public function setUpManagerUser() - { - $this->managerUserId = $this->getUserId('manager'); - - if (! $this->managerUserId) { - $this->managerUserId = $this->app->createUser('manager', 'password', 'Manager User', 'user@localhost', 'app-manager'); - $this->assertNotFalse($this->managerUserId); - } - - $this->manager = new JsonRPC\Client(API_URL); - $this->manager->authentication('manager', 'password'); - $this->manager->getHttpClient()->withDebug(); - } - - public function setUpStandardUser() - { - $this->userUserId = $this->getUserId('user'); - - if (! $this->userUserId) { - $this->userUserId = $this->app->createUser('user', 'password', 'Standard User', 'user@localhost', 'app-user'); - $this->assertNotFalse($this->userUserId); - } - - $this->user = new JsonRPC\Client(API_URL); - $this->user->authentication('user', 'password'); - $this->user->getHttpClient()->withDebug(); - } - - public function getUserId($username) - { - $user = $this->app->getUserByName($username); - - if (! empty($user)) { - return $user['id']; - } - - return 0; - } - - public function assertCreateTeamProject() - { - $this->projectId = $this->app->createProject($this->projectName, 'Description'); - $this->assertNotFalse($this->projectId); - } - - public function assertCreateUser() - { - $this->userId = $this->app->createUser($this->username, 'password'); - $this->assertNotFalse($this->userId); - } - - public function assertCreateGroups() - { - $this->groupId1 = $this->app->createGroup($this->groupName1); - $this->groupId2 = $this->app->createGroup($this->groupName2, 'External ID'); - $this->assertNotFalse($this->groupId1); - $this->assertNotFalse($this->groupId2); - } - - public function assertCreateTask() - { - $this->taskId = $this->app->createTask(array('title' => $this->taskTitle, 'project_id' => $this->projectId)); - $this->assertNotFalse($this->taskId); - } -} diff --git a/tests/integration/BaseProcedureTest.php b/tests/integration/BaseProcedureTest.php new file mode 100644 index 00000000..e3382e82 --- /dev/null +++ b/tests/integration/BaseProcedureTest.php @@ -0,0 +1,122 @@ +setUpAppClient(); + $this->setUpAdminUser(); + $this->setUpManagerUser(); + $this->setUpStandardUser(); + } + + public function setUpAppClient() + { + $this->app = new JsonRPC\Client(API_URL); + $this->app->authentication('jsonrpc', API_KEY); + $this->app->getHttpClient()->withDebug()->withTimeout(10); + } + + public function setUpAdminUser() + { + $this->adminUserId = $this->getUserId('superuser'); + + if (! $this->adminUserId) { + $this->adminUserId = $this->app->createUser('superuser', 'password', 'Admin User', 'user@localhost', 'app-admin'); + $this->assertNotFalse($this->adminUserId); + } + + $this->admin = new JsonRPC\Client(API_URL); + $this->admin->authentication('superuser', 'password'); + $this->admin->getHttpClient()->withDebug(); + } + + public function setUpManagerUser() + { + $this->managerUserId = $this->getUserId('manager'); + + if (! $this->managerUserId) { + $this->managerUserId = $this->app->createUser('manager', 'password', 'Manager User', 'user@localhost', 'app-manager'); + $this->assertNotFalse($this->managerUserId); + } + + $this->manager = new JsonRPC\Client(API_URL); + $this->manager->authentication('manager', 'password'); + $this->manager->getHttpClient()->withDebug(); + } + + public function setUpStandardUser() + { + $this->userUserId = $this->getUserId('user'); + + if (! $this->userUserId) { + $this->userUserId = $this->app->createUser('user', 'password', 'Standard User', 'user@localhost', 'app-user'); + $this->assertNotFalse($this->userUserId); + } + + $this->user = new JsonRPC\Client(API_URL); + $this->user->authentication('user', 'password'); + $this->user->getHttpClient()->withDebug(); + } + + public function getUserId($username) + { + $user = $this->app->getUserByName($username); + + if (! empty($user)) { + return $user['id']; + } + + return 0; + } + + public function assertCreateTeamProject() + { + $this->projectId = $this->app->createProject($this->projectName, 'Description'); + $this->assertNotFalse($this->projectId); + } + + public function assertCreateUser() + { + $this->userId = $this->app->createUser($this->username, 'password'); + $this->assertNotFalse($this->userId); + } + + public function assertCreateGroups() + { + $this->groupId1 = $this->app->createGroup($this->groupName1); + $this->groupId2 = $this->app->createGroup($this->groupName2, 'External ID'); + $this->assertNotFalse($this->groupId1); + $this->assertNotFalse($this->groupId2); + } + + public function assertCreateTask() + { + $this->taskId = $this->app->createTask(array('title' => $this->taskTitle, 'project_id' => $this->projectId)); + $this->assertNotFalse($this->taskId); + } +} diff --git a/tests/integration/BoardProcedureTest.php b/tests/integration/BoardProcedureTest.php new file mode 100644 index 00000000..273e93c7 --- /dev/null +++ b/tests/integration/BoardProcedureTest.php @@ -0,0 +1,25 @@ +assertCreateTeamProject(); + $this->assertGetBoard(); + } + + public function assertGetBoard() + { + $board = $this->app->getBoard($this->projectId); + $this->assertNotNull($board); + $this->assertCount(1, $board); + $this->assertEquals('Default swimlane', $board[0]['name']); + + $this->assertCount(4, $board[0]['columns']); + $this->assertEquals('Ready', $board[0]['columns'][1]['title']); + } +} diff --git a/tests/integration/BoardTest.php b/tests/integration/BoardTest.php deleted file mode 100644 index aa0f61ff..00000000 --- a/tests/integration/BoardTest.php +++ /dev/null @@ -1,25 +0,0 @@ -assertCreateTeamProject(); - $this->assertGetBoard(); - } - - public function assertGetBoard() - { - $board = $this->app->getBoard($this->projectId); - $this->assertNotNull($board); - $this->assertCount(1, $board); - $this->assertEquals('Default swimlane', $board[0]['name']); - - $this->assertCount(4, $board[0]['columns']); - $this->assertEquals('Ready', $board[0]['columns'][1]['title']); - } -} diff --git a/tests/integration/CategoryProcedureTest.php b/tests/integration/CategoryProcedureTest.php new file mode 100644 index 00000000..2f5294ba --- /dev/null +++ b/tests/integration/CategoryProcedureTest.php @@ -0,0 +1,76 @@ +assertCreateTeamProject(); + $this->assertCreateCategory(); + $this->assertThatCategoriesAreUnique(); + $this->assertGetCategory(); + $this->assertGetAllCategories(); + $this->assertCategoryUpdate(); + $this->assertRemoveCategory(); + } + + public function assertCreateCategory() + { + $this->categoryId = $this->app->createCategory(array( + 'name' => 'Category', + 'project_id' => $this->projectId, + )); + + $this->assertNotFalse($this->categoryId); + } + + public function assertThatCategoriesAreUnique() + { + $this->assertFalse($this->app->execute('createCategory', array( + 'name' => 'Category', + 'project_id' => $this->projectId, + ))); + } + + public function assertGetCategory() + { + $category = $this->app->getCategory($this->categoryId); + + $this->assertInternalType('array', $category); + $this->assertEquals($this->categoryId, $category['id']); + $this->assertEquals('Category', $category['name']); + $this->assertEquals($this->projectId, $category['project_id']); + } + + public function assertGetAllCategories() + { + $categories = $this->app->getAllCategories($this->projectId); + + $this->assertCount(1, $categories); + $this->assertEquals($this->categoryId, $categories[0]['id']); + $this->assertEquals('Category', $categories[0]['name']); + $this->assertEquals($this->projectId, $categories[0]['project_id']); + } + + public function assertCategoryUpdate() + { + $this->assertTrue($this->app->execute('updateCategory', array( + 'id' => $this->categoryId, + 'name' => 'Renamed category', + ))); + + $category = $this->app->getCategory($this->categoryId); + $this->assertEquals('Renamed category', $category['name']); + } + + public function assertRemoveCategory() + { + $this->assertTrue($this->app->removeCategory($this->categoryId)); + $this->assertFalse($this->app->removeCategory($this->categoryId)); + $this->assertFalse($this->app->removeCategory(1111)); + } +} diff --git a/tests/integration/CategoryTest.php b/tests/integration/CategoryTest.php deleted file mode 100644 index c1aec0bc..00000000 --- a/tests/integration/CategoryTest.php +++ /dev/null @@ -1,76 +0,0 @@ -assertCreateTeamProject(); - $this->assertCreateCategory(); - $this->assertThatCategoriesAreUnique(); - $this->assertGetCategory(); - $this->assertGetAllCategories(); - $this->assertCategoryUpdate(); - $this->assertRemoveCategory(); - } - - public function assertCreateCategory() - { - $this->categoryId = $this->app->createCategory(array( - 'name' => 'Category', - 'project_id' => $this->projectId, - )); - - $this->assertNotFalse($this->categoryId); - } - - public function assertThatCategoriesAreUnique() - { - $this->assertFalse($this->app->execute('createCategory', array( - 'name' => 'Category', - 'project_id' => $this->projectId, - ))); - } - - public function assertGetCategory() - { - $category = $this->app->getCategory($this->categoryId); - - $this->assertInternalType('array', $category); - $this->assertEquals($this->categoryId, $category['id']); - $this->assertEquals('Category', $category['name']); - $this->assertEquals($this->projectId, $category['project_id']); - } - - public function assertGetAllCategories() - { - $categories = $this->app->getAllCategories($this->projectId); - - $this->assertCount(1, $categories); - $this->assertEquals($this->categoryId, $categories[0]['id']); - $this->assertEquals('Category', $categories[0]['name']); - $this->assertEquals($this->projectId, $categories[0]['project_id']); - } - - public function assertCategoryUpdate() - { - $this->assertTrue($this->app->execute('updateCategory', array( - 'id' => $this->categoryId, - 'name' => 'Renamed category', - ))); - - $category = $this->app->getCategory($this->categoryId); - $this->assertEquals('Renamed category', $category['name']); - } - - public function assertRemoveCategory() - { - $this->assertTrue($this->app->removeCategory($this->categoryId)); - $this->assertFalse($this->app->removeCategory($this->categoryId)); - $this->assertFalse($this->app->removeCategory(1111)); - } -} diff --git a/tests/integration/ColumnProcedureTest.php b/tests/integration/ColumnProcedureTest.php new file mode 100644 index 00000000..fb6a27c3 --- /dev/null +++ b/tests/integration/ColumnProcedureTest.php @@ -0,0 +1,69 @@ +assertCreateTeamProject(); + $this->assertGetColumns(); + $this->assertUpdateColumn(); + $this->assertAddColumn(); + $this->assertRemoveColumn(); + $this->assertChangeColumnPosition(); + } + + public function assertGetColumns() + { + $this->columns = $this->app->getColumns($this->projectId); + $this->assertCount(4, $this->columns); + $this->assertEquals('Done', $this->columns[3]['title']); + } + + public function assertUpdateColumn() + { + $this->assertTrue($this->app->updateColumn($this->columns[3]['id'], 'Another column', 2)); + + $this->columns = $this->app->getColumns($this->projectId); + $this->assertEquals('Another column', $this->columns[3]['title']); + $this->assertEquals(2, $this->columns[3]['task_limit']); + } + + public function assertAddColumn() + { + $column_id = $this->app->addColumn($this->projectId, 'New column'); + $this->assertNotFalse($column_id); + $this->assertTrue($column_id > 0); + + $this->columns = $this->app->getColumns($this->projectId); + $this->assertCount(5, $this->columns); + $this->assertEquals('New column', $this->columns[4]['title']); + } + + public function assertRemoveColumn() + { + $this->assertTrue($this->app->removeColumn($this->columns[3]['id'])); + + $this->columns = $this->app->getColumns($this->projectId); + $this->assertCount(4, $this->columns); + } + + public function assertChangeColumnPosition() + { + $this->assertTrue($this->app->changeColumnPosition($this->projectId, $this->columns[0]['id'], 3)); + + $this->columns = $this->app->getColumns($this->projectId); + $this->assertEquals('Ready', $this->columns[0]['title']); + $this->assertEquals(1, $this->columns[0]['position']); + $this->assertEquals('Work in progress', $this->columns[1]['title']); + $this->assertEquals(2, $this->columns[1]['position']); + $this->assertEquals('Backlog', $this->columns[2]['title']); + $this->assertEquals(3, $this->columns[2]['position']); + $this->assertEquals('New column', $this->columns[3]['title']); + $this->assertEquals(4, $this->columns[3]['position']); + } +} diff --git a/tests/integration/ColumnTest.php b/tests/integration/ColumnTest.php deleted file mode 100644 index 5a81badc..00000000 --- a/tests/integration/ColumnTest.php +++ /dev/null @@ -1,69 +0,0 @@ -assertCreateTeamProject(); - $this->assertGetColumns(); - $this->assertUpdateColumn(); - $this->assertAddColumn(); - $this->assertRemoveColumn(); - $this->assertChangeColumnPosition(); - } - - public function assertGetColumns() - { - $this->columns = $this->app->getColumns($this->projectId); - $this->assertCount(4, $this->columns); - $this->assertEquals('Done', $this->columns[3]['title']); - } - - public function assertUpdateColumn() - { - $this->assertTrue($this->app->updateColumn($this->columns[3]['id'], 'Another column', 2)); - - $this->columns = $this->app->getColumns($this->projectId); - $this->assertEquals('Another column', $this->columns[3]['title']); - $this->assertEquals(2, $this->columns[3]['task_limit']); - } - - public function assertAddColumn() - { - $column_id = $this->app->addColumn($this->projectId, 'New column'); - $this->assertNotFalse($column_id); - $this->assertTrue($column_id > 0); - - $this->columns = $this->app->getColumns($this->projectId); - $this->assertCount(5, $this->columns); - $this->assertEquals('New column', $this->columns[4]['title']); - } - - public function assertRemoveColumn() - { - $this->assertTrue($this->app->removeColumn($this->columns[3]['id'])); - - $this->columns = $this->app->getColumns($this->projectId); - $this->assertCount(4, $this->columns); - } - - public function assertChangeColumnPosition() - { - $this->assertTrue($this->app->changeColumnPosition($this->projectId, $this->columns[0]['id'], 3)); - - $this->columns = $this->app->getColumns($this->projectId); - $this->assertEquals('Ready', $this->columns[0]['title']); - $this->assertEquals(1, $this->columns[0]['position']); - $this->assertEquals('Work in progress', $this->columns[1]['title']); - $this->assertEquals(2, $this->columns[1]['position']); - $this->assertEquals('Backlog', $this->columns[2]['title']); - $this->assertEquals(3, $this->columns[2]['position']); - $this->assertEquals('New column', $this->columns[3]['title']); - $this->assertEquals(4, $this->columns[3]['position']); - } -} diff --git a/tests/integration/CommentProcedureTest.php b/tests/integration/CommentProcedureTest.php new file mode 100644 index 00000000..881d938c --- /dev/null +++ b/tests/integration/CommentProcedureTest.php @@ -0,0 +1,63 @@ +assertCreateTeamProject(); + $this->assertCreateTask(); + $this->assertCreateComment(); + $this->assertUpdateComment(); + $this->assertGetAllComments(); + $this->assertRemoveComment(); + } + + public function assertCreateComment() + { + $this->commentId = $this->app->execute('createComment', array( + 'task_id' => $this->taskId, + 'user_id' => 1, + 'content' => 'foobar', + )); + + $this->assertNotFalse($this->commentId); + } + + public function assertGetComment() + { + $comment = $this->app->getComment($this->commentId); + $this->assertNotFalse($comment); + $this->assertNotEmpty($comment); + $this->assertEquals(1, $comment['user_id']); + $this->assertEquals('foobar', $comment['comment']); + } + + public function assertUpdateComment() + { + $this->assertTrue($this->app->execute('updateComment', array( + 'id' => $this->commentId, + 'content' => 'test', + ))); + + $comment = $this->app->getComment($this->commentId); + $this->assertEquals('test', $comment['comment']); + } + + public function assertGetAllComments() + { + $comments = $this->app->getAllComments($this->taskId); + $this->assertCount(1, $comments); + $this->assertEquals('test', $comments[0]['comment']); + } + + public function assertRemoveComment() + { + $this->assertTrue($this->app->removeComment($this->commentId)); + $this->assertFalse($this->app->removeComment($this->commentId)); + } +} diff --git a/tests/integration/CommentTest.php b/tests/integration/CommentTest.php deleted file mode 100644 index 34376838..00000000 --- a/tests/integration/CommentTest.php +++ /dev/null @@ -1,63 +0,0 @@ -assertCreateTeamProject(); - $this->assertCreateTask(); - $this->assertCreateComment(); - $this->assertUpdateComment(); - $this->assertGetAllComments(); - $this->assertRemoveComment(); - } - - public function assertCreateComment() - { - $this->commentId = $this->app->execute('createComment', array( - 'task_id' => $this->taskId, - 'user_id' => 1, - 'content' => 'foobar', - )); - - $this->assertNotFalse($this->commentId); - } - - public function assertGetComment() - { - $comment = $this->app->getComment($this->commentId); - $this->assertNotFalse($comment); - $this->assertNotEmpty($comment); - $this->assertEquals(1, $comment['user_id']); - $this->assertEquals('foobar', $comment['comment']); - } - - public function assertUpdateComment() - { - $this->assertTrue($this->app->execute('updateComment', array( - 'id' => $this->commentId, - 'content' => 'test', - ))); - - $comment = $this->app->getComment($this->commentId); - $this->assertEquals('test', $comment['comment']); - } - - public function assertGetAllComments() - { - $comments = $this->app->getAllComments($this->taskId); - $this->assertCount(1, $comments); - $this->assertEquals('test', $comments[0]['comment']); - } - - public function assertRemoveComment() - { - $this->assertTrue($this->app->removeComment($this->commentId)); - $this->assertFalse($this->app->removeComment($this->commentId)); - } -} diff --git a/tests/integration/GroupMemberProcedureTest.php b/tests/integration/GroupMemberProcedureTest.php new file mode 100644 index 00000000..fe243533 --- /dev/null +++ b/tests/integration/GroupMemberProcedureTest.php @@ -0,0 +1,53 @@ +assertCreateGroups(); + $this->assertCreateUser(); + $this->assertAddMember(); + $this->assertGetMembers(); + $this->assertIsGroupMember(); + $this->assertGetGroups(); + $this->assertRemove(); + } + + public function assertAddMember() + { + $this->assertTrue($this->app->addGroupMember($this->groupId1, $this->userId)); + } + + public function assertGetMembers() + { + $members = $this->app->getGroupMembers($this->groupId1); + $this->assertCount(1, $members); + $this->assertEquals($this->username, $members[0]['username']); + } + + public function assertIsGroupMember() + { + $this->assertTrue($this->app->isGroupMember($this->groupId1, $this->userId)); + $this->assertFalse($this->app->isGroupMember($this->groupId1, $this->adminUserId)); + } + + public function assertGetGroups() + { + $groups = $this->app->getMemberGroups($this->userId); + $this->assertCount(1, $groups); + $this->assertEquals($this->groupId1, $groups[0]['id']); + $this->assertEquals($this->groupName1, $groups[0]['name']); + } + + public function assertRemove() + { + $this->assertTrue($this->app->removeGroupMember($this->groupId1, $this->userId)); + $this->assertFalse($this->app->isGroupMember($this->groupId1, $this->userId)); + } +} diff --git a/tests/integration/GroupMemberTest.php b/tests/integration/GroupMemberTest.php deleted file mode 100644 index f79499a4..00000000 --- a/tests/integration/GroupMemberTest.php +++ /dev/null @@ -1,53 +0,0 @@ -assertCreateGroups(); - $this->assertCreateUser(); - $this->assertAddMember(); - $this->assertGetMembers(); - $this->assertIsGroupMember(); - $this->assertGetGroups(); - $this->assertRemove(); - } - - public function assertAddMember() - { - $this->assertTrue($this->app->addGroupMember($this->groupId1, $this->userId)); - } - - public function assertGetMembers() - { - $members = $this->app->getGroupMembers($this->groupId1); - $this->assertCount(1, $members); - $this->assertEquals($this->username, $members[0]['username']); - } - - public function assertIsGroupMember() - { - $this->assertTrue($this->app->isGroupMember($this->groupId1, $this->userId)); - $this->assertFalse($this->app->isGroupMember($this->groupId1, $this->adminUserId)); - } - - public function assertGetGroups() - { - $groups = $this->app->getMemberGroups($this->userId); - $this->assertCount(1, $groups); - $this->assertEquals($this->groupId1, $groups[0]['id']); - $this->assertEquals($this->groupName1, $groups[0]['name']); - } - - public function assertRemove() - { - $this->assertTrue($this->app->removeGroupMember($this->groupId1, $this->userId)); - $this->assertFalse($this->app->isGroupMember($this->groupId1, $this->userId)); - } -} diff --git a/tests/integration/GroupProcedureTest.php b/tests/integration/GroupProcedureTest.php new file mode 100644 index 00000000..610c121d --- /dev/null +++ b/tests/integration/GroupProcedureTest.php @@ -0,0 +1,50 @@ +assertCreateGroups(); + $this->assertGetAllGroups(); + $this->assertGetGroup(); + $this->assertUpdateGroup(); + $this->assertRemove(); + } + + public function assertGetAllGroups() + { + $groups = $this->app->getAllGroups(); + $this->assertNotEmpty($groups); + $this->assertArrayHasKey('name', $groups[0]); + $this->assertArrayHasKey('external_id', $groups[0]); + } + + public function assertGetGroup() + { + $group = $this->app->getGroup($this->groupId1); + $this->assertNotEmpty($group); + $this->assertEquals($this->groupName1, $group['name']); + $this->assertEquals('', $group['external_id']); + } + + public function assertUpdateGroup() + { + $this->assertTrue($this->app->updateGroup(array( + 'group_id' => $this->groupId2, + 'name' => 'My Group C', + 'external_id' => 'something else', + ))); + + $group = $this->app->getGroup($this->groupId2); + $this->assertNotEmpty($group); + $this->assertEquals('My Group C', $group['name']); + $this->assertEquals('something else', $group['external_id']); + } + + public function assertRemove() + { + $this->assertTrue($this->app->removeGroup($this->groupId1)); + } +} diff --git a/tests/integration/GroupTest.php b/tests/integration/GroupTest.php deleted file mode 100644 index ffcd7a71..00000000 --- a/tests/integration/GroupTest.php +++ /dev/null @@ -1,50 +0,0 @@ -assertCreateGroups(); - $this->assertGetAllGroups(); - $this->assertGetGroup(); - $this->assertUpdateGroup(); - $this->assertRemove(); - } - - public function assertGetAllGroups() - { - $groups = $this->app->getAllGroups(); - $this->assertNotEmpty($groups); - $this->assertArrayHasKey('name', $groups[0]); - $this->assertArrayHasKey('external_id', $groups[0]); - } - - public function assertGetGroup() - { - $group = $this->app->getGroup($this->groupId1); - $this->assertNotEmpty($group); - $this->assertEquals($this->groupName1, $group['name']); - $this->assertEquals('', $group['external_id']); - } - - public function assertUpdateGroup() - { - $this->assertTrue($this->app->updateGroup(array( - 'group_id' => $this->groupId2, - 'name' => 'My Group C', - 'external_id' => 'something else', - ))); - - $group = $this->app->getGroup($this->groupId2); - $this->assertNotEmpty($group); - $this->assertEquals('My Group C', $group['name']); - $this->assertEquals('something else', $group['external_id']); - } - - public function assertRemove() - { - $this->assertTrue($this->app->removeGroup($this->groupId1)); - } -} diff --git a/tests/integration/LinkProcedureTest.php b/tests/integration/LinkProcedureTest.php new file mode 100644 index 00000000..fb07e694 --- /dev/null +++ b/tests/integration/LinkProcedureTest.php @@ -0,0 +1,70 @@ +app->getAllLinks(); + $this->assertNotEmpty($links); + $this->assertArrayHasKey('id', $links[0]); + $this->assertArrayHasKey('label', $links[0]); + $this->assertArrayHasKey('opposite_id', $links[0]); + } + + public function testGetOppositeLink() + { + $link = $this->app->getOppositeLinkId(1); + $this->assertEquals(1, $link); + + $link = $this->app->getOppositeLinkId(2); + $this->assertEquals(3, $link); + } + + public function testGetLinkByLabel() + { + $link = $this->app->getLinkByLabel('blocks'); + $this->assertNotEmpty($link); + $this->assertEquals(2, $link['id']); + $this->assertEquals(3, $link['opposite_id']); + } + + public function testGetLinkById() + { + $link = $this->app->getLinkById(4); + $this->assertNotEmpty($link); + $this->assertEquals(4, $link['id']); + $this->assertEquals(5, $link['opposite_id']); + $this->assertEquals('duplicates', $link['label']); + } + + public function testCreateLink() + { + $link_id = $this->app->createLink(array('label' => 'test')); + $this->assertNotFalse($link_id); + $this->assertInternalType('int', $link_id); + + $link_id = $this->app->createLink(array('label' => 'foo', 'opposite_label' => 'bar')); + $this->assertNotFalse($link_id); + $this->assertInternalType('int', $link_id); + } + + public function testUpdateLink() + { + $link1 = $this->app->getLinkByLabel('bar'); + $this->assertNotEmpty($link1); + + $link2 = $this->app->getLinkByLabel('test'); + $this->assertNotEmpty($link2); + + $this->assertNotFalse($this->app->updateLink($link1['id'], $link2['id'], 'my link')); + + $link = $this->app->getLinkById($link1['id']); + $this->assertNotEmpty($link); + $this->assertEquals($link2['id'], $link['opposite_id']); + $this->assertEquals('my link', $link['label']); + + $this->assertTrue($this->app->removeLink($link1['id'])); + } +} diff --git a/tests/integration/LinkTest.php b/tests/integration/LinkTest.php deleted file mode 100644 index 16b16e50..00000000 --- a/tests/integration/LinkTest.php +++ /dev/null @@ -1,70 +0,0 @@ -app->getAllLinks(); - $this->assertNotEmpty($links); - $this->assertArrayHasKey('id', $links[0]); - $this->assertArrayHasKey('label', $links[0]); - $this->assertArrayHasKey('opposite_id', $links[0]); - } - - public function testGetOppositeLink() - { - $link = $this->app->getOppositeLinkId(1); - $this->assertEquals(1, $link); - - $link = $this->app->getOppositeLinkId(2); - $this->assertEquals(3, $link); - } - - public function testGetLinkByLabel() - { - $link = $this->app->getLinkByLabel('blocks'); - $this->assertNotEmpty($link); - $this->assertEquals(2, $link['id']); - $this->assertEquals(3, $link['opposite_id']); - } - - public function testGetLinkById() - { - $link = $this->app->getLinkById(4); - $this->assertNotEmpty($link); - $this->assertEquals(4, $link['id']); - $this->assertEquals(5, $link['opposite_id']); - $this->assertEquals('duplicates', $link['label']); - } - - public function testCreateLink() - { - $link_id = $this->app->createLink(array('label' => 'test')); - $this->assertNotFalse($link_id); - $this->assertInternalType('int', $link_id); - - $link_id = $this->app->createLink(array('label' => 'foo', 'opposite_label' => 'bar')); - $this->assertNotFalse($link_id); - $this->assertInternalType('int', $link_id); - } - - public function testUpdateLink() - { - $link1 = $this->app->getLinkByLabel('bar'); - $this->assertNotEmpty($link1); - - $link2 = $this->app->getLinkByLabel('test'); - $this->assertNotEmpty($link2); - - $this->assertNotFalse($this->app->updateLink($link1['id'], $link2['id'], 'my link')); - - $link = $this->app->getLinkById($link1['id']); - $this->assertNotEmpty($link); - $this->assertEquals($link2['id'], $link['opposite_id']); - $this->assertEquals('my link', $link['label']); - - $this->assertTrue($this->app->removeLink($link1['id'])); - } -} diff --git a/tests/integration/MeProcedureTest.php b/tests/integration/MeProcedureTest.php new file mode 100644 index 00000000..2106419c --- /dev/null +++ b/tests/integration/MeProcedureTest.php @@ -0,0 +1,68 @@ +assertGetMe(); + $this->assertCreateMyPrivateProject(); + $this->assertGetMyProjectsList(); + $this->assertGetMyProjects(); + $this->assertCreateTask(); + $this->assertGetMyDashboard(); + $this->assertGetMyActivityStream(); + } + + public function assertGetMe() + { + $profile = $this->user->getMe(); + $this->assertEquals('user', $profile['username']); + $this->assertEquals('app-user', $profile['role']); + } + + public function assertCreateMyPrivateProject() + { + $this->projectId = $this->user->createMyPrivateProject($this->projectName); + $this->assertNotFalse($this->projectId); + } + + public function assertGetMyProjectsList() + { + $projects = $this->user->getMyProjectsList(); + $this->assertNotEmpty($projects); + $this->assertEquals($this->projectName, $projects[$this->projectId]); + } + + public function assertGetMyProjects() + { + $projects = $this->user->getMyProjects(); + $this->assertNotEmpty($projects); + } + + public function assertCreateTask() + { + $taskId = $this->user->createTask(array('title' => 'My task', 'project_id' => $this->projectId, 'owner_id' => $this->userUserId)); + $this->assertNotFalse($taskId); + } + + public function assertGetMyDashboard() + { + $dashboard = $this->user->getMyDashboard(); + $this->assertNotEmpty($dashboard); + $this->assertArrayHasKey('projects', $dashboard); + $this->assertArrayHasKey('tasks', $dashboard); + $this->assertArrayHasKey('subtasks', $dashboard); + $this->assertNotEmpty($dashboard['projects']); + $this->assertNotEmpty($dashboard['tasks']); + } + + public function assertGetMyActivityStream() + { + $activity = $this->user->getMyActivityStream(); + $this->assertNotEmpty($activity); + } +} diff --git a/tests/integration/MeTest.php b/tests/integration/MeTest.php deleted file mode 100644 index 047ebf85..00000000 --- a/tests/integration/MeTest.php +++ /dev/null @@ -1,73 +0,0 @@ -assertGetMe(); - $this->assertCreateMyPrivateProject(); - $this->assertGetMyProjectsList(); - $this->assertGetMyProjects(); - $this->assertCreateTask(); - $this->assertGetMyDashboard(); - $this->assertGetMyActivityStream(); - } - - public function assertGetMe() - { - $profile = $this->user->getMe(); - $this->assertEquals('user', $profile['username']); - $this->assertEquals('app-user', $profile['role']); - } - - public function assertCreateMyPrivateProject() - { - $this->projectId = $this->user->createMyPrivateProject($this->projectName); - $this->assertNotFalse($this->projectId); - } - - public function assertGetMyProjectsList() - { - $projects = $this->user->getMyProjectsList(); - $this->assertNotEmpty($projects); - $this->assertEquals($this->projectName, $projects[$this->projectId]); - } - - public function assertGetMyProjects() - { - $projects = $this->user->getMyProjects(); - $this->assertNotEmpty($projects); - $this->assertCount(1, $projects); - $this->assertEquals($this->projectName, $projects[0]['name']); - $this->assertNotEmpty($projects[0]['url']['calendar']); - $this->assertNotEmpty($projects[0]['url']['board']); - $this->assertNotEmpty($projects[0]['url']['list']); - } - - public function assertCreateTask() - { - $taskId = $this->user->createTask(array('title' => 'My task', 'project_id' => $this->projectId, 'owner_id' => $this->userUserId)); - $this->assertNotFalse($taskId); - } - - public function assertGetMyDashboard() - { - $dashboard = $this->user->getMyDashboard(); - $this->assertNotEmpty($dashboard); - $this->assertArrayHasKey('projects', $dashboard); - $this->assertArrayHasKey('tasks', $dashboard); - $this->assertArrayHasKey('subtasks', $dashboard); - $this->assertNotEmpty($dashboard['projects']); - $this->assertNotEmpty($dashboard['tasks']); - } - - public function assertGetMyActivityStream() - { - $activity = $this->user->getMyActivityStream(); - $this->assertNotEmpty($activity); - } -} diff --git a/tests/integration/OverdueTaskProcedureTest.php b/tests/integration/OverdueTaskProcedureTest.php new file mode 100644 index 00000000..65f52301 --- /dev/null +++ b/tests/integration/OverdueTaskProcedureTest.php @@ -0,0 +1,43 @@ +assertCreateTeamProject(); + $this->assertCreateOverdueTask(); + $this->assertGetOverdueTasksByProject(); + $this->assertGetOverdueTasks(); + } + + public function assertCreateOverdueTask() + { + $this->assertNotFalse($this->app->createTask(array( + 'title' => 'overdue task', + 'project_id' => $this->projectId, + 'date_due' => date('Y-m-d', strtotime('-2days')), + ))); + } + + public function assertGetOverdueTasksByProject() + { + $tasks = $this->app->getOverdueTasksByProject($this->projectId); + $this->assertNotEmpty($tasks); + $this->assertCount(1, $tasks); + $this->assertEquals('overdue task', $tasks[0]['title']); + $this->assertEquals($this->projectName, $tasks[0]['project_name']); + } + + public function assertGetOverdueTasks() + { + $tasks = $this->app->getOverdueTasks(); + $this->assertNotEmpty($tasks); + $this->assertCount(1, $tasks); + $this->assertEquals('overdue task', $tasks[0]['title']); + $this->assertEquals($this->projectName, $tasks[0]['project_name']); + } +} diff --git a/tests/integration/OverdueTaskTest.php b/tests/integration/OverdueTaskTest.php deleted file mode 100644 index 1dea5030..00000000 --- a/tests/integration/OverdueTaskTest.php +++ /dev/null @@ -1,43 +0,0 @@ -assertCreateTeamProject(); - $this->assertCreateOverdueTask(); - $this->assertGetOverdueTasksByProject(); - $this->assertGetOverdueTasks(); - } - - public function assertCreateOverdueTask() - { - $this->assertNotFalse($this->app->createTask(array( - 'title' => 'overdue task', - 'project_id' => $this->projectId, - 'date_due' => date('Y-m-d', strtotime('-2days')), - ))); - } - - public function assertGetOverdueTasksByProject() - { - $tasks = $this->app->getOverdueTasksByProject($this->projectId); - $this->assertNotEmpty($tasks); - $this->assertCount(1, $tasks); - $this->assertEquals('overdue task', $tasks[0]['title']); - $this->assertEquals($this->projectName, $tasks[0]['project_name']); - } - - public function assertGetOverdueTasks() - { - $tasks = $this->app->getOverdueTasks(); - $this->assertNotEmpty($tasks); - $this->assertCount(1, $tasks); - $this->assertEquals('overdue task', $tasks[0]['title']); - $this->assertEquals($this->projectName, $tasks[0]['project_name']); - } -} diff --git a/tests/integration/ProcedureAuthorizationTest.php b/tests/integration/ProcedureAuthorizationTest.php new file mode 100644 index 00000000..a63e9d8c --- /dev/null +++ b/tests/integration/ProcedureAuthorizationTest.php @@ -0,0 +1,306 @@ +setExpectedException('JsonRPC\Exception\AccessDeniedException'); + $this->app->getMe(); + } + + public function testUserCredentialDoNotHaveAccessToAdminProcedures() + { + $this->setExpectedException('JsonRPC\Exception\AccessDeniedException'); + $this->user->getUser(1); + } + + public function testManagerCredentialDoNotHaveAccessToAdminProcedures() + { + $this->setExpectedException('JsonRPC\Exception\AccessDeniedException'); + $this->user->getAllProjects(); + } + + public function testUserCredentialDoNotHaveAccessToManagerProcedures() + { + $this->setExpectedException('JsonRPC\Exception\AccessDeniedException'); + $this->user->createProject('Team project creation are only for app managers'); + } + + public function testAppManagerCanCreateTeamProject() + { + $this->assertNotFalse($this->manager->createProject('Team project created by app manager')); + } + + public function testAdminManagerCanCreateTeamProject() + { + $projectId = $this->admin->createProject('Team project created by admin'); + $this->assertNotFalse($projectId); + + $this->setExpectedException('JsonRPC\Exception\AccessDeniedException'); + $this->assertNotNull($this->manager->getProjectById($projectId)); + } + + public function testProjectManagerCanUpdateHisProject() + { + $projectId = $this->manager->createProject(array( + 'name' => 'Team project can be updated', + 'owner_id' => $this->managerUserId, + )); + + $this->assertNotFalse($projectId); + $this->assertEquals('project-manager', $this->app->getProjectUserRole($projectId, $this->managerUserId)); + $this->assertNotNull($this->manager->getProjectById($projectId)); + + $this->assertTrue($this->manager->updateProject($projectId, 'My team project have been updated')); + } + + public function testProjectAuthorizationForbidden() + { + $projectId = $this->manager->createProject('A team project without members'); + $this->assertNotFalse($projectId); + + $this->setExpectedException('JsonRPC\Exception\AccessDeniedException'); + $this->user->getProjectById($projectId); + } + + public function testProjectAuthorizationGranted() + { + $projectId = $this->manager->createProject(array( + 'name' => 'A team project with members', + 'owner_id' => $this->managerUserId, + )); + + $this->assertNotFalse($projectId); + + $this->assertTrue($this->manager->addProjectUser($projectId, $this->userUserId)); + $this->assertNotNull($this->user->getProjectById($projectId)); + } + + public function testActionAuthorizationForbidden() + { + $projectId = $this->manager->createProject(array( + 'name' => 'Test Project', + 'owner_id' => $this->managerUserId, + )); + + $this->assertNotFalse($projectId); + + $actionId = $this->manager->createAction($projectId, 'task.move.column', '\Kanboard\Action\TaskCloseColumn', array('column_id' => 1)); + $this->assertNotFalse($actionId); + + $this->setExpectedException('JsonRPC\Exception\AccessDeniedException'); + $this->user->removeAction($projectId); + } + + public function testActionAuthorizationForbiddenBecauseNotProjectManager() + { + $projectId = $this->manager->createProject(array( + 'name' => 'Test Project', + 'owner_id' => $this->managerUserId, + )); + + $this->assertNotFalse($projectId); + + $actionId = $this->manager->createAction($projectId, 'task.move.column', '\Kanboard\Action\TaskCloseColumn', array('column_id' => 1)); + $this->assertNotFalse($actionId); + + $this->assertTrue($this->manager->addProjectUser($projectId, $this->userUserId, 'project-member')); + + $this->setExpectedException('JsonRPC\Exception\AccessDeniedException'); + $this->user->removeAction($actionId); + } + + public function testActionAuthorizationGranted() + { + $projectId = $this->manager->createProject(array( + 'name' => 'Test Project', + 'owner_id' => $this->managerUserId, + )); + + $this->assertNotFalse($projectId); + + $actionId = $this->manager->createAction($projectId, 'task.move.column', '\Kanboard\Action\TaskCloseColumn', array('column_id' => 1)); + $this->assertNotFalse($actionId); + + $this->assertTrue($this->manager->addProjectUser($projectId, $this->userUserId, 'project-manager')); + $this->assertTrue($this->user->removeAction($actionId)); + } + + public function testCategoryAuthorizationForbidden() + { + $projectId = $this->manager->createProject(array( + 'name' => 'Test Project', + 'owner_id' => $this->managerUserId, + )); + + $this->assertNotFalse($projectId); + + $categoryId = $this->manager->createCategory($projectId, 'Test'); + $this->assertNotFalse($categoryId); + + $this->setExpectedException('JsonRPC\Exception\AccessDeniedException'); + $this->user->removeCategory($categoryId); + } + + public function testCategoryAuthorizationForbiddenBecauseNotProjectManager() + { + $projectId = $this->manager->createProject(array( + 'name' => 'Test Project', + 'owner_id' => $this->managerUserId, + )); + + $this->assertNotFalse($projectId); + + $categoryId = $this->manager->createCategory($projectId, 'Test'); + $this->assertNotFalse($categoryId); + + $this->assertTrue($this->manager->addProjectUser($projectId, $this->userUserId, 'project-member')); + $this->setExpectedException('JsonRPC\Exception\AccessDeniedException'); + $this->user->removeCategory($categoryId); + } + + public function testCategoryAuthorizationGranted() + { + $projectId = $this->manager->createProject(array( + 'name' => 'Test Project', + 'owner_id' => $this->managerUserId, + )); + + $this->assertNotFalse($projectId); + + $categoryId = $this->manager->createCategory($projectId, 'Test'); + $this->assertNotFalse($categoryId); + + $this->assertTrue($this->manager->addProjectUser($projectId, $this->userUserId, 'project-manager')); + $this->assertTrue($this->user->removeCategory($categoryId)); + } + + public function testColumnAuthorizationForbidden() + { + $projectId = $this->manager->createProject(array( + 'name' => 'Test Project', + 'owner_id' => $this->managerUserId, + )); + + $this->assertNotFalse($projectId); + + $columnId = $this->manager->addColumn($projectId, 'Test'); + $this->assertNotFalse($columnId); + + $this->setExpectedException('JsonRPC\Exception\AccessDeniedException'); + $this->user->removeColumn($columnId); + } + + public function testColumnAuthorizationForbiddenBecauseNotProjectManager() + { + $projectId = $this->manager->createProject(array( + 'name' => 'Test Project', + 'owner_id' => $this->managerUserId, + )); + + $this->assertNotFalse($projectId); + + $columnId = $this->manager->addColumn($projectId, 'Test'); + $this->assertNotFalse($columnId); + + $this->assertTrue($this->manager->addProjectUser($projectId, $this->userUserId, 'project-member')); + $this->setExpectedException('JsonRPC\Exception\AccessDeniedException'); + $this->user->removeColumn($columnId); + } + + public function testColumnAuthorizationGranted() + { + $projectId = $this->manager->createProject(array( + 'name' => 'Test Project', + 'owner_id' => $this->managerUserId, + )); + + $this->assertNotFalse($projectId); + + $columnId = $this->manager->addColumn($projectId, 'Test'); + $this->assertNotFalse($columnId); + + $this->assertTrue($this->manager->addProjectUser($projectId, $this->userUserId, 'project-manager')); + $this->assertTrue($this->user->removeColumn($columnId)); + } + + public function testCommentAuthorizationForbidden() + { + $projectId = $this->manager->createProject(array( + 'name' => 'Test Project', + 'owner_id' => $this->managerUserId, + )); + + $this->assertNotFalse($projectId); + $this->assertTrue($this->manager->addProjectUser($projectId, $this->userUserId, 'project-viewer')); + + $taskId = $this->manager->createTask('My Task', $projectId); + $this->assertNotFalse($taskId); + + $commentId = $this->manager->createComment($taskId, $this->userUserId, 'My comment'); + $this->assertNotFalse($commentId); + + $this->setExpectedException('JsonRPC\Exception\AccessDeniedException'); + $this->user->updateComment($commentId, 'something else'); + } + + public function testCommentAuthorizationGranted() + { + $projectId = $this->manager->createProject(array( + 'name' => 'Test Project', + 'owner_id' => $this->managerUserId, + )); + + $this->assertNotFalse($projectId); + $this->assertTrue($this->manager->addProjectUser($projectId, $this->userUserId, 'project-member')); + + $taskId = $this->user->createTask('My Task', $projectId); + $this->assertNotFalse($taskId); + + $commentId = $this->user->createComment($taskId, $this->userUserId, 'My comment'); + $this->assertNotFalse($commentId); + + $this->assertTrue($this->user->updateComment($commentId, 'something else')); + } + + public function testSubtaskAuthorizationForbidden() + { + $projectId = $this->manager->createProject(array( + 'name' => 'Test Project', + 'owner_id' => $this->managerUserId, + )); + + $this->assertNotFalse($projectId); + $this->assertTrue($this->manager->addProjectUser($projectId, $this->userUserId, 'project-viewer')); + + $taskId = $this->manager->createTask('My Task', $projectId); + $this->assertNotFalse($taskId); + + $subtaskId = $this->manager->createSubtask($taskId, 'My subtask'); + $this->assertNotFalse($subtaskId); + + $this->setExpectedException('JsonRPC\Exception\AccessDeniedException'); + $this->user->removeSubtask($subtaskId); + } + + public function testSubtaskAuthorizationGranted() + { + $projectId = $this->manager->createProject(array( + 'name' => 'Test Project', + 'owner_id' => $this->managerUserId, + )); + + $this->assertNotFalse($projectId); + $this->assertTrue($this->manager->addProjectUser($projectId, $this->userUserId, 'project-member')); + + $taskId = $this->user->createTask('My Task', $projectId); + $this->assertNotFalse($taskId); + + $subtaskId = $this->manager->createSubtask($taskId, 'My subtask'); + $this->assertNotFalse($subtaskId); + + $this->assertTrue($this->user->removeSubtask($subtaskId)); + } +} diff --git a/tests/integration/ProjectPermissionProcedureTest.php b/tests/integration/ProjectPermissionProcedureTest.php new file mode 100644 index 00000000..74313dc4 --- /dev/null +++ b/tests/integration/ProjectPermissionProcedureTest.php @@ -0,0 +1,89 @@ +assertCreateTeamProject(); + $this->assertCreateGroups(); + $this->assertCreateUser(); + + $this->assertAddProjectUser(); + $this->assertGetProjectUsers(); + $this->assertGetAssignableUsers(); + $this->assertChangeProjectUserRole(); + $this->assertRemoveProjectUser(); + + $this->assertAddProjectGroup(); + $this->assertGetProjectUsers(); + $this->assertGetAssignableUsers(); + $this->assertChangeProjectGroupRole(); + $this->assertRemoveProjectGroup(); + } + + public function assertAddProjectUser() + { + $this->assertTrue($this->app->addProjectUser($this->projectId, $this->userId)); + } + + public function assertGetProjectUsers() + { + $members = $this->app->getProjectUsers($this->projectId); + $this->assertCount(1, $members); + $this->assertArrayHasKey($this->userId, $members); + $this->assertEquals($this->username, $members[$this->userId]); + } + + public function assertGetAssignableUsers() + { + $members = $this->app->getAssignableUsers($this->projectId); + $this->assertCount(1, $members); + $this->assertArrayHasKey($this->userId, $members); + $this->assertEquals($this->username, $members[$this->userId]); + } + + public function assertChangeProjectUserRole() + { + $this->assertTrue($this->app->changeProjectUserRole($this->projectId, $this->userId, 'project-viewer')); + + $members = $this->app->getAssignableUsers($this->projectId); + $this->assertCount(0, $members); + } + + public function assertRemoveProjectUser() + { + $this->assertTrue($this->app->removeProjectUser($this->projectId, $this->userId)); + + $members = $this->app->getProjectUsers($this->projectId); + $this->assertCount(0, $members); + } + + public function assertAddProjectGroup() + { + $this->assertTrue($this->app->addGroupMember($this->groupId1, $this->userId)); + $this->assertTrue($this->app->addProjectGroup($this->projectId, $this->groupId1)); + } + + public function assertChangeProjectGroupRole() + { + $this->assertTrue($this->app->changeProjectGroupRole($this->projectId, $this->groupId1, 'project-viewer')); + + $members = $this->app->getAssignableUsers($this->projectId); + $this->assertCount(0, $members); + } + + public function assertRemoveProjectGroup() + { + $this->assertTrue($this->app->removeProjectGroup($this->projectId, $this->groupId1)); + + $members = $this->app->getProjectUsers($this->projectId); + $this->assertCount(0, $members); + } +} diff --git a/tests/integration/ProjectPermissionTest.php b/tests/integration/ProjectPermissionTest.php deleted file mode 100644 index 3ceda07d..00000000 --- a/tests/integration/ProjectPermissionTest.php +++ /dev/null @@ -1,89 +0,0 @@ -assertCreateTeamProject(); - $this->assertCreateGroups(); - $this->assertCreateUser(); - - $this->assertAddProjectUser(); - $this->assertGetProjectUsers(); - $this->assertGetAssignableUsers(); - $this->assertChangeProjectUserRole(); - $this->assertRemoveProjectUser(); - - $this->assertAddProjectGroup(); - $this->assertGetProjectUsers(); - $this->assertGetAssignableUsers(); - $this->assertChangeProjectGroupRole(); - $this->assertRemoveProjectGroup(); - } - - public function assertAddProjectUser() - { - $this->assertTrue($this->app->addProjectUser($this->projectId, $this->userId)); - } - - public function assertGetProjectUsers() - { - $members = $this->app->getProjectUsers($this->projectId); - $this->assertCount(1, $members); - $this->assertArrayHasKey($this->userId, $members); - $this->assertEquals($this->username, $members[$this->userId]); - } - - public function assertGetAssignableUsers() - { - $members = $this->app->getAssignableUsers($this->projectId); - $this->assertCount(1, $members); - $this->assertArrayHasKey($this->userId, $members); - $this->assertEquals($this->username, $members[$this->userId]); - } - - public function assertChangeProjectUserRole() - { - $this->assertTrue($this->app->changeProjectUserRole($this->projectId, $this->userId, 'project-viewer')); - - $members = $this->app->getAssignableUsers($this->projectId); - $this->assertCount(0, $members); - } - - public function assertRemoveProjectUser() - { - $this->assertTrue($this->app->removeProjectUser($this->projectId, $this->userId)); - - $members = $this->app->getProjectUsers($this->projectId); - $this->assertCount(0, $members); - } - - public function assertAddProjectGroup() - { - $this->assertTrue($this->app->addGroupMember($this->groupId1, $this->userId)); - $this->assertTrue($this->app->addProjectGroup($this->projectId, $this->groupId1)); - } - - public function assertChangeProjectGroupRole() - { - $this->assertTrue($this->app->changeProjectGroupRole($this->projectId, $this->groupId1, 'project-viewer')); - - $members = $this->app->getAssignableUsers($this->projectId); - $this->assertCount(0, $members); - } - - public function assertRemoveProjectGroup() - { - $this->assertTrue($this->app->removeProjectGroup($this->projectId, $this->groupId1)); - - $members = $this->app->getProjectUsers($this->projectId); - $this->assertCount(0, $members); - } -} diff --git a/tests/integration/ProjectProcedureTest.php b/tests/integration/ProjectProcedureTest.php new file mode 100644 index 00000000..1ebd48ae --- /dev/null +++ b/tests/integration/ProjectProcedureTest.php @@ -0,0 +1,89 @@ +assertCreateTeamProject(); + $this->assertGetProjectById(); + $this->assertGetProjectByName(); + $this->assertGetAllProjects(); + $this->assertUpdateProject(); + $this->assertGetProjectActivity(); + $this->assertGetProjectsActivity(); + $this->assertEnableDisableProject(); + $this->assertEnableDisablePublicAccess(); + $this->assertRemoveProject(); + } + + public function assertGetProjectById() + { + $project = $this->app->getProjectById($this->projectId); + $this->assertNotNull($project); + $this->assertEquals($this->projectName, $project['name']); + $this->assertEquals('Description', $project['description']); + } + + public function assertGetProjectByName() + { + $project = $this->app->getProjectByName($this->projectName); + $this->assertNotNull($project); + $this->assertEquals($this->projectId, $project['id']); + $this->assertEquals($this->projectName, $project['name']); + $this->assertEquals('Description', $project['description']); + } + + public function assertGetAllProjects() + { + $projects = $this->app->getAllProjects(); + $this->assertNotEmpty($projects); + } + + public function assertGetProjectActivity() + { + $activities = $this->app->getProjectActivity($this->projectId); + $this->assertInternalType('array', $activities); + $this->assertCount(0, $activities); + } + + public function assertGetProjectsActivity() + { + $activities = $this->app->getProjectActivities(array('project_ids' => array($this->projectId))); + $this->assertInternalType('array', $activities); + $this->assertCount(0, $activities); + } + + public function assertUpdateProject() + { + $this->assertTrue($this->app->updateProject(array('project_id' => $this->projectId, 'name' => 'test', 'description' => 'test'))); + + $project = $this->app->getProjectById($this->projectId); + $this->assertNotNull($project); + $this->assertEquals('test', $project['name']); + $this->assertEquals('test', $project['description']); + + $this->assertTrue($this->app->updateProject(array('project_id' => $this->projectId, 'name' => $this->projectName))); + } + + public function assertEnableDisableProject() + { + $this->assertTrue($this->app->disableProject($this->projectId)); + $this->assertTrue($this->app->enableProject($this->projectId)); + } + + public function assertEnableDisablePublicAccess() + { + $this->assertTrue($this->app->disableProjectPublicAccess($this->projectId)); + $this->assertTrue($this->app->enableProjectPublicAccess($this->projectId)); + } + + public function assertRemoveProject() + { + $this->assertTrue($this->app->removeProject($this->projectId)); + $this->assertNull($this->app->getProjectById($this->projectId)); + } +} diff --git a/tests/integration/ProjectTest.php b/tests/integration/ProjectTest.php deleted file mode 100644 index 50d4fc53..00000000 --- a/tests/integration/ProjectTest.php +++ /dev/null @@ -1,89 +0,0 @@ -assertCreateTeamProject(); - $this->assertGetProjectById(); - $this->assertGetProjectByName(); - $this->assertGetAllProjects(); - $this->assertUpdateProject(); - $this->assertGetProjectActivity(); - $this->assertGetProjectsActivity(); - $this->assertEnableDisableProject(); - $this->assertEnableDisablePublicAccess(); - $this->assertRemoveProject(); - } - - public function assertGetProjectById() - { - $project = $this->app->getProjectById($this->projectId); - $this->assertNotNull($project); - $this->assertEquals($this->projectName, $project['name']); - $this->assertEquals('Description', $project['description']); - } - - public function assertGetProjectByName() - { - $project = $this->app->getProjectByName($this->projectName); - $this->assertNotNull($project); - $this->assertEquals($this->projectId, $project['id']); - $this->assertEquals($this->projectName, $project['name']); - $this->assertEquals('Description', $project['description']); - } - - public function assertGetAllProjects() - { - $projects = $this->app->getAllProjects(); - $this->assertNotEmpty($projects); - } - - public function assertGetProjectActivity() - { - $activities = $this->app->getProjectActivity($this->projectId); - $this->assertInternalType('array', $activities); - $this->assertCount(0, $activities); - } - - public function assertGetProjectsActivity() - { - $activities = $this->app->getProjectActivities(array('project_ids' => array($this->projectId))); - $this->assertInternalType('array', $activities); - $this->assertCount(0, $activities); - } - - public function assertUpdateProject() - { - $this->assertTrue($this->app->updateProject(array('project_id' => $this->projectId, 'name' => 'test', 'description' => 'test'))); - - $project = $this->app->getProjectById($this->projectId); - $this->assertNotNull($project); - $this->assertEquals('test', $project['name']); - $this->assertEquals('test', $project['description']); - - $this->assertTrue($this->app->updateProject(array('project_id' => $this->projectId, 'name' => $this->projectName))); - } - - public function assertEnableDisableProject() - { - $this->assertTrue($this->app->disableProject($this->projectId)); - $this->assertTrue($this->app->enableProject($this->projectId)); - } - - public function assertEnableDisablePublicAccess() - { - $this->assertTrue($this->app->disableProjectPublicAccess($this->projectId)); - $this->assertTrue($this->app->enableProjectPublicAccess($this->projectId)); - } - - public function assertRemoveProject() - { - $this->assertTrue($this->app->removeProject($this->projectId)); - $this->assertNull($this->app->getProjectById($this->projectId)); - } -} diff --git a/tests/integration/SubtaskProcedureTest.php b/tests/integration/SubtaskProcedureTest.php new file mode 100644 index 00000000..7ab4ef0b --- /dev/null +++ b/tests/integration/SubtaskProcedureTest.php @@ -0,0 +1,64 @@ +assertCreateTeamProject(); + $this->assertCreateTask(); + $this->assertCreateSubtask(); + $this->assertGetSubtask(); + $this->assertUpdateSubtask(); + $this->assertGetAllSubtasks(); + $this->assertRemoveSubtask(); + } + + public function assertCreateSubtask() + { + $this->subtaskId = $this->app->createSubtask(array( + 'task_id' => $this->taskId, + 'title' => 'subtask #1', + )); + + $this->assertNotFalse($this->subtaskId); + } + + public function assertGetSubtask() + { + $subtask = $this->app->getSubtask($this->subtaskId); + $this->assertEquals($this->taskId, $subtask['task_id']); + $this->assertEquals('subtask #1', $subtask['title']); + } + + public function assertUpdateSubtask() + { + $this->assertTrue($this->app->execute('updateSubtask', array( + 'id' => $this->subtaskId, + 'task_id' => $this->taskId, + 'title' => 'test', + ))); + + $subtask = $this->app->getSubtask($this->subtaskId); + $this->assertEquals('test', $subtask['title']); + } + + public function assertGetAllSubtasks() + { + $subtasks = $this->app->getAllSubtasks($this->taskId); + $this->assertCount(1, $subtasks); + $this->assertEquals('test', $subtasks[0]['title']); + } + + public function assertRemoveSubtask() + { + $this->assertTrue($this->app->removeSubtask($this->subtaskId)); + + $subtasks = $this->app->getAllSubtasks($this->taskId); + $this->assertCount(0, $subtasks); + } +} diff --git a/tests/integration/SubtaskTest.php b/tests/integration/SubtaskTest.php deleted file mode 100644 index 10082e60..00000000 --- a/tests/integration/SubtaskTest.php +++ /dev/null @@ -1,64 +0,0 @@ -assertCreateTeamProject(); - $this->assertCreateTask(); - $this->assertCreateSubtask(); - $this->assertGetSubtask(); - $this->assertUpdateSubtask(); - $this->assertGetAllSubtasks(); - $this->assertRemoveSubtask(); - } - - public function assertCreateSubtask() - { - $this->subtaskId = $this->app->createSubtask(array( - 'task_id' => $this->taskId, - 'title' => 'subtask #1', - )); - - $this->assertNotFalse($this->subtaskId); - } - - public function assertGetSubtask() - { - $subtask = $this->app->getSubtask($this->subtaskId); - $this->assertEquals($this->taskId, $subtask['task_id']); - $this->assertEquals('subtask #1', $subtask['title']); - } - - public function assertUpdateSubtask() - { - $this->assertTrue($this->app->execute('updateSubtask', array( - 'id' => $this->subtaskId, - 'task_id' => $this->taskId, - 'title' => 'test', - ))); - - $subtask = $this->app->getSubtask($this->subtaskId); - $this->assertEquals('test', $subtask['title']); - } - - public function assertGetAllSubtasks() - { - $subtasks = $this->app->getAllSubtasks($this->taskId); - $this->assertCount(1, $subtasks); - $this->assertEquals('test', $subtasks[0]['title']); - } - - public function assertRemoveSubtask() - { - $this->assertTrue($this->app->removeSubtask($this->subtaskId)); - - $subtasks = $this->app->getAllSubtasks($this->taskId); - $this->assertCount(0, $subtasks); - } -} diff --git a/tests/integration/SwimlaneProcedureTest.php b/tests/integration/SwimlaneProcedureTest.php new file mode 100644 index 00000000..e64342b4 --- /dev/null +++ b/tests/integration/SwimlaneProcedureTest.php @@ -0,0 +1,93 @@ +assertCreateTeamProject(); + } + + public function assertGetDefaultSwimlane() + { + $swimlane = $this->app->getDefaultSwimlane($this->projectId); + $this->assertNotEmpty($swimlane); + $this->assertEquals('Default swimlane', $swimlane['default_swimlane']); + } + + public function assertAddSwimlane() + { + $this->swimlaneId = $this->app->addSwimlane($this->projectId, 'Swimlane 1'); + $this->assertNotFalse($this->swimlaneId); + $this->assertNotFalse($this->app->addSwimlane($this->projectId, 'Swimlane 2')); + } + + public function assertGetSwimlane() + { + $swimlane = $this->app->getSwimlane($this->swimlaneId); + $this->assertInternalType('array', $swimlane); + $this->assertEquals('Swimlane 1', $swimlane['name']); + } + + public function assertUpdateSwimlane() + { + $this->assertTrue($this->app->updateSwimlane($this->swimlaneId, 'Another swimlane')); + + $swimlane = $this->app->getSwimlaneById($this->swimlaneId); + $this->assertEquals('Another swimlane', $swimlane['name']); + } + + public function assertDisableSwimlane() + { + $this->assertTrue($this->app->disableSwimlane($this->projectId, $this->swimlaneId)); + + $swimlane = $this->app->getSwimlaneById($this->swimlaneId); + $this->assertEquals(0, $swimlane['is_active']); + } + + public function assertEnableSwimlane() + { + $this->assertTrue($this->app->enableSwimlane($this->projectId, $this->swimlaneId)); + + $swimlane = $this->app->getSwimlaneById($this->swimlaneId); + $this->assertEquals(1, $swimlane['is_active']); + } + + public function assertGetAllSwimlanes() + { + $swimlanes = $this->app->getAllSwimlanes($this->projectId); + $this->assertCount(2, $swimlanes); + $this->assertEquals('Another swimlane', $swimlanes[0]['name']); + $this->assertEquals('Swimlane 2', $swimlanes[1]['name']); + } + + public function assertGetActiveSwimlane() + { + $this->assertTrue($this->app->disableSwimlane($this->projectId, $this->swimlaneId)); + + $swimlanes = $this->app->getActiveSwimlanes($this->projectId); + $this->assertCount(2, $swimlanes); + $this->assertEquals('Default swimlane', $swimlanes[0]['name']); + $this->assertEquals('Swimlane 2', $swimlanes[1]['name']); + } + + public function assertRemoveSwimlane() + { + $this->assertTrue($this->app->removeSwimlane($this->projectId, $this->swimlaneId)); + } + + public function assertChangePosition() + { + $swimlaneId1 = $this->app->addSwimlane($this->projectId, 'Swimlane A'); + $this->assertNotFalse($this->app->addSwimlane($this->projectId, 'Swimlane B')); + + $swimlanes = $this->app->getAllSwimlanes($this->projectId); + $this->assertCount(3, $swimlanes); + + $this->assertTrue($this->app->changeSwimlanePosition($this->projectId, $swimlaneId1, 3)); + } +} diff --git a/tests/integration/SwimlaneTest.php b/tests/integration/SwimlaneTest.php deleted file mode 100644 index 4f703414..00000000 --- a/tests/integration/SwimlaneTest.php +++ /dev/null @@ -1,93 +0,0 @@ -assertCreateTeamProject(); - } - - public function assertGetDefaultSwimlane() - { - $swimlane = $this->app->getDefaultSwimlane($this->projectId); - $this->assertNotEmpty($swimlane); - $this->assertEquals('Default swimlane', $swimlane['default_swimlane']); - } - - public function assertAddSwimlane() - { - $this->swimlaneId = $this->app->addSwimlane($this->projectId, 'Swimlane 1'); - $this->assertNotFalse($this->swimlaneId); - $this->assertNotFalse($this->app->addSwimlane($this->projectId, 'Swimlane 2')); - } - - public function assertGetSwimlane() - { - $swimlane = $this->app->getSwimlane($this->swimlaneId); - $this->assertInternalType('array', $swimlane); - $this->assertEquals('Swimlane 1', $swimlane['name']); - } - - public function assertUpdateSwimlane() - { - $this->assertTrue($this->app->updateSwimlane($this->swimlaneId, 'Another swimlane')); - - $swimlane = $this->app->getSwimlaneById($this->swimlaneId); - $this->assertEquals('Another swimlane', $swimlane['name']); - } - - public function assertDisableSwimlane() - { - $this->assertTrue($this->app->disableSwimlane($this->projectId, $this->swimlaneId)); - - $swimlane = $this->app->getSwimlaneById($this->swimlaneId); - $this->assertEquals(0, $swimlane['is_active']); - } - - public function assertEnableSwimlane() - { - $this->assertTrue($this->app->enableSwimlane($this->projectId, $this->swimlaneId)); - - $swimlane = $this->app->getSwimlaneById($this->swimlaneId); - $this->assertEquals(1, $swimlane['is_active']); - } - - public function assertGetAllSwimlanes() - { - $swimlanes = $this->app->getAllSwimlanes($this->projectId); - $this->assertCount(2, $swimlanes); - $this->assertEquals('Another swimlane', $swimlanes[0]['name']); - $this->assertEquals('Swimlane 2', $swimlanes[1]['name']); - } - - public function assertGetActiveSwimlane() - { - $this->assertTrue($this->app->disableSwimlane($this->projectId, $this->swimlaneId)); - - $swimlanes = $this->app->getActiveSwimlanes($this->projectId); - $this->assertCount(2, $swimlanes); - $this->assertEquals('Default swimlane', $swimlanes[0]['name']); - $this->assertEquals('Swimlane 2', $swimlanes[1]['name']); - } - - public function assertRemoveSwimlane() - { - $this->assertTrue($this->app->removeSwimlane($this->projectId, $this->swimlaneId)); - } - - public function assertChangePosition() - { - $swimlaneId1 = $this->app->addSwimlane($this->projectId, 'Swimlane A'); - $this->assertNotFalse($this->app->addSwimlane($this->projectId, 'Swimlane B')); - - $swimlanes = $this->app->getAllSwimlanes($this->projectId); - $this->assertCount(3, $swimlanes); - - $this->assertTrue($this->app->changeSwimlanePosition($this->projectId, $swimlaneId1, 3)); - } -} diff --git a/tests/integration/TaskFileProcedureTest.php b/tests/integration/TaskFileProcedureTest.php new file mode 100644 index 00000000..61155555 --- /dev/null +++ b/tests/integration/TaskFileProcedureTest.php @@ -0,0 +1,67 @@ +assertCreateTeamProject(); + $this->assertCreateTask(); + $this->assertCreateTaskFile(); + $this->assertGetTaskFile(); + $this->assertDownloadTaskFile(); + $this->assertGetAllFiles(); + $this->assertRemoveTaskFile(); + $this->assertRemoveAllTaskFiles(); + } + + public function assertCreateTaskFile() + { + $this->fileId = $this->app->createTaskFile(1, $this->taskId, 'My file', base64_encode('plain text file')); + $this->assertNotFalse($this->fileId); + } + + public function assertGetTaskFile() + { + $file = $this->app->getTaskFile($this->fileId); + $this->assertNotEmpty($file); + $this->assertEquals('My file', $file['name']); + } + + public function assertDownloadTaskFile() + { + $content = $this->app->downloadTaskFile($this->fileId); + $this->assertNotEmpty($content); + $this->assertEquals('plain text file', base64_decode($content)); + } + + public function assertGetAllFiles() + { + $files = $this->app->getAllTaskFiles(array('task_id' => $this->taskId)); + $this->assertCount(1, $files); + $this->assertEquals('My file', $files[0]['name']); + } + + public function assertRemoveTaskFile() + { + $this->assertTrue($this->app->removeTaskFile($this->fileId)); + + $files = $this->app->getAllTaskFiles(array('task_id' => $this->taskId)); + $this->assertEmpty($files); + } + + public function assertRemoveAllTaskFiles() + { + $this->assertCreateTaskFile(); + $this->assertCreateTaskFile(); + + $this->assertTrue($this->app->removeAllTaskFiles($this->taskId)); + + $files = $this->app->getAllTaskFiles(array('task_id' => $this->taskId)); + $this->assertEmpty($files); + } +} diff --git a/tests/integration/TaskFileTest.php b/tests/integration/TaskFileTest.php deleted file mode 100644 index 7e9e943b..00000000 --- a/tests/integration/TaskFileTest.php +++ /dev/null @@ -1,67 +0,0 @@ -assertCreateTeamProject(); - $this->assertCreateTask(); - $this->assertCreateTaskFile(); - $this->assertGetTaskFile(); - $this->assertDownloadTaskFile(); - $this->assertGetAllFiles(); - $this->assertRemoveTaskFile(); - $this->assertRemoveAllTaskFiles(); - } - - public function assertCreateTaskFile() - { - $this->fileId = $this->app->createTaskFile(1, $this->taskId, 'My file', base64_encode('plain text file')); - $this->assertNotFalse($this->fileId); - } - - public function assertGetTaskFile() - { - $file = $this->app->getTaskFile($this->fileId); - $this->assertNotEmpty($file); - $this->assertEquals('My file', $file['name']); - } - - public function assertDownloadTaskFile() - { - $content = $this->app->downloadTaskFile($this->fileId); - $this->assertNotEmpty($content); - $this->assertEquals('plain text file', base64_decode($content)); - } - - public function assertGetAllFiles() - { - $files = $this->app->getAllTaskFiles(array('task_id' => $this->taskId)); - $this->assertCount(1, $files); - $this->assertEquals('My file', $files[0]['name']); - } - - public function assertRemoveTaskFile() - { - $this->assertTrue($this->app->removeTaskFile($this->fileId)); - - $files = $this->app->getAllTaskFiles(array('task_id' => $this->taskId)); - $this->assertEmpty($files); - } - - public function assertRemoveAllTaskFiles() - { - $this->assertCreateTaskFile(); - $this->assertCreateTaskFile(); - - $this->assertTrue($this->app->removeAllTaskFiles($this->taskId)); - - $files = $this->app->getAllTaskFiles(array('task_id' => $this->taskId)); - $this->assertEmpty($files); - } -} diff --git a/tests/integration/TaskLinkProcedureTest.php b/tests/integration/TaskLinkProcedureTest.php new file mode 100644 index 00000000..a25fced5 --- /dev/null +++ b/tests/integration/TaskLinkProcedureTest.php @@ -0,0 +1,68 @@ +assertCreateTeamProject(); + + $this->taskId1 = $this->app->createTask(array('project_id' => $this->projectId, 'title' => 'Task 1')); + $this->taskId2 = $this->app->createTask(array('project_id' => $this->projectId, 'title' => 'Task 2')); + + $this->assertNotFalse($this->taskId1); + $this->assertNotFalse($this->taskId2); + + $this->assertCreateTaskLink(); + $this->assertGetTaskLink(); + $this->assertGetAllTaskLinks(); + $this->assertUpdateTaskLink(); + $this->assertRemoveTaskLink(); + } + + public function assertCreateTaskLink() + { + $this->taskLinkId = $this->app->createTaskLink($this->taskId1, $this->taskId2, 1); + $this->assertNotFalse($this->taskLinkId); + } + + public function assertGetTaskLink() + { + $link = $this->app->getTaskLinkById($this->taskLinkId); + $this->assertNotNull($link); + $this->assertEquals($this->taskId1, $link['task_id']); + $this->assertEquals($this->taskId2, $link['opposite_task_id']); + $this->assertEquals(1, $link['link_id']); + } + + public function assertGetAllTaskLinks() + { + $links = $this->app->getAllTaskLinks($this->taskId2); + $this->assertCount(1, $links); + } + + public function assertUpdateTaskLink() + { + $this->assertTrue($this->app->updateTaskLink($this->taskLinkId, $this->taskId1, $this->taskId2, 3)); + + $link = $this->app->getTaskLinkById($this->taskLinkId); + $this->assertNotNull($link); + $this->assertEquals($this->taskId1, $link['task_id']); + $this->assertEquals($this->taskId2, $link['opposite_task_id']); + $this->assertEquals(3, $link['link_id']); + } + + public function assertRemoveTaskLink() + { + $this->assertTrue($this->app->removeTaskLink($this->taskLinkId)); + + $links = $this->app->getAllTaskLinks($this->taskId2); + $this->assertCount(0, $links); + } +} diff --git a/tests/integration/TaskLinkTest.php b/tests/integration/TaskLinkTest.php deleted file mode 100644 index 03bc437b..00000000 --- a/tests/integration/TaskLinkTest.php +++ /dev/null @@ -1,68 +0,0 @@ -assertCreateTeamProject(); - - $this->taskId1 = $this->app->createTask(array('project_id' => $this->projectId, 'title' => 'Task 1')); - $this->taskId2 = $this->app->createTask(array('project_id' => $this->projectId, 'title' => 'Task 2')); - - $this->assertNotFalse($this->taskId1); - $this->assertNotFalse($this->taskId2); - - $this->assertCreateTaskLink(); - $this->assertGetTaskLink(); - $this->assertGetAllTaskLinks(); - $this->assertUpdateTaskLink(); - $this->assertRemoveTaskLink(); - } - - public function assertCreateTaskLink() - { - $this->taskLinkId = $this->app->createTaskLink($this->taskId1, $this->taskId2, 1); - $this->assertNotFalse($this->taskLinkId); - } - - public function assertGetTaskLink() - { - $link = $this->app->getTaskLinkById($this->taskLinkId); - $this->assertNotNull($link); - $this->assertEquals($this->taskId1, $link['task_id']); - $this->assertEquals($this->taskId2, $link['opposite_task_id']); - $this->assertEquals(1, $link['link_id']); - } - - public function assertGetAllTaskLinks() - { - $links = $this->app->getAllTaskLinks($this->taskId2); - $this->assertCount(1, $links); - } - - public function assertUpdateTaskLink() - { - $this->assertTrue($this->app->updateTaskLink($this->taskLinkId, $this->taskId1, $this->taskId2, 3)); - - $link = $this->app->getTaskLinkById($this->taskLinkId); - $this->assertNotNull($link); - $this->assertEquals($this->taskId1, $link['task_id']); - $this->assertEquals($this->taskId2, $link['opposite_task_id']); - $this->assertEquals(3, $link['link_id']); - } - - public function assertRemoveTaskLink() - { - $this->assertTrue($this->app->removeTaskLink($this->taskLinkId)); - - $links = $this->app->getAllTaskLinks($this->taskId2); - $this->assertCount(0, $links); - } -} diff --git a/tests/integration/TaskProcedureTest.php b/tests/integration/TaskProcedureTest.php new file mode 100644 index 00000000..f456ae52 --- /dev/null +++ b/tests/integration/TaskProcedureTest.php @@ -0,0 +1,55 @@ +assertCreateTeamProject(); + $this->assertCreateTask(); + $this->assertUpdateTask(); + $this->assertGetTaskById(); + $this->assertGetTaskByReference(); + $this->assertGetAllTasks(); + $this->assertOpenCloseTask(); + } + + public function assertUpdateTask() + { + $this->assertTrue($this->app->updateTask(array('id' => $this->taskId, 'color_id' => 'red'))); + } + + public function assertGetTaskById() + { + $task = $this->app->getTask($this->taskId); + $this->assertNotNull($task); + $this->assertEquals('red', $task['color_id']); + $this->assertEquals($this->taskTitle, $task['title']); + } + + public function assertGetTaskByReference() + { + $taskId = $this->app->createTask(array('title' => 'task with reference', 'project_id' => $this->projectId, 'reference' => 'test')); + $this->assertNotFalse($taskId); + + $task = $this->app->getTaskByReference($this->projectId, 'test'); + $this->assertNotNull($task); + $this->assertEquals($taskId, $task['id']); + } + + public function assertGetAllTasks() + { + $tasks = $this->app->getAllTasks($this->projectId); + $this->assertInternalType('array', $tasks); + $this->assertNotEmpty($tasks); + } + + public function assertOpenCloseTask() + { + $this->assertTrue($this->app->closeTask($this->taskId)); + $this->assertTrue($this->app->openTask($this->taskId)); + } +} diff --git a/tests/integration/TaskTest.php b/tests/integration/TaskTest.php deleted file mode 100644 index 6f1d9d62..00000000 --- a/tests/integration/TaskTest.php +++ /dev/null @@ -1,55 +0,0 @@ -assertCreateTeamProject(); - $this->assertCreateTask(); - $this->assertUpdateTask(); - $this->assertGetTaskById(); - $this->assertGetTaskByReference(); - $this->assertGetAllTasks(); - $this->assertOpenCloseTask(); - } - - public function assertUpdateTask() - { - $this->assertTrue($this->app->updateTask(array('id' => $this->taskId, 'color_id' => 'red'))); - } - - public function assertGetTaskById() - { - $task = $this->app->getTask($this->taskId); - $this->assertNotNull($task); - $this->assertEquals('red', $task['color_id']); - $this->assertEquals($this->taskTitle, $task['title']); - } - - public function assertGetTaskByReference() - { - $taskId = $this->app->createTask(array('title' => 'task with reference', 'project_id' => $this->projectId, 'reference' => 'test')); - $this->assertNotFalse($taskId); - - $task = $this->app->getTaskByReference($this->projectId, 'test'); - $this->assertNotNull($task); - $this->assertEquals($taskId, $task['id']); - } - - public function assertGetAllTasks() - { - $tasks = $this->app->getAllTasks($this->projectId); - $this->assertInternalType('array', $tasks); - $this->assertNotEmpty($tasks); - } - - public function assertOpenCloseTask() - { - $this->assertTrue($this->app->closeTask($this->taskId)); - $this->assertTrue($this->app->openTask($this->taskId)); - } -} diff --git a/tests/integration/UserProcedureTest.php b/tests/integration/UserProcedureTest.php new file mode 100644 index 00000000..290f87fb --- /dev/null +++ b/tests/integration/UserProcedureTest.php @@ -0,0 +1,63 @@ +assertCreateUser(); + $this->assertGetUserById(); + $this->assertGetUserByName(); + $this->assertGetAllUsers(); + $this->assertEnableDisableUser(); + $this->assertUpdateUser(); + $this->assertRemoveUser(); + } + + public function assertGetUserById() + { + $user = $this->app->getUser($this->userId); + $this->assertNotNull($user); + $this->assertEquals($this->username, $user['username']); + } + + public function assertGetUserByName() + { + $user = $this->app->getUserByName($this->username); + $this->assertNotNull($user); + $this->assertEquals($this->username, $user['username']); + } + + public function assertGetAllUsers() + { + $users = $this->app->getAllUsers(); + $this->assertInternalType('array', $users); + $this->assertNotEmpty($users); + } + + public function assertEnableDisableUser() + { + $this->assertTrue($this->app->disableUser($this->userId)); + $this->assertFalse($this->app->isActiveUser($this->userId)); + $this->assertTrue($this->app->enableUser($this->userId)); + $this->assertTrue($this->app->isActiveUser($this->userId)); + } + + public function assertUpdateUser() + { + $this->assertTrue($this->app->updateUser(array( + 'id' => $this->userId, + 'name' => 'My user', + ))); + + $user = $this->app->getUser($this->userId); + $this->assertNotNull($user); + $this->assertEquals('My user', $user['name']); + } + + public function assertRemoveUser() + { + $this->assertTrue($this->app->removeUser($this->userId)); + } +} diff --git a/tests/integration/UserTest.php b/tests/integration/UserTest.php deleted file mode 100644 index c407c918..00000000 --- a/tests/integration/UserTest.php +++ /dev/null @@ -1,63 +0,0 @@ -assertCreateUser(); - $this->assertGetUserById(); - $this->assertGetUserByName(); - $this->assertGetAllUsers(); - $this->assertEnableDisableUser(); - $this->assertUpdateUser(); - $this->assertRemoveUser(); - } - - public function assertGetUserById() - { - $user = $this->app->getUser($this->userId); - $this->assertNotNull($user); - $this->assertEquals($this->username, $user['username']); - } - - public function assertGetUserByName() - { - $user = $this->app->getUserByName($this->username); - $this->assertNotNull($user); - $this->assertEquals($this->username, $user['username']); - } - - public function assertGetAllUsers() - { - $users = $this->app->getAllUsers(); - $this->assertInternalType('array', $users); - $this->assertNotEmpty($users); - } - - public function assertEnableDisableUser() - { - $this->assertTrue($this->app->disableUser($this->userId)); - $this->assertFalse($this->app->isActiveUser($this->userId)); - $this->assertTrue($this->app->enableUser($this->userId)); - $this->assertTrue($this->app->isActiveUser($this->userId)); - } - - public function assertUpdateUser() - { - $this->assertTrue($this->app->updateUser(array( - 'id' => $this->userId, - 'name' => 'My user', - ))); - - $user = $this->app->getUser($this->userId); - $this->assertNotNull($user); - $this->assertEquals('My user', $user['name']); - } - - public function assertRemoveUser() - { - $this->assertTrue($this->app->removeUser($this->userId)); - } -} -- cgit v1.2.3