Filter refactoring

This commit is contained in:
Frederic Guillot
2016-04-09 22:42:17 -04:00
parent 42813d702d
commit 11858be4e8
101 changed files with 3235 additions and 2841 deletions

View File

@@ -1,21 +0,0 @@
<?php
require_once __DIR__.'/../Base.php';
use Kanboard\Formatter\TaskFilterCalendarFormatter;
class TaskFilterCalendarFormatterTest extends Base
{
public function testCopy()
{
$tf = new TaskFilterCalendarFormatter($this->container);
$filter1 = $tf->create()->setFullDay();
$filter2 = $tf->copy();
$this->assertTrue($filter1 !== $filter2);
$this->assertTrue($filter1->query !== $filter2->query);
$this->assertTrue($filter1->query->condition !== $filter2->query->condition);
$this->assertTrue($filter1->isFullDay());
$this->assertFalse($filter2->isFullDay());
}
}

View File

@@ -1,24 +0,0 @@
<?php
require_once __DIR__.'/../Base.php';
use Kanboard\Formatter\TaskFilterGanttFormatter;
use Kanboard\Model\Project;
use Kanboard\Model\TaskCreation;
use Kanboard\Core\DateParser;
class TaskFilterGanttFormatterTest extends Base
{
public function testFormat()
{
$dp = new DateParser($this->container);
$p = new Project($this->container);
$tc = new TaskCreation($this->container);
$tf = new TaskFilterGanttFormatter($this->container);
$this->assertEquals(1, $p->create(array('name' => 'test')));
$this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'task1')));
$this->assertNotEmpty($tf->search('status:open')->format());
}
}

View File

@@ -1,74 +0,0 @@
<?php
require_once __DIR__.'/../Base.php';
use Eluceo\iCal\Component\Calendar;
use Kanboard\Formatter\TaskFilterICalendarFormatter;
use Kanboard\Model\Project;
use Kanboard\Model\User;
use Kanboard\Model\TaskCreation;
use Kanboard\Core\DateParser;
use Kanboard\Model\Config;
class TaskFilterICalendarFormatterTest extends Base
{
public function testIcalEventsWithCreatorAndDueDate()
{
$dp = new DateParser($this->container);
$p = new Project($this->container);
$tc = new TaskCreation($this->container);
$tf = new TaskFilterICalendarFormatter($this->container);
$this->assertEquals(1, $p->create(array('name' => 'test')));
$this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'task1', 'creator_id' => 1, 'date_due' => $dp->getTimestampFromIsoFormat('-2 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('-2 days')), $ics);
$this->assertContains('DTEND;TZID=UTC;VALUE=DATE:'.date('Ymd', strtotime('-2 days')), $ics);
$this->assertContains('URL:http://localhost/?controller=task&action=show&task_id=1&project_id=1', $ics);
$this->assertContains('SUMMARY:#1 task1', $ics);
$this->assertContains('ATTENDEE:MAILTO:admin@kanboard.local', $ics);
$this->assertContains('X-MICROSOFT-CDO-ALLDAYEVENT:TRUE', $ics);
}
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);
}
}