public function testConvert() { $d = new DateParser($this->container); $values = array('date_due' => '2015-01-25', 'date_started' => '2015_01_25'); $d->convert($values, array('date_due', 'date_started')); $this->assertEquals(mktime(0, 0, 0, 1, 25, 2015), $values['date_due']); $this->assertEquals('2015-01-25', date('Y-m-d', $values['date_due'])); $this->assertEquals(mktime(0, 0, 0, 1, 25, 2015), $values['date_started']); $this->assertEquals('2015-01-25', date('Y-m-d', $values['date_started'])); }
/** * Apply a date filter * * @access protected * @param string $field */ protected function applyDateFilter($field) { $method = $this->parseOperator(); $timestamp = $this->dateParser->getTimestampFromIsoFormat($this->value); if ($method !== '') { $this->query->{$method}($field, $this->getTimestampFromOperator($method, $timestamp)); } else { $this->query->gte($field, $timestamp); $this->query->lte($field, $timestamp + 86399); } }
public function testIcalEventsWithAssigneeAndDueDate() { $dp = new DateParser($this->container); $p = new Project($this->container); $tc = new TaskCreation($this->container); $tf = new TaskFilterICalendarFormatter($this->container); $u = new User($this->container); $c = new Config($this->container); $this->assertNotFalse($c->save(array('application_url' => 'http://kb/'))); $this->assertEquals('http://kb/', $c->get('application_url')); $this->assertNotFalse($u->update(array('id' => 1, 'email' => 'bob@localhost'))); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'task1', 'owner_id' => 1, 'date_due' => $dp->getTimestampFromIsoFormat('+5 days')))); $ics = $tf->create()->filterByDueDateRange(strtotime('-1 month'), strtotime('+1 month'))->setFullDay()->setCalendar(new Calendar('Kanboard'))->setColumns('date_due')->addFullDayEvents()->format(); $this->assertContains('UID:task-#1-date_due', $ics); $this->assertContains('DTSTART;TZID=UTC;VALUE=DATE:' . date('Ymd', strtotime('+5 days')), $ics); $this->assertContains('DTEND;TZID=UTC;VALUE=DATE:' . date('Ymd', strtotime('+5 days')), $ics); $this->assertContains('URL:http://kb/?controller=task&action=show&task_id=1&project_id=1', $ics); $this->assertContains('SUMMARY:#1 task1', $ics); $this->assertContains('ORGANIZER;CN=admin:MAILTO:bob@localhost', $ics); $this->assertContains('X-MICROSOFT-CDO-ALLDAYEVENT:TRUE', $ics); }
public function testSearchWithDueDate() { $dp = new DateParser($this->container); $p = new Project($this->container); $tc = new TaskCreation($this->container); $tf = new TaskFilter($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'my task title is awesome', 'date_due' => $dp->getTimestampFromIsoFormat('-2 days')))); $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'my task title is amazing', 'date_due' => $dp->getTimestampFromIsoFormat('+1 day')))); $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'Bob at work', 'date_due' => $dp->getTimestampFromIsoFormat('-1 day')))); $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'youpi', 'date_due' => $dp->getTimestampFromIsoFormat(time())))); $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'no due date'))); $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'due date at 0', 'date_due' => 0))); $tf->search('due:>' . date('Y-m-d')); $tasks = $tf->findAll(); $this->assertNotEmpty($tasks); $this->assertCount(1, $tasks); $this->assertEquals('my task title is amazing', $tasks[0]['title']); $tf->search('due:>=' . date('Y-m-d')); $tasks = $tf->findAll(); $this->assertNotEmpty($tasks); $this->assertCount(2, $tasks); $this->assertEquals('my task title is amazing', $tasks[0]['title']); $this->assertEquals('youpi', $tasks[1]['title']); $tf->search('due:<' . date('Y-m-d')); $tasks = $tf->findAll(); $this->assertNotEmpty($tasks); $this->assertCount(2, $tasks); $this->assertEquals('my task title is awesome', $tasks[0]['title']); $this->assertEquals('Bob at work', $tasks[1]['title']); $tf->search('due:<=' . date('Y-m-d')); $tasks = $tf->findAll(); $this->assertNotEmpty($tasks); $this->assertCount(3, $tasks); $this->assertEquals('my task title is awesome', $tasks[0]['title']); $this->assertEquals('Bob at work', $tasks[1]['title']); $this->assertEquals('youpi', $tasks[2]['title']); $tf->search('due:tomorrow'); $tasks = $tf->findAll(); $this->assertNotEmpty($tasks); $this->assertCount(1, $tasks); $this->assertEquals('my task title is amazing', $tasks[0]['title']); $tf->search('due:yesterday'); $tasks = $tf->findAll(); $this->assertNotEmpty($tasks); $this->assertCount(1, $tasks); $this->assertEquals('Bob at work', $tasks[0]['title']); $tf->search('due:today'); $tasks = $tf->findAll(); $this->assertNotEmpty($tasks); $this->assertCount(1, $tasks); $this->assertEquals('youpi', $tasks[0]['title']); }
public function testDuplicateRecurringTask() { $td = new TaskDuplication($this->container); $tc = new TaskCreation($this->container); $tf = new TaskFinder($this->container); $p = new Project($this->container); $c = new Category($this->container); $dp = new DateParser($this->container); $this->assertEquals(1, $p->create(array('name' => 'test1'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'date_due' => 1436561776, 'recurrence_status' => Task::RECURRING_STATUS_PENDING, 'recurrence_trigger' => Task::RECURRING_TRIGGER_CLOSE, 'recurrence_factor' => 2, 'recurrence_timeframe' => Task::RECURRING_TIMEFRAME_DAYS, 'recurrence_basedate' => Task::RECURRING_BASEDATE_TRIGGERDATE))); $this->assertEquals(2, $td->duplicateRecurringTask(1)); $task = $tf->getById(1); $this->assertNotEmpty($task); $this->assertEquals(Task::RECURRING_STATUS_PROCESSED, $task['recurrence_status']); $this->assertEquals(2, $task['recurrence_child']); $this->assertEquals(1436486400, $task['date_due'], '', 2); $task = $tf->getById(2); $this->assertNotEmpty($task); $this->assertEquals(Task::RECURRING_STATUS_PENDING, $task['recurrence_status']); $this->assertEquals(Task::RECURRING_TRIGGER_CLOSE, $task['recurrence_trigger']); $this->assertEquals(Task::RECURRING_TIMEFRAME_DAYS, $task['recurrence_timeframe']); $this->assertEquals(Task::RECURRING_BASEDATE_TRIGGERDATE, $task['recurrence_basedate']); $this->assertEquals(1, $task['recurrence_parent']); $this->assertEquals(2, $task['recurrence_factor']); $this->assertEquals($dp->removeTimeFromTimestamp(strtotime('+2 days')), $task['date_due'], '', 2); }
public function testConvert() { $dateParser = new DateParser($this->container); $values = array('date_due' => '2015-01-25', 'date_started' => '2015-01-25 17:25'); $this->assertEquals(array('date_due' => 1422144000, 'date_started' => 1422144000), $dateParser->convert($values, array('date_due', 'date_started'))); $values = array('date_started' => '2015-01-25 17:25'); $this->assertEquals(array('date_started' => 1422206700), $dateParser->convert($values, array('date_due', 'date_started'), true)); }