diff options
author | Gerardo Zamudio <gerardozamudio@users.noreply.github.com> | 2016-02-24 23:48:50 -0600 |
---|---|---|
committer | Gerardo Zamudio <gerardozamudio@users.noreply.github.com> | 2016-02-24 23:48:50 -0600 |
commit | e4de6b3898b64b26d29aff31f21df5fda8055686 (patch) | |
tree | 575f8a65440f291d70a070d168eafca8c82a6459 /tests/units/Analytic/TaskDistributionAnalyticTest.php | |
parent | d9ffbea174ea6524d0a22f8375ca8b3aa04a3c96 (diff) | |
parent | a6540bc604c837d92c9368540c145606723e97f7 (diff) |
Merge pull request #1 from fguillot/master
Update from upstream
Diffstat (limited to 'tests/units/Analytic/TaskDistributionAnalyticTest.php')
-rw-r--r-- | tests/units/Analytic/TaskDistributionAnalyticTest.php | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/units/Analytic/TaskDistributionAnalyticTest.php b/tests/units/Analytic/TaskDistributionAnalyticTest.php new file mode 100644 index 00000000..531101ef --- /dev/null +++ b/tests/units/Analytic/TaskDistributionAnalyticTest.php @@ -0,0 +1,62 @@ +<?php + +require_once __DIR__.'/../Base.php'; + +use Kanboard\Model\TaskCreation; +use Kanboard\Model\Project; +use Kanboard\Analytic\TaskDistributionAnalytic; + +class TaskDistributionAnalyticTest extends Base +{ + public function testBuild() + { + $projectModel = new Project($this->container); + $taskDistributionModel = new TaskDistributionAnalytic($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'test1'))); + $this->assertEquals(2, $projectModel->create(array('name' => 'test1'))); + + $this->createTasks(1, 20, 1); + $this->createTasks(2, 30, 1); + $this->createTasks(3, 40, 1); + $this->createTasks(4, 10, 1); + + $expected = array( + array( + 'column_title' => 'Backlog', + 'nb_tasks' => 20, + 'percentage' => 20.0, + ), + array( + 'column_title' => 'Ready', + 'nb_tasks' => 30, + 'percentage' => 30.0, + ), + array( + 'column_title' => 'Work in progress', + 'nb_tasks' => 40, + 'percentage' => 40.0, + ), + array( + 'column_title' => 'Done', + 'nb_tasks' => 10, + 'percentage' => 10.0, + ) + ); + + $this->assertEquals($expected, $taskDistributionModel->build(1)); + } + + private function createTasks($column_id, $nb_active, $nb_inactive) + { + $taskCreationModel = new TaskCreation($this->container); + + for ($i = 0; $i < $nb_active; $i++) { + $this->assertNotFalse($taskCreationModel->create(array('project_id' => 1, 'title' => 'test', 'column_id' => $column_id, 'is_active' => 1))); + } + + for ($i = 0; $i < $nb_inactive; $i++) { + $this->assertNotFalse($taskCreationModel->create(array('project_id' => 1, 'title' => 'test', 'column_id' => $column_id, 'is_active' => 0))); + } + } +} |