Example #1
0
 public function testGet()
 {
     $c = new Config($this->registry);
     $this->assertEquals('', $c->get('default_columns'));
     $this->assertEquals('test', $c->get('default_columns', 'test'));
     $this->assertEquals(0, $c->get('default_columns', 0));
 }
Example #2
0
 public function testGet()
 {
     $c = new Config($this->container);
     $this->assertEquals('', $c->get('board_columns'));
     $this->assertEquals('test', $c->get('board_columns', 'test'));
     $this->assertEquals(0, $c->get('board_columns', 0));
 }
Example #3
0
 public function testGetWithSession()
 {
     $this->container['session'] = new Session();
     $c = new Config($this->container);
     session_id('test');
     $this->assertTrue(Session::isOpen());
     $this->assertEquals('', $c->get('board_columns'));
     $this->assertEquals('test', $c->get('board_columns', 'test'));
     $this->container['session']['config'] = array('board_columns' => 'foo', 'empty_value' => 0);
     $this->assertEquals('foo', $c->get('board_columns'));
     $this->assertEquals('foo', $c->get('board_columns', 'test'));
     $this->assertEquals('test', $c->get('empty_value', 'test'));
     session_id('');
     unset($this->container['session']);
 }
Example #4
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]);
 }
Example #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);
 }
Example #7
0
 /**
  * Method executed before each action
  *
  * @access public
  */
 public function beforeAction($controller, $action)
 {
     // Start the session
     $this->session->open(BASE_URL_DIRECTORY, SESSION_SAVE_PATH);
     // HTTP secure headers
     $this->response->csp();
     $this->response->nosniff();
     $this->response->xss();
     $this->response->hsts();
     $this->response->xframe();
     // Load translations
     $language = $this->config->get('language', 'en_US');
     if ($language !== 'en_US') {
         \Translator\load($language);
     }
     // Set timezone
     date_default_timezone_set($this->config->get('timezone', 'UTC'));
     // Authentication
     if (!$this->acl->isLogged() && !$this->acl->isPublicAction($controller, $action)) {
         // Try the remember me authentication first
         if (!$this->rememberMe->authenticate()) {
             // Redirect to the login form if not authenticated
             $this->response->redirect('?controller=user&action=login');
         } else {
             $this->lastLogin->create(\Model\LastLogin::AUTH_REMEMBER_ME, $this->acl->getUserId(), $this->user->getIpAddress(), $this->user->getUserAgent());
         }
     } else {
         if ($this->rememberMe->hasCookie()) {
             $this->rememberMe->refresh();
         }
     }
     // Check if the user is allowed to see this page
     if (!$this->acl->isPageAccessAllowed($controller, $action)) {
         $this->response->redirect('?controller=user&action=forbidden');
     }
     // Attach events for automatic actions
     $this->action->attachEvents();
 }
Example #8
0
$project = new Project($registry);
$task = new Task($registry);
$user = new User($registry);
$category = new Category($registry);
$comment = new Comment($registry);
$subtask = new SubTask($registry);
$board = new Board($registry);
$action = new Action($registry);
$webhook = new Webhook($registry);
$notification = new Notification($registry);
$action->attachEvents();
$project->attachEvents();
$webhook->attachEvents();
$notification->attachEvents();
// Load translations
$language = $config->get('language', 'en_US');
if ($language !== 'en_US') {
    Translator::load($language);
}
$server = new Server();
$server->authentication(array('jsonrpc' => $config->get('api_token')));
/**
 * Project procedures
 */
$server->register('createProject', function ($name) use($project) {
    $values = array('name' => $name);
    list($valid, ) = $project->validateCreation($values);
    return $valid && $project->create($values);
});
$server->register('getProjectById', function ($project_id) use($project) {
    return $project->getById($project_id);
Example #9
0
 public function testSave()
 {
     $c = new Config($this->container);
     $this->assertTrue($c->save(array('application_url' => 'http://localhost/')));
     $this->assertEquals('http://localhost/', $c->get('application_url'));
 }