Filter refactoring
This commit is contained in:
@@ -240,81 +240,4 @@ class SubtaskTimeTrackingTest extends Base
|
||||
$this->assertEquals(0, $task['time_estimated']);
|
||||
$this->assertEquals(0, $task['time_spent']);
|
||||
}
|
||||
|
||||
public function testGetCalendarEvents()
|
||||
{
|
||||
$tf = new TaskFinder($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$s = new Subtask($this->container);
|
||||
$st = new SubtaskTimeTracking($this->container);
|
||||
$p = new Project($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'test1')));
|
||||
$this->assertEquals(2, $p->create(array('name' => 'test2')));
|
||||
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'test 1', 'project_id' => 1)));
|
||||
$this->assertEquals(2, $tc->create(array('title' => 'test 1', 'project_id' => 2)));
|
||||
|
||||
$this->assertEquals(1, $s->create(array('title' => 'subtask #1', 'task_id' => 1)));
|
||||
$this->assertEquals(2, $s->create(array('title' => 'subtask #2', 'task_id' => 1)));
|
||||
$this->assertEquals(3, $s->create(array('title' => 'subtask #3', 'task_id' => 1)));
|
||||
|
||||
$this->assertEquals(4, $s->create(array('title' => 'subtask #4', 'task_id' => 2)));
|
||||
$this->assertEquals(5, $s->create(array('title' => 'subtask #5', 'task_id' => 2)));
|
||||
$this->assertEquals(6, $s->create(array('title' => 'subtask #6', 'task_id' => 2)));
|
||||
$this->assertEquals(7, $s->create(array('title' => 'subtask #7', 'task_id' => 2)));
|
||||
$this->assertEquals(8, $s->create(array('title' => 'subtask #8', 'task_id' => 2)));
|
||||
|
||||
// Slot start before and finish inside the calendar time range
|
||||
$this->container['db']->table(SubtaskTimeTracking::TABLE)->insert(array('user_id' => 1, 'subtask_id' => 1, 'start' => strtotime('-1 day'), 'end' => strtotime('+1 hour')));
|
||||
|
||||
// Slot start inside time range and finish after the time range
|
||||
$this->container['db']->table(SubtaskTimeTracking::TABLE)->insert(array('user_id' => 1, 'subtask_id' => 2, 'start' => strtotime('+1 hour'), 'end' => strtotime('+2 days')));
|
||||
|
||||
// Start before time range and finish inside time range
|
||||
$this->container['db']->table(SubtaskTimeTracking::TABLE)->insert(array('user_id' => 1, 'subtask_id' => 3, 'start' => strtotime('-1 day'), 'end' => strtotime('+1.5 days')));
|
||||
|
||||
// Start and finish inside time range
|
||||
$this->container['db']->table(SubtaskTimeTracking::TABLE)->insert(array('user_id' => 1, 'subtask_id' => 4, 'start' => strtotime('+1 hour'), 'end' => strtotime('+2 hours')));
|
||||
|
||||
// Start and finish after the time range
|
||||
$this->container['db']->table(SubtaskTimeTracking::TABLE)->insert(array('user_id' => 1, 'subtask_id' => 5, 'start' => strtotime('+2 days'), 'end' => strtotime('+3 days')));
|
||||
|
||||
// Start and finish before the time range
|
||||
$this->container['db']->table(SubtaskTimeTracking::TABLE)->insert(array('user_id' => 1, 'subtask_id' => 6, 'start' => strtotime('-2 days'), 'end' => strtotime('-1 day')));
|
||||
|
||||
// Start before time range and not finished
|
||||
$this->container['db']->table(SubtaskTimeTracking::TABLE)->insert(array('user_id' => 1, 'subtask_id' => 7, 'start' => strtotime('-1 day')));
|
||||
|
||||
// Start inside time range and not finish
|
||||
$this->container['db']->table(SubtaskTimeTracking::TABLE)->insert(array('user_id' => 1, 'subtask_id' => 8, 'start' => strtotime('+3200 seconds')));
|
||||
|
||||
$timesheet = $st->getUserTimesheet(1);
|
||||
$this->assertNotEmpty($timesheet);
|
||||
$this->assertCount(8, $timesheet);
|
||||
|
||||
$events = $st->getUserCalendarEvents(1, date('Y-m-d'), date('Y-m-d', strtotime('+2 day')));
|
||||
$this->assertNotEmpty($events);
|
||||
$this->assertCount(6, $events);
|
||||
$this->assertEquals(1, $events[0]['subtask_id']);
|
||||
$this->assertEquals(2, $events[1]['subtask_id']);
|
||||
$this->assertEquals(3, $events[2]['subtask_id']);
|
||||
$this->assertEquals(4, $events[3]['subtask_id']);
|
||||
$this->assertEquals(7, $events[4]['subtask_id']);
|
||||
$this->assertEquals(8, $events[5]['subtask_id']);
|
||||
|
||||
$events = $st->getProjectCalendarEvents(1, date('Y-m-d'), date('Y-m-d', strtotime('+2 days')));
|
||||
$this->assertNotEmpty($events);
|
||||
$this->assertCount(3, $events);
|
||||
$this->assertEquals(1, $events[0]['subtask_id']);
|
||||
$this->assertEquals(2, $events[1]['subtask_id']);
|
||||
$this->assertEquals(3, $events[2]['subtask_id']);
|
||||
|
||||
$events = $st->getProjectCalendarEvents(2, date('Y-m-d'), date('Y-m-d', strtotime('+2 days')));
|
||||
$this->assertNotEmpty($events);
|
||||
$this->assertCount(3, $events);
|
||||
$this->assertEquals(4, $events[0]['subtask_id']);
|
||||
$this->assertEquals(7, $events[1]['subtask_id']);
|
||||
$this->assertEquals(8, $events[2]['subtask_id']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user