本文整理汇总了PHP中Model\User::remove方法的典型用法代码示例。如果您正苦于以下问题:PHP User::remove方法的具体用法?PHP User::remove怎么用?PHP User::remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model\User
的用法示例。
在下文中一共展示了User::remove方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRemove
public function testRemove()
{
$u = new User($this->registry);
$t = new Task($this->registry);
$p = new Project($this->registry);
$this->assertTrue($u->create(array('username' => 'toto', 'password' => '123456', 'name' => 'Toto')));
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'owner_id' => 2)));
$task = $t->getById(1);
$this->assertEquals(1, $task['id']);
$this->assertEquals(2, $task['owner_id']);
$this->assertTrue($u->remove(1));
$this->assertTrue($u->remove(2));
$this->assertFalse($u->remove(2));
$this->assertFalse($u->remove(55));
// Make sure that assigned tasks are unassigned after removing the user
$task = $t->getById(1);
$this->assertEquals(1, $task['id']);
$this->assertEquals(0, $task['owner_id']);
}
示例2: testRemove
public function testRemove()
{
$u = new User($this->container);
$tc = new TaskCreation($this->container);
$tf = new TaskFinder($this->container);
$p = new Project($this->container);
$s = new Subtask($this->container);
$c = new Comment($this->container);
$this->assertNotFalse($u->create(array('username' => 'toto', 'password' => '123456', 'name' => 'Toto')));
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
$this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'owner_id' => 2)));
$this->assertEquals(1, $s->create(array('title' => 'Subtask #1', 'user_id' => 2, 'task_id' => 1)));
$this->assertEquals(1, $c->create(array('comment' => 'foobar', 'user_id' => 2, 'task_id' => 1)));
$task = $tf->getById(1);
$this->assertEquals(1, $task['id']);
$this->assertEquals(2, $task['owner_id']);
$this->assertTrue($u->remove(1));
$this->assertTrue($u->remove(2));
$this->assertFalse($u->remove(2));
$this->assertFalse($u->remove(55));
// Make sure that assigned tasks are unassigned after removing the user
$task = $tf->getById(1);
$this->assertEquals(1, $task['id']);
$this->assertEquals(0, $task['owner_id']);
// Make sure that assigned subtasks are unassigned after removing the user
$subtask = $s->getById(1);
$this->assertEquals(1, $subtask['id']);
$this->assertEquals(0, $subtask['user_id']);
// Make sure that comments are not related to the user anymore
$comment = $c->getById(1);
$this->assertEquals(1, $comment['id']);
$this->assertEquals(0, $comment['user_id']);
// Make sure that private projects are also removed
$user_id1 = $u->create(array('username' => 'toto1', 'password' => '123456', 'name' => 'Toto'));
$user_id2 = $u->create(array('username' => 'toto2', 'password' => '123456', 'name' => 'Toto'));
$this->assertNotFalse($user_id1);
$this->assertNotFalse($user_id2);
$this->assertEquals(2, $p->create(array('name' => 'Private project #1', 'is_private' => 1), $user_id1, true));
$this->assertEquals(3, $p->create(array('name' => 'Private project #2', 'is_private' => 1), $user_id2, true));
$this->assertTrue($u->remove($user_id1));
$this->assertNotEmpty($p->getById(1));
$this->assertNotEmpty($p->getById(3));
$this->assertEmpty($p->getById(2));
}
示例3: function
$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);
});
$server->register('getCategory', function ($category_id) use($category) {
return $category->getById($category_id);
});
$server->register('getAllCategories', function ($project_id) use($category) {
return $category->getAll($project_id);
});