Set the assignee as organizer for ical events

This commit is contained in:
Frederic Guillot
2015-07-05 12:23:00 -04:00
parent 45774afafc
commit 4438e03c62
6 changed files with 94 additions and 13 deletions

View File

@@ -58,6 +58,8 @@ abstract class Base extends PHPUnit_Framework_TestCase
public function setUp()
{
date_default_timezone_set('UTC');
if (DB_DRIVER === 'mysql') {
$pdo = new PDO('mysql:host='.DB_HOSTNAME, DB_USERNAME, DB_PASSWORD);
$pdo->exec('DROP DATABASE '.DB_NAME);

View File

@@ -8,9 +8,60 @@ use Model\TaskFilter;
use Model\TaskCreation;
use Model\DateParser;
use Model\Category;
use Model\Config;
class TaskFilterTest extends Base
{
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:MAILTO:bob@localhost', $ics);
$this->assertContains('X-MICROSOFT-CDO-ALLDAYEVENT:TRUE', $ics);
}
public function testSearchWithEmptyResult()
{
$dp = new DateParser($this->container);

View File

@@ -38,22 +38,26 @@ class UrlHelperTest extends Base
{
$h = new Url($this->container);
$this->assertEquals('http://localhost/', $h->server());
$_SERVER['PHP_SELF'] = '/';
$_SERVER['SERVER_NAME'] = 'localhost';
$_SERVER['SERVER_NAME'] = 'kb';
$_SERVER['SERVER_PORT'] = 1234;
$this->assertEquals('http://localhost:1234/', $h->server());
$this->assertEquals('http://kb:1234/', $h->server());
}
public function testBase()
{
$h = new Url($this->container);
$this->assertEquals('http://localhost/', $h->base());
$_SERVER['PHP_SELF'] = '/';
$_SERVER['SERVER_NAME'] = 'localhost';
$_SERVER['SERVER_NAME'] = 'kb';
$_SERVER['SERVER_PORT'] = 1234;
$this->assertEquals('http://localhost:1234/', $h->base());
$this->assertEquals('http://kb:1234/', $h->base());
$c = new Config($this->container);
$c->save(array('application_url' => 'https://mykanboard/'));