本文整理汇总了PHP中Model\Project::allowUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Project::allowUser方法的具体用法?PHP Project::allowUser怎么用?PHP Project::allowUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model\Project
的用法示例。
在下文中一共展示了Project::allowUser方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testUsersList
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));
}
示例2: function
});
$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);
});
$server->register('getAllTasks', function ($project_id, array $status) use($task) {
return $task->getAll($project_id, $status);
});
示例3: testMoveToAnotherProject
public function testMoveToAnotherProject()
{
$t = new Task($this->registry);
$p = new Project($this->registry);
$user = new User($this->registry);
// We create a regular user
$user->create(array('username' => 'unittest1', 'password' => 'unittest'));
$user->create(array('username' => 'unittest2', 'password' => 'unittest'));
// We create 2 projects
$this->assertEquals(1, $p->create(array('name' => 'test1')));
$this->assertEquals(2, $p->create(array('name' => 'test2')));
// We create a task
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 1, 'category_id' => 10, 'position' => 333)));
$this->assertEquals(2, $t->create(array('title' => 'test2', 'project_id' => 1, 'column_id' => 1, 'owner_id' => 3, 'category_id' => 10, 'position' => 333)));
// We duplicate our task to the 2nd project
$task = $t->getById(1);
$this->assertEquals(1, $t->moveToAnotherProject(2, $task));
//$this->assertTrue($this->registry->event->isEventTriggered(Task::EVENT_CREATE));
// Check the values of the duplicated task
$task = $t->getById(1);
$this->assertNotEmpty($task);
$this->assertEquals(1, $task['owner_id']);
$this->assertEquals(0, $task['category_id']);
$this->assertEquals(2, $task['project_id']);
$this->assertEquals(5, $task['column_id']);
$this->assertEquals(1, $task['position']);
$this->assertEquals('test', $task['title']);
// We allow only one user on the second project
$this->assertTrue($p->allowUser(2, 2));
// The owner should be reseted
$task = $t->getById(2);
$this->assertEquals(2, $t->moveToAnotherProject(2, $task));
$task = $t->getById(2);
$this->assertNotEmpty($task);
$this->assertEquals(0, $task['owner_id']);
}