summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/units/Model/CustomFilterTest.php12
-rw-r--r--tests/units/Model/ProjectDuplicationModelTest.php44
2 files changed, 54 insertions, 2 deletions
diff --git a/tests/units/Model/CustomFilterTest.php b/tests/units/Model/CustomFilterTest.php
index 463a1c91..f21cdfcd 100644
--- a/tests/units/Model/CustomFilterTest.php
+++ b/tests/units/Model/CustomFilterTest.php
@@ -16,6 +16,7 @@ class CustomFilterTest extends Base
$this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
$this->assertEquals(1, $cf->create(array('name' => 'My filter 1', 'filter' => 'status:open color:blue', 'project_id' => 1, 'user_id' => 1)));
$this->assertEquals(2, $cf->create(array('name' => 'My filter 2', 'filter' => 'status:open color:red', 'project_id' => 1, 'user_id' => 1, 'is_shared' => 1)));
+ $this->assertEquals(3, $cf->create(array('name' => 'My filter 3', 'filter' => 'status:open color:green', 'project_id' => 1, 'user_id' => 1, 'append' => 1)));
$filter = $cf->getById(1);
$this->assertNotEmpty($filter);
@@ -24,6 +25,7 @@ class CustomFilterTest extends Base
$this->assertEquals(1, $filter['project_id']);
$this->assertEquals(1, $filter['user_id']);
$this->assertEquals(0, $filter['is_shared']);
+ $this->assertEquals(0, $filter['append']);
$filter = $cf->getById(2);
$this->assertNotEmpty($filter);
@@ -32,6 +34,16 @@ class CustomFilterTest extends Base
$this->assertEquals(1, $filter['project_id']);
$this->assertEquals(1, $filter['user_id']);
$this->assertEquals(1, $filter['is_shared']);
+ $this->assertEquals(0, $filter['append']);
+
+ $filter = $cf->getById(3);
+ $this->assertNotEmpty($filter);
+ $this->assertEquals('My filter 3', $filter['name']);
+ $this->assertEquals('status:open color:green', $filter['filter']);
+ $this->assertEquals(1, $filter['project_id']);
+ $this->assertEquals(1, $filter['user_id']);
+ $this->assertEquals(0, $filter['is_shared']);
+ $this->assertEquals(1, $filter['append']);
}
public function testModification()
diff --git a/tests/units/Model/ProjectDuplicationModelTest.php b/tests/units/Model/ProjectDuplicationModelTest.php
index ac93d67c..e704f981 100644
--- a/tests/units/Model/ProjectDuplicationModelTest.php
+++ b/tests/units/Model/ProjectDuplicationModelTest.php
@@ -17,6 +17,7 @@ use Kanboard\Model\SwimlaneModel;
use Kanboard\Model\TaskModel;
use Kanboard\Model\TaskCreationModel;
use Kanboard\Model\TaskFinderModel;
+use Kanboard\Model\CustomFilterModel;
use Kanboard\Core\Security\Role;
class ProjectDuplicationModelTest extends Base
@@ -24,8 +25,8 @@ class ProjectDuplicationModelTest extends Base
public function testGetSelections()
{
$projectDuplicationModel = new ProjectDuplicationModel($this->container);
- $this->assertCount(7, $projectDuplicationModel->getOptionalSelection());
- $this->assertCount(10, $projectDuplicationModel->getPossibleSelection());
+ $this->assertCount(8, $projectDuplicationModel->getOptionalSelection());
+ $this->assertCount(11, $projectDuplicationModel->getPossibleSelection());
}
public function testGetClonedProjectName()
@@ -539,6 +540,9 @@ class ProjectDuplicationModelTest extends Base
$this->assertEquals(2, $taskCreationModel->create(array('title' => 'T2', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 1)));
$this->assertEquals(3, $taskCreationModel->create(array('title' => 'T3', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1)));
+ // make the first swimlane inactive (keep positions)
+ $this->assertTrue($swimlaneModel->disable(1, 1));
+
$this->assertEquals(2, $projectDuplicationModel->duplicate(1, array('projectPermissionModel', 'swimlaneModel', 'projectTaskDuplicationModel')));
// Check if Swimlanes have been duplicated
@@ -546,12 +550,16 @@ class ProjectDuplicationModelTest extends Base
$this->assertCount(4, $swimlanes);
$this->assertEquals(5, $swimlanes[0]['id']);
$this->assertEquals('Default swimlane', $swimlanes[0]['name']);
+ $this->assertEquals(0, $swimlanes[0]['is_active']);
$this->assertEquals(6, $swimlanes[1]['id']);
$this->assertEquals('S1', $swimlanes[1]['name']);
+ $this->assertEquals(1, $swimlanes[1]['is_active']);
$this->assertEquals(7, $swimlanes[2]['id']);
$this->assertEquals('S2', $swimlanes[2]['name']);
+ $this->assertEquals(1, $swimlanes[2]['is_active']);
$this->assertEquals(8, $swimlanes[3]['id']);
$this->assertEquals('S3', $swimlanes[3]['name']);
+ $this->assertEquals(1, $swimlanes[3]['is_active']);
// Check if Tasks have been duplicated
$tasks = $taskFinderModel->getAll(2);
@@ -603,4 +611,36 @@ class ProjectDuplicationModelTest extends Base
$tags = $taskTagModel->getList(6);
$this->assertEquals('C', $tags[6]);
}
+
+ public function testCloneProjectWithCustomFilters()
+ {
+ $projectModel = new ProjectModel($this->container);
+ $customFilterModel = new CustomFilterModel($this->container);
+ $projectDuplicationModel = new ProjectDuplicationModel($this->container);
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'P1')));
+
+ $this->assertEquals(1, $customFilterModel->create(array('name' => 'My filter 1', 'filter' => 'status:open color:blue', 'project_id' => 1, 'user_id' => 1, 'append' => 1)));
+ $this->assertEquals(2, $customFilterModel->create(array('name' => 'My filter 2', 'filter' => 'status:open color:red', 'project_id' => 1, 'user_id' => 1, 'is_shared' => 1)));
+
+ $this->assertEquals(2, $projectDuplicationModel->duplicate(1, array('customFilterModel')));
+
+ $filter = $customFilterModel->getById(3);
+ $this->assertNotEmpty($filter);
+ $this->assertEquals('My filter 1', $filter['name']);
+ $this->assertEquals('status:open color:blue', $filter['filter']);
+ $this->assertEquals(2, $filter['project_id']);
+ $this->assertEquals(1, $filter['user_id']);
+ $this->assertEquals(0, $filter['is_shared']);
+ $this->assertEquals(1, $filter['append']);
+
+ $filter = $customFilterModel->getById(4);
+ $this->assertNotEmpty($filter);
+ $this->assertEquals('My filter 2', $filter['name']);
+ $this->assertEquals('status:open color:red', $filter['filter']);
+ $this->assertEquals(2, $filter['project_id']);
+ $this->assertEquals(1, $filter['user_id']);
+ $this->assertEquals(1, $filter['is_shared']);
+ $this->assertEquals(0, $filter['append']);
+ }
}