summaryrefslogtreecommitdiff
path: root/tests/units/Export/TaskExportTest.php
blob: ca0fb8deac3a01ed77a394aeb90153c2b7ba000f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php

require_once __DIR__ . '/../Base.php';

use Kanboard\Model\TaskCreationModel;
use Kanboard\Export\TaskExport;
use Kanboard\Model\ProjectModel;
use Kanboard\Model\CategoryModel;
use Kanboard\Model\SwimlaneModel;

class TaskExportTest extends Base
{
    public function testExport()
    {
        $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(2, $swimlaneModel->create(1, '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' => 2,
            'title' => 'Task 2',
            'date_due' => time(),
            'tags' => array('tag 1', 'tag 2'),
        )));

        $report = $taskExport->export(1, date('Y-m-d'), date('Y-m-d'));

        $this->assertCount(3, $report);
        $this->assertCount(24, $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 H:i'), $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]);

        $this->assertEquals('tag 1, tag 2', $report[2][23]);
    }
}