Esempio n. 1
0
 public function testGetTimestamp()
 {
     $d = new DateParser($this->container);
     $this->assertEquals('2014-03-05', date('Y-m-d', $d->getTimestamp('2014-03-05')));
     $this->assertEquals('2014-03-05', date('Y-m-d', $d->getTimestamp('2014_03_05')));
     $this->assertEquals('2014-03-05', date('Y-m-d', $d->getTimestamp('03/05/2014')));
 }
Esempio n. 2
0
 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']));
 }
 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']);
 }