From acba6839a6082e3e3800a733f8baea7c843fc02e Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Sat, 11 Oct 2014 21:11:10 -0400 Subject: Add 3 new fields for tasks: start date, time estimated and time spent --- tests/functionals.mysql.xml | 2 +- tests/functionals.postgres.xml | 2 +- tests/functionals.sqlite.xml | 2 +- tests/units.postgres.xml | 1 + tests/units/TimeTrackingTest.php | 44 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 tests/units/TimeTrackingTest.php (limited to 'tests') diff --git a/tests/functionals.mysql.xml b/tests/functionals.mysql.xml index aa5b6ec1..f667cafa 100644 --- a/tests/functionals.mysql.xml +++ b/tests/functionals.mysql.xml @@ -5,7 +5,7 @@ - + diff --git a/tests/functionals.postgres.xml b/tests/functionals.postgres.xml index ecfe72ef..38904d1a 100644 --- a/tests/functionals.postgres.xml +++ b/tests/functionals.postgres.xml @@ -5,7 +5,7 @@ - + diff --git a/tests/functionals.sqlite.xml b/tests/functionals.sqlite.xml index 62aa94c3..bf5d4117 100644 --- a/tests/functionals.sqlite.xml +++ b/tests/functionals.sqlite.xml @@ -5,7 +5,7 @@ - + diff --git a/tests/units.postgres.xml b/tests/units.postgres.xml index 0583c7f8..22e09c03 100644 --- a/tests/units.postgres.xml +++ b/tests/units.postgres.xml @@ -7,6 +7,7 @@ + \ No newline at end of file diff --git a/tests/units/TimeTrackingTest.php b/tests/units/TimeTrackingTest.php new file mode 100644 index 00000000..50d5cb53 --- /dev/null +++ b/tests/units/TimeTrackingTest.php @@ -0,0 +1,44 @@ +registry); + $p = new Project($this->registry); + $s = new SubTask($this->registry); + $ts = new TimeTracking($this->registry); + + $this->assertEquals(1, $p->create(array('name' => 'Project #1'))); + $this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'time_estimated' => 4.5))); + $this->assertTrue($t->update(array('id' => 1, 'time_spent' => 3.5))); + + $task = $t->getById(1); + $this->assertNotEmpty($task); + $this->assertEquals(4.5, $task['time_estimated']); + $this->assertEquals(3.5, $task['time_spent']); + + $timesheet = $ts->getTaskTimesheet($task, array()); + $this->assertNotEmpty($timesheet); + $this->assertEquals(4.5, $timesheet['time_estimated']); + $this->assertEquals(3.5, $timesheet['time_spent']); + $this->assertEquals(1, $timesheet['time_remaining']); + + // Subtasks calculation + $this->assertEquals(1, $s->create(array('title' => 'subtask #1', 'task_id' => 1, 'time_estimated' => 5.5, 'time_spent' => 3))); + $this->assertEquals(2, $s->create(array('title' => 'subtask #2', 'task_id' => 1, 'time_estimated' => '', 'time_spent' => 4))); + + $timesheet = $ts->getTaskTimesheet($task, $s->getAll(1)); + $this->assertNotEmpty($timesheet); + $this->assertEquals(5.5, $timesheet['time_estimated']); + $this->assertEquals(7, $timesheet['time_spent']); + $this->assertEquals(-1.5, $timesheet['time_remaining']); + } +} -- cgit v1.2.3