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')); }
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->container['memoryCache']->flush(); $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()); }
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->container['memoryCache']->flush(); $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->container['memoryCache']->flush(); $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->container['memoryCache']->flush(); $this->assertEquals(4, $p->create(array('name' => 'UnitTest4'))); $project = $p->getById(4); $this->assertNotEmpty($project); $categories = $cat->getAll(4); $this->assertEmpty($categories); }
public function testGetDefaultColor() { $colorModel = new Color($this->container); $configModel = new Config($this->container); $this->assertEquals('yellow', $colorModel->getDefaultColor()); $this->container['memoryCache']->flush(); $this->assertTrue($configModel->save(array('default_color' => 'red'))); $this->assertEquals('red', $colorModel->getDefaultColor()); }
public function testTaskCreation() { $c = new Config($this->container); $p = new Project($this->container); $tc = new TaskCreation($this->container); $this->container['dispatcher']->addSubscriber(new NotificationSubscriber($this->container)); $c->save(array('webhook_url' => 'http://localhost/?task-creation')); $this->container['httpClient']->expects($this->once())->method('postJson')->with($this->stringContains('http://localhost/?task-creation&token='), $this->anything()); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test'))); }
public function testBase() { $this->container['request'] = new Request($this->container, array('PHP_SELF' => '/index.php', 'REQUEST_METHOD' => 'GET', 'SERVER_NAME' => 'kb', 'SERVER_PORT' => 1234)); $h = new Url($this->container); $this->assertEquals('http://kb:1234/', $h->base()); $c = new Config($this->container); $c->save(array('application_url' => 'https://mykanboard/')); $h = new Url($this->container); $this->assertEquals('https://mykanboard/', $c->get('application_url')); $this->assertEquals('https://mykanboard/', $h->base()); }
public function testBase() { $h = new Url($this->container); $this->assertEquals('http://localhost/', $h->base()); $_SERVER['PHP_SELF'] = '/'; $_SERVER['SERVER_NAME'] = 'kb'; $_SERVER['SERVER_PORT'] = 1234; $h = new Url($this->container); $this->assertEquals('http://kb:1234/', $h->base()); $c = new Config($this->container); $c->save(array('application_url' => 'https://mykanboard/')); $h = new Url($this->container); $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); }
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 NotificationSubscriber($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']['comment']); $this->assertArrayHasKey('user_id', $event['event_data']['comment']); $this->assertArrayHasKey('comment', $event['event_data']['comment']); $this->assertArrayHasKey('id', $event['event_data']['comment']); $this->assertEquals('test comment', $event['event_data']['comment']['comment']); }
public function testUpdateTotalsWithOnlyOpenTasks() { $configModel = new Config($this->container); $projectModel = new Project($this->container); $projectDailyColumnStats = new ProjectDailyColumnStats($this->container); $this->assertEquals(1, $projectModel->create(array('name' => 'UnitTest'))); $this->assertTrue($configModel->save(array('cfd_include_closed_tasks' => 0))); $this->container['memoryCache']->flush(); $this->createTasks(1, 2, 1); $this->createTasks(1, 3, 0); $this->createTasks(2, 5, 1); $this->createTasks(2, 8, 1); $this->createTasks(2, 0, 0); $this->createTasks(2, 0, 0); $projectDailyColumnStats->updateTotals(1, '2016-01-16'); $this->createTasks(1, 9, 1); $this->createTasks(1, 7, 0); $projectDailyColumnStats->updateTotals(1, '2016-01-16'); $this->createTasks(3, 0, 1); $projectDailyColumnStats->updateTotals(1, '2016-01-17'); $stats = $this->container['db']->table(ProjectDailyColumnStats::TABLE)->asc('day')->asc('column_id')->columns('day', 'project_id', 'column_id', 'total', 'score')->findAll(); $expected = array(array('day' => '2016-01-16', 'project_id' => 1, 'column_id' => 1, 'total' => 2, 'score' => 11), array('day' => '2016-01-16', 'project_id' => 1, 'column_id' => 2, 'total' => 2, 'score' => 13), array('day' => '2016-01-17', 'project_id' => 1, 'column_id' => 1, 'total' => 2, 'score' => 11), array('day' => '2016-01-17', 'project_id' => 1, 'column_id' => 2, 'total' => 2, 'score' => 13), array('day' => '2016-01-17', 'project_id' => 1, 'column_id' => 3, 'total' => 1, 'score' => 0)); $this->assertEquals($expected, $stats); }
public function testCreateDefaultCategories() { $projectModel = new Project($this->container); $categoryModel = new Category($this->container); $configModel = new Config($this->container); $this->assertTrue($configModel->save(array('project_categories' => 'C1, C2, C3'))); $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); $this->assertTrue($categoryModel->createDefaultCategories(1)); $categories = $categoryModel->getAll(1); $this->assertCount(3, $categories); $this->assertEquals('C1', $categories[0]['name']); $this->assertEquals('C2', $categories[1]['name']); $this->assertEquals('C3', $categories[2]['name']); }
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']); }
public function testGetWithCaching() { $c = new Config($this->container); $this->assertEquals('UTC', $c->get('application_timezone')); $this->assertTrue($c->save(array('application_timezone' => 'Europe/Paris'))); $this->assertEquals('UTC', $c->get('application_timezone')); // cached value $this->assertEquals('Europe/Paris', $c->getOption('application_timezone')); $this->assertEquals('', $c->get('board_columns')); $this->assertEquals('test', $c->get('board_columns', 'test')); $this->assertEquals('test', $c->get('empty_value', 'test')); }