summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-02-07 23:28:17 -0500
committerFrederic Guillot <fred@kanboard.net>2015-02-07 23:28:17 -0500
commit00b9508d8178bae016b2a25a81282dbe9ae0a9d2 (patch)
tree488397b9830b9ee56ff3eb4752958ea7a44eec04 /tests
parent607d9dc79429cefa51dfe1739564922cc9a2ab89 (diff)
Be able to disable the login form for specific users
Diffstat (limited to 'tests')
-rw-r--r--tests/units/ProjectDuplicationTest.php117
-rw-r--r--tests/units/ProjectTest.php2
2 files changed, 79 insertions, 40 deletions
diff --git a/tests/units/ProjectDuplicationTest.php b/tests/units/ProjectDuplicationTest.php
index bb8e0408..b35575aa 100644
--- a/tests/units/ProjectDuplicationTest.php
+++ b/tests/units/ProjectDuplicationTest.php
@@ -229,13 +229,13 @@ class ProjectDuplicationTest extends Base
$this->assertEquals(2, $tc->create(array('title' => 'T2', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 1)));
$this->assertEquals(3, $tc->create(array('title' => 'T3', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1)));
- $this->container['dispatcher']->addListener(Task::EVENT_CREATE_UPDATE, function() {});
- $this->container['dispatcher']->addListener(Task::EVENT_CREATE, function() {});
-
- $this->assertEquals(2, $pd->duplicate(1, array('category', 'action', 'swimlane', 'task')));
+ $this->assertNotFalse($pd->duplicate(1, array('category', 'action', 'swimlane', 'task')));
+ $project = $p->getByName('P1 (Clone)');
+ $this->assertNotFalse($project);
+ $project_id = $project['id'];
// Check if Swimlanes have been duplicated
- $swimlanes = $s->getAll(2);
+ $swimlanes = $s->getAll($project_id);
$this->assertCount(3, $swimlanes);
$this->assertEquals(4, $swimlanes[0]['id']);
@@ -244,37 +244,59 @@ class ProjectDuplicationTest extends Base
$this->assertEquals('S2', $swimlanes[1]['name']);
$this->assertEquals(6, $swimlanes[2]['id']);
$this->assertEquals('S3', $swimlanes[2]['name']);
- $new_default = $s->getDefault(2);
+ $new_default = $s->getDefault($project_id);
$this->assertEquals('New Default', $new_default['default_swimlane']);
// Check if Tasks have been duplicated
- $tasks = $tf->getAll(2);
+ $tasks = $tf->getAll($project_id);
$this->assertCount(3, $tasks);
- $this->assertEquals(4, $tasks[0]['id']);
+ // $this->assertEquals(4, $tasks[0]['id']);
$this->assertEquals('T1', $tasks[0]['title']);
- $this->assertEquals(5, $tasks[1]['id']);
+ // $this->assertEquals(5, $tasks[1]['id']);
$this->assertEquals('T2', $tasks[1]['title']);
- $this->assertEquals(6, $tasks[2]['id']);
+ // $this->assertEquals(6, $tasks[2]['id']);
$this->assertEquals('T3', $tasks[2]['title']);
- // Drop project
- unset($tasks);
- unset($swimlanes);
- unset($new_default);
+ $p->remove($project_id);
- $p->remove(2);
+ $this->assertFalse($p->exists($project_id));
+ $this->assertCount(0, $s->getAll($project_id));
+ $this->assertCount(0, $tf->getAll($project_id));
+ }
- $this->assertFalse($p->exists(2));
- $this->assertCount(0, $s->getAll(2));
- $this->assertCount(0, $tf->getAll(2));
+ public function testCloneProjectWithSwimlanes()
+ {
+ $p = new Project($this->container);
+ $pd = new ProjectDuplication($this->container);
+ $s = new Swimlane($this->container);
+ $tc = new TaskCreation($this->container);
+ $tf = new TaskFinder($this->container);
- // Check duplication with Swimlanes only
- $this->assertEquals(2, $pd->duplicate(1, array('category', 'action', 'swimlane')));
+ $this->assertEquals(1, $p->create(array('name' => 'P1')));
- // Check if Swimlanes have been duplicated
- $swimlanes = $s->getAll(2);
+ // create initial swimlanes
+ $this->assertEquals(1, $s->create(1, 'S1'));
+ $this->assertEquals(2, $s->create(1, 'S2'));
+ $this->assertEquals(3, $s->create(1, 'S3'));
+
+ $default_swimlane1 = $s->getDefault(1);
+ $default_swimlane1['default_swimlane'] = 'New Default';
+
+ $this->assertTrue($s->updateDefault($default_swimlane1));
+
+ //create initial tasks
+ $this->assertEquals(1, $tc->create(array('title' => 'T1', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 1)));
+ $this->assertEquals(2, $tc->create(array('title' => 'T2', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 1)));
+ $this->assertEquals(3, $tc->create(array('title' => 'T3', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1)));
+
+ $this->assertNotFalse($pd->duplicate(1, array('category', 'action', 'swimlane')));
+ $project = $p->getByName('P1 (Clone)');
+ $this->assertNotFalse($project);
+ $project_id = $project['id'];
+
+ $swimlanes = $s->getAll($project_id);
$this->assertCount(3, $swimlanes);
$this->assertEquals(4, $swimlanes[0]['id']);
@@ -283,38 +305,55 @@ class ProjectDuplicationTest extends Base
$this->assertEquals('S2', $swimlanes[1]['name']);
$this->assertEquals(6, $swimlanes[2]['id']);
$this->assertEquals('S3', $swimlanes[2]['name']);
- $new_default = $s->getDefault(2);
+ $new_default = $s->getDefault($project_id);
$this->assertEquals('New Default', $new_default['default_swimlane']);
// Check if Tasks have NOT been duplicated
- $this->assertCount(0, $tf->getAll(2));
+ $this->assertCount(0, $tf->getAll($project_id));
+ }
+
+ public function testCloneProjectWithTasks()
+ {
+ $p = new Project($this->container);
+ $pd = new ProjectDuplication($this->container);
+ $s = new Swimlane($this->container);
+ $tc = new TaskCreation($this->container);
+ $tf = new TaskFinder($this->container);
+
+ $this->assertEquals(1, $p->create(array('name' => 'P1')));
- // Drop project
- unset($tasks);
- unset($swimlanes);
- unset($new_default);
+ // create initial swimlanes
+ $this->assertEquals(1, $s->create(1, 'S1'));
+ $this->assertEquals(2, $s->create(1, 'S2'));
+ $this->assertEquals(3, $s->create(1, 'S3'));
+
+ $default_swimlane1 = $s->getDefault(1);
+ $default_swimlane1['default_swimlane'] = 'New Default';
- $p->remove(2);
+ $this->assertTrue($s->updateDefault($default_swimlane1));
- $this->assertFalse($p->exists(2));
- $this->assertCount(0, $s->getAll(2));
- $this->assertCount(0, $tf->getAll(2));
+ //create initial tasks
+ $this->assertEquals(1, $tc->create(array('title' => 'T1', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 1)));
+ $this->assertEquals(2, $tc->create(array('title' => 'T2', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 1)));
+ $this->assertEquals(3, $tc->create(array('title' => 'T3', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1)));
- // Check duplication with Tasks only
- $this->assertEquals(2, $pd->duplicate(1, array('category', 'action', 'task')));
+ $this->assertNotFalse($pd->duplicate(1, array('category', 'action', 'task')));
+ $project = $p->getByName('P1 (Clone)');
+ $this->assertNotFalse($project);
+ $project_id = $project['id'];
// Check if Swimlanes have NOT been duplicated
- $this->assertCount(0, $s->getAll(2));
+ $this->assertCount(0, $s->getAll($project_id));
// Check if Tasks have been duplicated
- $tasks = $tf->getAll(2);
+ $tasks = $tf->getAll($project_id);
$this->assertCount(3, $tasks);
- $this->assertEquals(4, $tasks[0]['id']);
+ //$this->assertEquals(4, $tasks[0]['id']);
$this->assertEquals('T1', $tasks[0]['title']);
- $this->assertEquals(5, $tasks[1]['id']);
+ //$this->assertEquals(5, $tasks[1]['id']);
$this->assertEquals('T2', $tasks[1]['title']);
- $this->assertEquals(6, $tasks[2]['id']);
+ //$this->assertEquals(6, $tasks[2]['id']);
$this->assertEquals('T3', $tasks[2]['title']);
}
}
diff --git a/tests/units/ProjectTest.php b/tests/units/ProjectTest.php
index 4553dd3a..4864a3ae 100644
--- a/tests/units/ProjectTest.php
+++ b/tests/units/ProjectTest.php
@@ -97,7 +97,7 @@ class ProjectTest extends Base
$project = $p->getById(1);
$this->assertNotEmpty($project);
- $this->assertEquals($now, $project['last_modified']);
+ $this->assertEquals($now, $project['last_modified'], 'Wrong Timestamp', 1);
sleep(1);
$this->assertTrue($p->updateModificationDate(1));