Exemple #1
0
 public function testSaveApplicationUrl()
 {
     $c = new Config($this->container);
     $this->assertTrue($c->save(array('application_url' => 'http://localhost/')));
     $this->assertEquals('http://localhost/', $c->get('application_url'));
     $this->assertTrue($c->save(array('application_url' => 'http://localhost')));
     $this->assertEquals('http://localhost/', $c->get('application_url'));
     $this->assertTrue($c->save(array('application_url' => '')));
     $this->assertEquals('', $c->get('application_url'));
 }
Exemple #2
0
 public function testCreation()
 {
     $p = new Project($this->container);
     $b = new Board($this->container);
     $c = new Config($this->container);
     // Default columns
     $this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
     $columns = $b->getColumnsList(1);
     $this->assertTrue(is_array($columns));
     $this->assertEquals(4, count($columns));
     $this->assertEquals('Backlog', $columns[1]);
     $this->assertEquals('Ready', $columns[2]);
     $this->assertEquals('Work in progress', $columns[3]);
     $this->assertEquals('Done', $columns[4]);
     // Custom columns: spaces should be trimed and no empty columns
     $input = '   column #1  , column #2, ';
     $this->assertTrue($c->save(array('board_columns' => $input)));
     $this->assertEquals($input, $c->get('board_columns'));
     $this->assertEquals(2, $p->create(array('name' => 'UnitTest2')));
     $columns = $b->getColumnsList(2);
     $this->assertTrue(is_array($columns));
     $this->assertEquals(2, count($columns));
     $this->assertEquals('column #1', $columns[5]);
     $this->assertEquals('column #2', $columns[6]);
 }
 public function testCustomCss()
 {
     $h = new Asset($this->container);
     $c = new Config($this->container);
     $this->assertEmpty($h->customCss());
     $this->assertTrue($c->save(array('application_stylesheet' => 'p { color: red }')));
     $this->assertEquals('<style>p { color: red }</style>', $h->customCss());
 }
Exemple #4
0
 public function testCreationWithDefaultCategories()
 {
     $p = new Project($this->container);
     $c = new Config($this->container);
     $cat = new Category($this->container);
     // Multiple categories correctly formatted
     $this->assertTrue($c->save(array('project_categories' => 'Test1, Test2')));
     $this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
     $project = $p->getById(1);
     $this->assertNotEmpty($project);
     $categories = $cat->getAll(1);
     $this->assertNotEmpty($categories);
     $this->assertEquals(2, count($categories));
     $this->assertEquals('Test1', $categories[0]['name']);
     $this->assertEquals('Test2', $categories[1]['name']);
     // Single category
     $this->assertTrue($c->save(array('project_categories' => 'Test1')));
     $this->assertEquals(2, $p->create(array('name' => 'UnitTest2')));
     $project = $p->getById(2);
     $this->assertNotEmpty($project);
     $categories = $cat->getAll(2);
     $this->assertNotEmpty($categories);
     $this->assertEquals(1, count($categories));
     $this->assertEquals('Test1', $categories[0]['name']);
     // Multiple categories badly formatted
     $this->assertTrue($c->save(array('project_categories' => 'ABC, , DEF 3,  ')));
     $this->assertEquals(3, $p->create(array('name' => 'UnitTest3')));
     $project = $p->getById(3);
     $this->assertNotEmpty($project);
     $categories = $cat->getAll(3);
     $this->assertNotEmpty($categories);
     $this->assertEquals(2, count($categories));
     $this->assertEquals('ABC', $categories[0]['name']);
     $this->assertEquals('DEF 3', $categories[1]['name']);
     // No default categories
     $this->assertTrue($c->save(array('project_categories' => '  ')));
     $this->assertEquals(4, $p->create(array('name' => 'UnitTest4')));
     $project = $p->getById(4);
     $this->assertNotEmpty($project);
     $categories = $cat->getAll(4);
     $this->assertEmpty($categories);
 }
Exemple #5
0
 public function testBase()
 {
     $h = new Url($this->container);
     $_SERVER['PHP_SELF'] = '/';
     $_SERVER['SERVER_NAME'] = 'localhost';
     $_SERVER['SERVER_PORT'] = 1234;
     $this->assertEquals('http://localhost:1234/', $h->base());
     $c = new Config($this->container);
     $c->save(array('application_url' => 'https://mykanboard/'));
     $this->assertEquals('https://mykanboard/', $c->get('application_url'));
     $this->assertEquals('https://mykanboard/', $h->base());
 }
 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);
 }
Exemple #7
0
 public function testCommentCreation()
 {
     $c = new Config($this->container);
     $p = new Project($this->container);
     $tc = new TaskCreation($this->container);
     $cm = new Comment($this->container);
     $this->container['dispatcher']->addSubscriber(new WebhookSubscriber($this->container));
     $c->save(array('webhook_url' => 'http://localhost/comment'));
     $this->assertEquals(1, $p->create(array('name' => 'test')));
     $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test')));
     $this->assertEquals(1, $cm->create(array('task_id' => 1, 'comment' => 'test comment', 'user_id' => 1)));
     $this->assertStringStartsWith('http://localhost/comment?token=', $this->container['httpClient']->getUrl());
     $event = $this->container['httpClient']->getData();
     $this->assertNotEmpty($event);
     $this->assertArrayHasKey('event_name', $event);
     $this->assertArrayHasKey('event_data', $event);
     $this->assertEquals('comment.create', $event['event_name']);
     $this->assertNotEmpty($event['event_data']);
     $this->assertArrayHasKey('task_id', $event['event_data']);
     $this->assertArrayHasKey('user_id', $event['event_data']);
     $this->assertArrayHasKey('comment', $event['event_data']);
     $this->assertArrayHasKey('id', $event['event_data']);
     $this->assertEquals('test comment', $event['event_data']['comment']);
 }
 public function testDefaultColor()
 {
     $p = new Project($this->container);
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $c = new Config($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'test')));
     $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test1')));
     $task = $tf->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEquals('yellow', $task['color_id']);
     $this->assertTrue($c->save(array('default_color' => 'orange')));
     $this->assertEquals(2, $tc->create(array('project_id' => 1, 'title' => 'test2')));
     $task = $tf->getById(2);
     $this->assertNotEmpty($task);
     $this->assertEquals('orange', $task['color_id']);
 }