Add per-project and per-swimlane task limits

This change allows projects and swimlanes to be configured with task limits that apply to their whole scope (i.e. all active tasks in a project or swimlane, respectively), as opposed to the usual per-column task limits.
This commit is contained in:
Andre Nathan
2020-02-26 01:26:31 -03:00
committed by GitHub
parent 542fd17891
commit c8a617cfcb
21 changed files with 161 additions and 27 deletions

View File

@@ -44,6 +44,7 @@ class ProjectModelTest extends Base
$this->assertEquals(0, $project['is_public']);
$this->assertEquals(0, $project['is_private']);
$this->assertEquals(0, $project['per_swimlane_task_limits']);
$this->assertEquals(0, $project['task_limit']);
$this->assertEquals(time(), $project['last_modified'], '', 1);
$this->assertEmpty($project['token']);
$this->assertEmpty($project['start_date']);
@@ -65,6 +66,17 @@ class ProjectModelTest extends Base
$this->assertEquals(0, $project['owner_id']);
}
public function testCreationWithTaskLimit()
{
$projectModel = new ProjectModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest', 'task_limit' => 3)));
$project = $projectModel->getById(1);
$this->assertNotEmpty($project);
$this->assertEquals(3, $project['task_limit']);
}
public function testProjectDate()
{
$projectModel = new ProjectModel($this->container);
@@ -162,6 +174,14 @@ class ProjectModelTest extends Base
$this->assertEmpty($categories);
}
public function testCreationWithBlankTaskLimit()
{
$projectModel = new ProjectModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest1', 'task_limit' => '')));
$project = $projectModel->getById(1);
$this->assertEquals(0, $project['task_limit']);
}
public function testUpdateLastModifiedDate()
{
$projectModel = new ProjectModel($this->container);
@@ -215,6 +235,20 @@ class ProjectModelTest extends Base
$this->assertEquals(1, $project['per_swimlane_task_limits']);
}
public function testUpdateTaskLimit()
{
$projectModel = new ProjectModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest')));
$project = $projectModel->getById(1);
$this->assertEquals(0, $project['task_limit']);
$this->assertTrue($projectModel->update(array('id'=> 1, 'task_limit' => 1)));
$project = $projectModel->getById(1);
$this->assertEquals(1, $project['task_limit']);
}
public function testGetAllIds()
{
$projectModel = new ProjectModel($this->container);
@@ -453,24 +487,29 @@ class ProjectModelTest extends Base
{
$projectModel = new ProjectModel($this->container);
$userModel = new UserModel($this->container);
$taskCreationModel = new TaskCreationModel($this->container);
$this->assertEquals(2, $userModel->create(array('username' => 'user1', 'name' => 'Me')));
$this->assertEquals(1, $projectModel->create(array('name' => 'My project 1'), 2));
$this->assertEquals(2, $projectModel->create(array('name' => 'My project 2')));
$this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task #1', 'project_id' => 1)));
$this->assertEquals(2, $taskCreationModel->create(array('title' => 'Task #2', 'project_id' => 1)));
$project = $projectModel->getByIdWithOwner(1);
$project = $projectModel->getByIdWithOwnerAndTaskCount(1);
$this->assertNotEmpty($project);
$this->assertSame('My project 1', $project['name']);
$this->assertSame('Me', $project['owner_name']);
$this->assertSame('user1', $project['owner_username']);
$this->assertEquals(2, $project['owner_id']);
$this->assertEquals(2, $project['nb_active_tasks']);
$project = $projectModel->getByIdWithOwner(2);
$project = $projectModel->getByIdWithOwnerAndTaskCount(2);
$this->assertNotEmpty($project);
$this->assertSame('My project 2', $project['name']);
$this->assertEquals('', $project['owner_name']);
$this->assertEquals('', $project['owner_username']);
$this->assertEquals(0, $project['owner_id']);
$this->assertEquals(0, $project['nb_active_tasks']);
}
public function testGetList()

View File

@@ -14,13 +14,15 @@ class SwimlaneModelTest extends Base
$swimlaneModel = new SwimlaneModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest')));
$this->assertEquals(2, $swimlaneModel->create(1, 'Swimlane #1'));
$this->assertEquals(2, $swimlaneModel->create(1, 'Swimlane #1', '', 1));
$swimlanes = $swimlaneModel->getAll(1);
$this->assertNotEmpty($swimlanes);
$this->assertEquals(2, count($swimlanes));
$this->assertEquals('Default swimlane', $swimlanes[0]['name']);
$this->assertEquals('Swimlane #1', $swimlanes[1]['name']);
$this->assertEquals(0, $swimlanes[0]['task_limit']);
$this->assertEquals(1, $swimlanes[1]['task_limit']);
$this->assertEquals(2, $swimlaneModel->getIdByName(1, 'Swimlane #1'));
$this->assertEquals(0, $swimlaneModel->getIdByName(2, 'Swimlane #2'));
@@ -85,10 +87,11 @@ class SwimlaneModelTest extends Base
$this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest')));
$this->assertEquals(2, $swimlaneModel->create(1, 'Swimlane #1'));
$this->assertTrue($swimlaneModel->update(2, array('name' => 'foobar')));
$this->assertTrue($swimlaneModel->update(2, array('name' => 'foobar', 'task_limit' => 1)));
$swimlane = $swimlaneModel->getById(2);
$this->assertEquals('foobar', $swimlane['name']);
$this->assertEquals(1, $swimlane['task_limit']);
}
public function testDisableEnable()