Пример #1
0
});
$server->register('moveTaskPosition', function ($project_id, $task_id, $column_id, $position) use($task) {
    return $task->movePosition($project_id, $task_id, $column_id, $position);
});
/**
 * User procedures
 */
$server->register('createUser', function (array $values) use($user) {
    list($valid, ) = $user->validateCreation($values);
    return $valid && $user->create($values);
});
$server->register('getUser', function ($user_id) use($user) {
    return $user->getById($user_id);
});
$server->register('getAllUsers', function () use($user) {
    return $user->getAll();
});
$server->register('updateUser', function ($values) use($user) {
    list($valid, ) = $user->validateModification($values);
    return $valid && $user->update($values);
});
$server->register('removeUser', function ($user_id) use($user) {
    return $user->remove($user_id);
});
/**
 * Category procedures
 */
$server->register('createCategory', function ($project_id, $name) use($category) {
    $values = array('project_id' => $project_id, 'name' => $name);
    list($valid, ) = $category->validateCreation($values);
    return $valid && $category->create($values);
Пример #2
0
 public function testGetAll()
 {
     $u = new User($this->container);
     $this->assertEquals(2, $u->create(array('username' => 'you')));
     $this->assertEquals(3, $u->create(array('username' => 'me', 'name' => 'Me')));
     $users = $u->getAll();
     $this->assertCount(3, $users);
     $this->assertEquals('admin', $users[0]['username']);
     $this->assertEquals('me', $users[1]['username']);
     $this->assertEquals('you', $users[2]['username']);
 }