Improve dashboard

This commit is contained in:
Frederic Guillot
2017-04-08 13:58:25 -04:00
parent fe9f3ba707
commit d7b0cfbbe5
21 changed files with 493 additions and 30 deletions

View File

@@ -0,0 +1,35 @@
<?php
use Kanboard\Core\Security\Role;
use Kanboard\Model\ProjectModel;
use Kanboard\Model\ProjectUserRoleModel;
use Kanboard\Model\UserModel;
use Kanboard\Pagination\ProjectPagination;
require_once __DIR__.'/../Base.php';
class ProjectPaginationTest extends Base
{
public function testDashboardPagination()
{
$projectModel = new ProjectModel($this->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());
}
}

View File

@@ -0,0 +1,30 @@
<?php
use Kanboard\Model\ProjectModel;
use Kanboard\Model\TaskCreationModel;
use Kanboard\Model\TaskModel;
use Kanboard\Pagination\TaskPagination;
require_once __DIR__.'/../Base.php';
class TaskPaginationTest extends Base
{
public function testDashboardPagination()
{
$taskCreationModel = new TaskCreationModel($this->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());
}
}