Example #1
0
});
$server->register('updateColumn', function ($column_id, array $values) use($board) {
    return $board->updateColumn($column_id, $values);
});
$server->register('addColumn', function ($project_id, array $values) use($board) {
    $values += array('project_id' => $project_id);
    return $board->add($values);
});
$server->register('removeColumn', function ($column_id) use($board) {
    return $board->removeColumn($column_id);
});
$server->register('getAllowedUsers', function ($project_id) use($project) {
    return $project->getUsersList($project_id, false, false);
});
$server->register('revokeUser', function ($project_id, $user_id) use($project) {
    return $project->revokeUser($project_id, $user_id);
});
$server->register('allowUser', function ($project_id, $user_id) use($project) {
    return $project->allowUser($project_id, $user_id);
});
/**
 * Task procedures
 */
$server->register('createTask', function ($title, $project_id, $color_id = '', $column_id = 0, $owner_id = 0, $creator_id = 0, $date_due = '', $description = '', $category_id = 0, $score = 0) use($task) {
    $values = array('title' => $title, 'project_id' => $project_id, 'color_id' => $color_id, 'column_id' => $column_id, 'owner_id' => $owner_id, 'creator_id' => $creator_id, 'date_due' => $date_due, 'description' => $description, 'category_id' => $category_id, 'score' => $score);
    list($valid, ) = $task->validateCreation($values);
    return $valid && $task->create($values) !== false;
});
$server->register('getTask', function ($task_id) use($task) {
    return $task->getById($task_id);
});
Example #2
0
 public function testUsersList()
 {
     $p = new Project($this->registry);
     $user = new User($this->registry);
     $user->create(array('username' => 'unittest', 'password' => 'unittest'));
     // We create project
     $this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
     // No restriction, we should have everybody
     $this->assertEquals(array('Unassigned', 'admin', 'unittest'), $p->getUsersList(1));
     // We allow only the regular user
     $this->assertTrue($p->allowUser(1, 2));
     $this->assertEquals(array(0 => 'Unassigned', 2 => 'unittest'), $p->getUsersList(1));
     // We allow the admin user
     $this->assertTrue($p->allowUser(1, 1));
     $this->assertEquals(array(0 => 'Unassigned', 1 => 'admin', 2 => 'unittest'), $p->getUsersList(1));
     // We revoke only the regular user
     $this->assertTrue($p->revokeUser(1, 2));
     $this->assertEquals(array(0 => 'Unassigned', 1 => 'admin'), $p->getUsersList(1));
     // We revoke only the admin user, we should have everybody
     $this->assertTrue($p->revokeUser(1, 1));
     $this->assertEquals(array(0 => 'Unassigned', 1 => 'admin', 2 => 'unittest'), $p->getUsersList(1));
 }