From 9b34631135f29480dda3ed2df463fbb5aab7c9e4 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 12 Mar 2017 21:36:52 -0400 Subject: Simplify dashboard to use new tasks list view --- tests/integration/MeProcedureTest.php | 6 +- tests/units/Model/SubtaskModelTest.php | 29 +++++ tests/units/Pagination/DashboardPaginationTest.php | 121 +++++++++++++++++++++ tests/units/Pagination/ProjectPaginationTest.php | 35 ------ tests/units/Pagination/SubtaskPaginationTest.php | 53 --------- tests/units/Pagination/TaskPaginationTest.php | 30 ----- 6 files changed, 151 insertions(+), 123 deletions(-) create mode 100644 tests/units/Pagination/DashboardPaginationTest.php delete mode 100644 tests/units/Pagination/ProjectPaginationTest.php delete mode 100644 tests/units/Pagination/SubtaskPaginationTest.php delete mode 100644 tests/units/Pagination/TaskPaginationTest.php (limited to 'tests') diff --git a/tests/integration/MeProcedureTest.php b/tests/integration/MeProcedureTest.php index 2106419c..5d30b61b 100644 --- a/tests/integration/MeProcedureTest.php +++ b/tests/integration/MeProcedureTest.php @@ -53,11 +53,7 @@ class MeProcedureTest extends BaseProcedureTest { $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']); + $this->assertEquals($this->userUserId, $dashboard[0]['owner_id']); } public function assertGetMyActivityStream() diff --git a/tests/units/Model/SubtaskModelTest.php b/tests/units/Model/SubtaskModelTest.php index eed37cf3..8ad054d1 100644 --- a/tests/units/Model/SubtaskModelTest.php +++ b/tests/units/Model/SubtaskModelTest.php @@ -172,4 +172,33 @@ class SubtaskModelTest extends Base $this->assertEquals(1, $subtaskModel->getProjectId(1)); $this->assertEquals(0, $subtaskModel->getProjectId(2)); } + + public function testGetAllByTaskIds() + { + $taskCreationModel = new TaskCreationModel($this->container); + $subtaskModel = new SubtaskModel($this->container); + $projectModel = new ProjectModel($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); + $this->assertEquals(1, $taskCreationModel->create(array('title' => 'test 1', 'project_id' => 1))); + $this->assertEquals(1, $subtaskModel->create(array('title' => 'subtask #1', 'task_id' => 1))); + + $this->assertCount(0, $subtaskModel->getAllByTaskIds(array())); + $this->assertCount(1, $subtaskModel->getAllByTaskIds(array(1))); + } + + public function testGetAllByTaskIdsAndAssignee() + { + $taskCreationModel = new TaskCreationModel($this->container); + $subtaskModel = new SubtaskModel($this->container); + $projectModel = new ProjectModel($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); + $this->assertEquals(1, $taskCreationModel->create(array('title' => 'test 1', 'project_id' => 1))); + $this->assertEquals(1, $subtaskModel->create(array('title' => 'subtask #1', 'task_id' => 1, 'user_id' => 1))); + + $this->assertCount(0, $subtaskModel->getAllByTaskIdsAndAssignee(array(), 1)); + $this->assertCount(0, $subtaskModel->getAllByTaskIdsAndAssignee(array(1), 2)); + $this->assertCount(1, $subtaskModel->getAllByTaskIdsAndAssignee(array(1), 1)); + } } diff --git a/tests/units/Pagination/DashboardPaginationTest.php b/tests/units/Pagination/DashboardPaginationTest.php new file mode 100644 index 00000000..92b5ac6f --- /dev/null +++ b/tests/units/Pagination/DashboardPaginationTest.php @@ -0,0 +1,121 @@ +container); + $projectUserRoleModel = new ProjectUserRoleModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $subtaskModel = new SubtaskModel($this->container); + $dashboardPagination = new DashboardPagination($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); + $this->assertEquals(2, $projectModel->create(array('name' => 'Project #2'))); + + $this->assertTrue($projectUserRoleModel->addUser(1, 1, Role::PROJECT_MEMBER)); + + $this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task #1', 'project_id' => 2))); + $this->assertEquals(2, $taskCreationModel->create(array('title' => 'Task #2', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 1))); + + $this->assertEquals(1, $subtaskModel->create(array('task_id' => 1, 'title' => 'subtask A', 'user_id' => 1))); + $this->assertEquals(2, $subtaskModel->create(array('task_id' => 2, 'title' => 'subtask B', 'user_id' => 1))); + $this->assertEquals(3, $subtaskModel->create(array('task_id' => 2, 'title' => 'subtask C'))); + + $dashboard = $dashboardPagination->getOverview(1); + $this->assertCount(1, $dashboard); + $this->assertEquals(1, $dashboard[0]['project_id']); + $this->assertEquals('Project #1', $dashboard[0]['project_name']); + $this->assertEquals(1, $dashboard[0]['paginator']->getTotal()); + + $tasks = $dashboard[0]['paginator']->getCollection(); + $this->assertCount(1, $tasks); + $this->assertCount(1, $tasks[0]['subtasks']); + $this->assertEquals('subtask B', $tasks[0]['subtasks'][0]['title']); + } + + public function testWhenUserIsNotAssignedToTask() + { + $userModel = new UserModel($this->container); + $projectModel = new ProjectModel($this->container); + $projectUserRoleModel = new ProjectUserRoleModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $subtaskModel = new SubtaskModel($this->container); + $dashboardPagination = new DashboardPagination($this->container); + + $this->assertEquals(2, $userModel->create(array('username' => 'user1'))); + + $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); + $this->assertEquals(2, $projectModel->create(array('name' => 'Project #2'))); + + $this->assertTrue($projectUserRoleModel->addUser(1, 1, Role::PROJECT_MEMBER)); + $this->assertTrue($projectUserRoleModel->addUser(1, 2, Role::PROJECT_MEMBER)); + $this->assertTrue($projectUserRoleModel->addUser(2, 2, Role::PROJECT_MEMBER)); + + $this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task #1', 'project_id' => 2))); + $this->assertEquals(2, $taskCreationModel->create(array('title' => 'Task #2', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 2))); + $this->assertEquals(3, $taskCreationModel->create(array('title' => 'Task #3', 'project_id' => 2, 'owner_id' => 2))); + + $this->assertEquals(1, $subtaskModel->create(array('task_id' => 1, 'title' => 'subtask A', 'user_id' => 2))); + $this->assertEquals(2, $subtaskModel->create(array('task_id' => 2, 'title' => 'subtask B', 'user_id' => 1))); + $this->assertEquals(3, $subtaskModel->create(array('task_id' => 2, 'title' => 'subtask C'))); + + $dashboard = $dashboardPagination->getOverview(1); + $this->assertCount(1, $dashboard); + $this->assertEquals(1, $dashboard[0]['project_id']); + $this->assertEquals('Project #1', $dashboard[0]['project_name']); + $this->assertEquals(1, $dashboard[0]['paginator']->getTotal()); + + $tasks = $dashboard[0]['paginator']->getCollection(); + $this->assertCount(1, $tasks); + $this->assertCount(1, $tasks[0]['subtasks']); + $this->assertEquals('subtask B', $tasks[0]['subtasks'][0]['title']); + + $dashboard = $dashboardPagination->getOverview(2); + $this->assertCount(2, $dashboard); + $this->assertEquals('Project #1', $dashboard[0]['project_name']); + $this->assertEquals('Project #2', $dashboard[1]['project_name']); + $this->assertEquals(1, $dashboard[0]['paginator']->getTotal()); + + $tasks = $dashboard[0]['paginator']->getCollection(); + $this->assertCount(1, $tasks); + $this->assertCount(0, $tasks[0]['subtasks']); + + $tasks = $dashboard[1]['paginator']->getCollection(); + $this->assertCount(2, $tasks); + $this->assertCount(1, $tasks[0]['subtasks']); + $this->assertEquals('subtask A', $tasks[0]['subtasks'][0]['title']); + } + + public function testWhenColumnIsHidden() + { + $projectModel = new ProjectModel($this->container); + $projectUserRoleModel = new ProjectUserRoleModel($this->container); + $columnModel = new ColumnModel($this->container); + $taskCreationModel = new TaskCreationModel($this->container); + $subtaskModel = new SubtaskModel($this->container); + $dashboardPagination = new DashboardPagination($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); + $this->assertTrue($projectUserRoleModel->addUser(1, 1, Role::PROJECT_MEMBER)); + + $this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1))); + $this->assertEquals(1, $subtaskModel->create(array('task_id' => 1, 'title' => 'subtask #1', 'user_id' => 1))); + + $this->assertCount(1, $dashboardPagination->getOverview(1)); + + $this->assertTrue($columnModel->update(1, 'test', 0, '', 1)); + $this->assertCount(0, $dashboardPagination->getOverview(1)); + } +} diff --git a/tests/units/Pagination/ProjectPaginationTest.php b/tests/units/Pagination/ProjectPaginationTest.php deleted file mode 100644 index 35532d0d..00000000 --- a/tests/units/Pagination/ProjectPaginationTest.php +++ /dev/null @@ -1,35 +0,0 @@ -container); - $projectUserRoleModel = new ProjectUserRoleModel($this->container); - $userModel = new UserModel($this->container); - $projectPagination = new ProjectPagination($this->container); - - $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); - $this->assertEquals(2, $projectModel->create(array('name' => 'Project #2', 'is_private' => 1))); - $this->assertEquals(3, $projectModel->create(array('name' => 'Project #3'))); - $this->assertEquals(4, $projectModel->create(array('name' => 'Project #4', 'is_private' => 1))); - - $this->assertEquals(2, $userModel->create(array('username' => 'test'))); - $this->assertTrue($projectUserRoleModel->addUser(1, 2, Role::PROJECT_MANAGER)); - $this->assertTrue($projectUserRoleModel->addUser(2, 2, Role::PROJECT_MANAGER)); - - $this->assertCount(2, $projectPagination->getDashboardPaginator(2, 'projects', 5)->getCollection()); - $this->assertCount(0, $projectPagination->getDashboardPaginator(3, 'projects', 5)->getCollection()); - $this->assertCount(2, $projectPagination->getDashboardPaginator(2, 'projects', 5)->setOrder(ProjectModel::TABLE.'.id')->getCollection()); - $this->assertCount(2, $projectPagination->getDashboardPaginator(2, 'projects', 5)->setOrder(ProjectModel::TABLE.'.is_private')->getCollection()); - $this->assertCount(2, $projectPagination->getDashboardPaginator(2, 'projects', 5)->setOrder(ProjectModel::TABLE.'.name')->getCollection()); - } -} diff --git a/tests/units/Pagination/SubtaskPaginationTest.php b/tests/units/Pagination/SubtaskPaginationTest.php deleted file mode 100644 index 1e16c985..00000000 --- a/tests/units/Pagination/SubtaskPaginationTest.php +++ /dev/null @@ -1,53 +0,0 @@ -container); - $projectModel = new ProjectModel($this->container); - $subtaskModel = new SubtaskModel($this->container); - $subtaskPagination = new SubtaskPagination($this->container); - - $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); - $this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task #1', 'project_id' => 1))); - $this->assertEquals(2, $taskCreationModel->create(array('title' => 'Task #2', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 1))); - $this->assertEquals(1, $subtaskModel->create(array('task_id' => 1, 'title' => 'subtask #1', 'user_id' => 1))); - $this->assertEquals(2, $subtaskModel->create(array('task_id' => 2, 'title' => 'subtask #1', 'user_id' => 1))); - $this->assertEquals(3, $subtaskModel->create(array('task_id' => 1, 'title' => 'subtask #1', 'user_id' => 1))); - $this->assertEquals(4, $subtaskModel->create(array('task_id' => 2, 'title' => 'subtask #1'))); - $this->assertEquals(5, $subtaskModel->create(array('task_id' => 1, 'title' => 'subtask #1'))); - - $this->assertCount(3, $subtaskPagination->getDashboardPaginator(1, 'subtasks', 5)->getCollection()); - $this->assertCount(0, $subtaskPagination->getDashboardPaginator(2, 'subtasks', 5)->getCollection()); - $this->assertCount(3, $subtaskPagination->getDashboardPaginator(1, 'subtasks', 5)->setOrder(TaskModel::TABLE.'.id')->getCollection()); - $this->assertCount(3, $subtaskPagination->getDashboardPaginator(1, 'subtasks', 5)->setOrder('project_name')->getCollection()); - $this->assertCount(3, $subtaskPagination->getDashboardPaginator(1, 'subtasks', 5)->setOrder('task_name')->getCollection()); - $this->assertCount(3, $subtaskPagination->getDashboardPaginator(1, 'subtasks', 5)->setOrder(SubtaskModel::TABLE.'.title')->getCollection()); - } - - public function testWhenColumnIsHidden() - { - $columnModel = new ColumnModel($this->container); - $taskCreationModel = new TaskCreationModel($this->container); - $projectModel = new ProjectModel($this->container); - $subtaskModel = new SubtaskModel($this->container); - $subtaskPagination = new SubtaskPagination($this->container); - - $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); - $this->assertTrue($columnModel->update(1, 'test', 0, '', 1)); - $this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1))); - $this->assertEquals(1, $subtaskModel->create(array('task_id' => 1, 'title' => 'subtask #1', 'user_id' => 1))); - - $this->assertCount(0, $subtaskPagination->getDashboardPaginator(1, 'subtasks', 5)->getCollection()); - } -} diff --git a/tests/units/Pagination/TaskPaginationTest.php b/tests/units/Pagination/TaskPaginationTest.php deleted file mode 100644 index 027212e2..00000000 --- a/tests/units/Pagination/TaskPaginationTest.php +++ /dev/null @@ -1,30 +0,0 @@ -container); - $projectModel = new ProjectModel($this->container); - $taskPagination = new TaskPagination($this->container); - - $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); - $this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task #1', 'project_id' => 1))); - $this->assertEquals(2, $taskCreationModel->create(array('title' => 'Task #2', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 1))); - - $this->assertCount(1, $taskPagination->getDashboardPaginator(1, 'tasks', 5)->getCollection()); - $this->assertCount(0, $taskPagination->getDashboardPaginator(2, 'tasks', 5)->getCollection()); - $this->assertCount(1, $taskPagination->getDashboardPaginator(1, 'tasks', 5)->setOrder(TaskModel::TABLE.'.id')->getCollection()); - $this->assertCount(1, $taskPagination->getDashboardPaginator(1, 'tasks', 5)->setOrder('project_name')->getCollection()); - $this->assertCount(1, $taskPagination->getDashboardPaginator(1, 'tasks', 5)->setOrder(TaskModel::TABLE.'.title')->getCollection()); - $this->assertCount(1, $taskPagination->getDashboardPaginator(1, 'tasks', 5)->setOrder(TaskModel::TABLE.'.priority')->getCollection()); - $this->assertCount(1, $taskPagination->getDashboardPaginator(1, 'tasks', 5)->setOrder(TaskModel::TABLE.'.date_due')->getCollection()); - } -} -- cgit v1.2.3