summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/units/Formatter/TaskFilterCalendarFormatterTest.php29
-rw-r--r--tests/units/Formatter/TaskFilterGanttFormatterTest.php24
-rw-r--r--tests/units/Formatter/TaskFilterICalendarFormatterTest.php77
-rw-r--r--tests/units/Model/TaskFilterTest.php64
4 files changed, 130 insertions, 64 deletions
diff --git a/tests/units/Formatter/TaskFilterCalendarFormatterTest.php b/tests/units/Formatter/TaskFilterCalendarFormatterTest.php
new file mode 100644
index 00000000..2ea327ff
--- /dev/null
+++ b/tests/units/Formatter/TaskFilterCalendarFormatterTest.php
@@ -0,0 +1,29 @@
+<?php
+
+require_once __DIR__.'/../Base.php';
+
+use Formatter\TaskFilterCalendarFormatter;
+use Model\Project;
+use Model\User;
+use Model\TaskCreation;
+use Model\DateParser;
+use Model\Category;
+use Model\Subtask;
+use Model\Config;
+use Model\Swimlane;
+
+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());
+ }
+}
diff --git a/tests/units/Formatter/TaskFilterGanttFormatterTest.php b/tests/units/Formatter/TaskFilterGanttFormatterTest.php
new file mode 100644
index 00000000..9006e164
--- /dev/null
+++ b/tests/units/Formatter/TaskFilterGanttFormatterTest.php
@@ -0,0 +1,24 @@
+<?php
+
+require_once __DIR__.'/../Base.php';
+
+use Formatter\TaskFilterGanttFormatter;
+use Model\Project;
+use Model\TaskCreation;
+use Model\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());
+ }
+}
diff --git a/tests/units/Formatter/TaskFilterICalendarFormatterTest.php b/tests/units/Formatter/TaskFilterICalendarFormatterTest.php
new file mode 100644
index 00000000..17602520
--- /dev/null
+++ b/tests/units/Formatter/TaskFilterICalendarFormatterTest.php
@@ -0,0 +1,77 @@
+<?php
+
+require_once __DIR__.'/../Base.php';
+
+use Eluceo\iCal\Component\Calendar;
+use Formatter\TaskFilterICalendarFormatter;
+use Model\Project;
+use Model\User;
+use Model\TaskCreation;
+use Model\DateParser;
+use Model\Category;
+use Model\Subtask;
+use Model\Config;
+use Model\Swimlane;
+
+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);
+ }
+}
diff --git a/tests/units/Model/TaskFilterTest.php b/tests/units/Model/TaskFilterTest.php
index 1987265d..28b5d24a 100644
--- a/tests/units/Model/TaskFilterTest.php
+++ b/tests/units/Model/TaskFilterTest.php
@@ -14,70 +14,6 @@ use Model\Swimlane;
class TaskFilterTest extends Base
{
- public function testGetGanttbar()
- {
- $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' => 'task1')));
-
- $this->assertNotEmpty($tf->search('status:open')->toGanttBars());
- $this->assertNotEmpty($p->getGanttBars(array(1)));
- }
-
- public function testIcalEventsWithCreatorAndDueDate()
- {
- $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' => 'task1', 'creator_id' => 1, 'date_due' => $dp->getTimestampFromIsoFormat('-2 days'))));
-
- $events = $tf->create()->filterByDueDateRange(strtotime('-1 month'), strtotime('+1 month'))->addAllDayIcalEvents();
- $ics = $events->render();
-
- $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 TaskFilter($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'))));
-
- $events = $tf->create()->filterByDueDateRange(strtotime('-1 month'), strtotime('+1 month'))->addAllDayIcalEvents();
- $ics = $events->render();
-
- $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 testSearchWithEmptyResult()
{
$dp = new DateParser($this->container);