summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-09-03 17:38:35 -0400
committerFrederic Guillot <fred@kanboard.net>2016-09-03 17:38:35 -0400
commita7f720ecbbe2b2f36a488921eeb311276fbe1e00 (patch)
tree4e299906a3304a7d3612d3be0ee569c809dc4a05 /tests
parent0bd108d648f52b30d499a1d12af782aeee02f18f (diff)
Improve TaskExport class
Diffstat (limited to 'tests')
-rw-r--r--tests/units/Export/TaskExportTest.php104
1 files changed, 65 insertions, 39 deletions
diff --git a/tests/units/Export/TaskExportTest.php b/tests/units/Export/TaskExportTest.php
index c142cde9..ae6ca308 100644
--- a/tests/units/Export/TaskExportTest.php
+++ b/tests/units/Export/TaskExportTest.php
@@ -12,44 +12,70 @@ class TaskExportTest extends Base
{
public function testExport()
{
- $tc = new TaskCreationModel($this->container);
- $p = new ProjectModel($this->container);
- $c = new CategoryModel($this->container);
- $e = new TaskExport($this->container);
- $s = new SwimlaneModel($this->container);
-
- $this->assertEquals(1, $p->create(array('name' => 'Export Project')));
-
- $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'S1')));
- $this->assertEquals(2, $s->create(array('project_id' => 1, 'name' => 'S2')));
-
- $this->assertNotFalse($c->create(array('name' => 'Category #1', 'project_id' => 1)));
- $this->assertNotFalse($c->create(array('name' => 'Category #2', 'project_id' => 1)));
- $this->assertNotFalse($c->create(array('name' => 'Category #3', 'project_id' => 1)));
-
- for ($i = 1; $i <= 100; $i++) {
- $task = array(
- 'title' => 'Task #'.$i,
- 'project_id' => 1,
- 'column_id' => rand(1, 3),
- 'creator_id' => rand(0, 1),
- 'owner_id' => rand(0, 1),
- 'color_id' => rand(0, 1) === 0 ? 'green' : 'purple',
- 'category_id' => rand(0, 3),
- 'date_due' => array_rand(array(0, date('Y-m-d'), date('Y-m-d', strtotime('+'.$i.'day')))),
- 'score' => rand(0, 21),
- 'swimlane_id' => rand(0, 2),
- );
-
- $this->assertEquals($i, $tc->create($task));
- }
-
- $rows = $e->export(1, strtotime('-1 day'), strtotime('+1 day'));
-
- $this->assertEquals($i, count($rows));
- $this->assertEquals('Task Id', $rows[0][0]);
- $this->assertEquals(1, $rows[1][0]);
- $this->assertEquals('Task #'.($i - 1), $rows[$i - 1][13]);
- $this->assertTrue(in_array($rows[$i - 1][4], array('Default swimlane', 'S1', 'S2')));
+ $taskCreationModel = new TaskCreationModel($this->container);
+ $projectModel = new ProjectModel($this->container);
+ $categoryModel = new CategoryModel($this->container);
+ $taskExport = new TaskExport($this->container);
+ $swimlaneModel = new SwimlaneModel($this->container);
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'Export Project')));
+ $this->assertEquals(1, $swimlaneModel->create(array('project_id' => 1, 'name' => 'S1')));
+ $this->assertEquals(1, $categoryModel->create(array('name' => 'Category #1', 'project_id' => 1)));
+
+ $this->assertEquals(1, $taskCreationModel->create(array(
+ 'project_id' => 1,
+ 'column_id' => 2,
+ 'category_id' => 1,
+ 'reference' => 'REF1',
+ 'title' => 'Task 1',
+ 'time_estimated' => 2.5,
+ 'time_spent' => 3,
+ )));
+
+ $this->assertEquals(2, $taskCreationModel->create(array(
+ 'project_id' => 1,
+ 'swimlane_id' => 1,
+ 'title' => 'Task 2',
+ 'date_due' => time(),
+ )));
+
+ $report = $taskExport->export(1, date('Y-m-d'), date('Y-m-d'));
+
+ $this->assertCount(3, $report);
+ $this->assertCount(22, $report[0]);
+ $this->assertEquals('Task Id', $report[0][0]);
+
+ $this->assertEquals(1, $report[1][0]);
+ $this->assertEquals(2, $report[2][0]);
+
+ $this->assertEquals('REF1', $report[1][1]);
+ $this->assertEquals('', $report[2][1]);
+
+ $this->assertEquals('Export Project', $report[1][2]);
+ $this->assertEquals('Export Project', $report[2][2]);
+
+ $this->assertEquals('Open', $report[1][3]);
+ $this->assertEquals('Open', $report[2][3]);
+
+ $this->assertEquals('Category #1', $report[1][4]);
+ $this->assertEquals('', $report[2][4]);
+
+ $this->assertEquals('Default swimlane', $report[1][5]);
+ $this->assertEquals('S1', $report[2][5]);
+
+ $this->assertEquals('Ready', $report[1][6]);
+ $this->assertEquals('Backlog', $report[2][6]);
+
+ $this->assertEquals('Yellow', $report[1][8]);
+ $this->assertEquals('Yellow', $report[2][8]);
+
+ $this->assertEquals('', $report[1][9]);
+ $this->assertEquals(date('m/d/Y').' 00:00', $report[2][9]);
+
+ $this->assertEquals(3, $report[1][21]);
+ $this->assertEquals(0, $report[2][21]);
+
+ $this->assertEquals(2.5, $report[1][20]);
+ $this->assertEquals(0, $report[2][20]);
}
}