当前位置: 首页>>代码示例>>PHP>>正文


PHP User::create方法代码示例

本文整理汇总了PHP中Model\User::create方法的典型用法代码示例。如果您正苦于以下问题:PHP User::create方法的具体用法?PHP User::create怎么用?PHP User::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Model\User的用法示例。


在下文中一共展示了User::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testCloneProjectWithUsers

 public function testCloneProjectWithUsers()
 {
     $p = new Project($this->container);
     $c = new Category($this->container);
     $pp = new ProjectPermission($this->container);
     $u = new User($this->container);
     $this->assertEquals(2, $u->create(array('username' => 'unittest1', 'password' => 'unittest')));
     $this->assertEquals(3, $u->create(array('username' => 'unittest2', 'password' => 'unittest')));
     $this->assertEquals(4, $u->create(array('username' => 'unittest3', 'password' => 'unittest')));
     $this->assertEquals(1, $p->create(array('name' => 'P1')));
     $this->assertTrue($pp->addMember(1, 2));
     $this->assertTrue($pp->addMember(1, 4));
     $this->assertTrue($pp->addManager(1, 3));
     $this->assertTrue($pp->isMember(1, 2));
     $this->assertTrue($pp->isMember(1, 3));
     $this->assertTrue($pp->isMember(1, 4));
     $this->assertFalse($pp->isManager(1, 2));
     $this->assertTrue($pp->isManager(1, 3));
     $this->assertFalse($pp->isManager(1, 4));
     $this->assertEquals(2, $p->duplicate(1));
     $project = $p->getById(2);
     $this->assertNotEmpty($project);
     $this->assertEquals('P1 (Clone)', $project['name']);
     $this->assertEquals(3, count($pp->getMembers(2)));
     $this->assertTrue($pp->isMember(2, 2));
     $this->assertTrue($pp->isMember(2, 3));
     $this->assertTrue($pp->isMember(2, 4));
     $this->assertFalse($pp->isManager(2, 2));
     $this->assertTrue($pp->isManager(2, 3));
     $this->assertFalse($pp->isManager(2, 4));
 }
开发者ID:jasonmoofang,项目名称:kanboard,代码行数:31,代码来源:ProjectDuplicateTest.php

示例2: add

 function add()
 {
     $app = get_app();
     //GET
     if ($app->request()->isGet()) {
         render_with_layout('misc.php', 'Users/add.php');
     }
     //POST
     if ($app->request()->isPost()) {
         $password_1 = $app->request()->post('password_1');
         $password_2 = $app->request()->post('password_2');
         if ($password_1 != $password_2) {
             $app->flashNow('errors', array('您两次输入的密码不一致!'));
             render_with_layout('misc.php', 'Users/add.php');
         } else {
             $post = $app->request()->post();
             $post['password'] = !empty($password_1) && strlen($password_1) >= 8 ? md5($password_1) : $password_1;
             $post['team_id'] = 0;
             unset($post['password_1']);
             unset($post['password_2']);
             $user = User::create($post);
             if (!$user->is_valid()) {
                 $app->flashNow('errors', $user->errors);
                 render_with_layout('misc.php', 'Users/add.php');
             } else {
                 $user->save();
                 $app->flash('success', '用户创建成功!');
                 redirect('/users');
             }
         }
     }
 }
开发者ID:saintyk,项目名称:yndl_2,代码行数:32,代码来源:Users.php

示例3: testHandlePayload

 public function testHandlePayload()
 {
     $w = new MailgunWebhook($this->container);
     $p = new Project($this->container);
     $pp = new ProjectPermission($this->container);
     $u = new User($this->container);
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $this->assertEquals(2, $u->create(array('name' => 'me', 'email' => 'me@localhost')));
     $this->assertEquals(1, $p->create(array('name' => 'test1')));
     $this->assertEquals(2, $p->create(array('name' => 'test2', 'identifier' => 'TEST1')));
     // Empty payload
     $this->assertFalse($w->parsePayload(array()));
     // Unknown user
     $this->assertFalse($w->parsePayload(array('sender' => 'a@b.c', 'subject' => 'Email task', 'recipient' => 'foobar', 'stripped-text' => 'boo')));
     // Project not found
     $this->assertFalse($w->parsePayload(array('sender' => 'me@localhost', 'subject' => 'Email task', 'recipient' => 'foo+test@localhost', 'stripped-text' => 'boo')));
     // User is not member
     $this->assertFalse($w->parsePayload(array('sender' => 'me@localhost', 'subject' => 'Email task', 'recipient' => 'foo+test1@localhost', 'stripped-text' => 'boo')));
     $this->assertTrue($pp->addMember(2, 2));
     // The task must be created
     $this->assertTrue($w->parsePayload(array('sender' => 'me@localhost', 'subject' => 'Email task', 'recipient' => 'foo+test1@localhost', 'stripped-text' => 'boo')));
     $task = $tf->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEquals(2, $task['project_id']);
     $this->assertEquals('Email task', $task['title']);
     $this->assertEquals('boo', $task['description']);
     $this->assertEquals(2, $task['creator_id']);
 }
开发者ID:rbertani,项目名称:kanboard,代码行数:29,代码来源:MailgunWebhookTest.php

示例4: testHtml2Markdown

 public function testHtml2Markdown()
 {
     $w = new Postmark($this->container);
     $p = new Project($this->container);
     $pp = new ProjectPermission($this->container);
     $u = new User($this->container);
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $this->assertEquals(2, $u->create(array('username' => 'me', 'email' => 'me@localhost')));
     $this->assertEquals(1, $p->create(array('name' => 'test2', 'identifier' => 'TEST1')));
     $this->assertTrue($pp->addMember(1, 2));
     $this->assertTrue($w->receiveEmail(array('From' => 'me@localhost', 'Subject' => 'Email task', 'MailboxHash' => 'test1', 'TextBody' => 'boo', 'HtmlBody' => '<p><strong>boo</strong></p>')));
     $task = $tf->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEquals(1, $task['project_id']);
     $this->assertEquals('Email task', $task['title']);
     $this->assertEquals('**boo**', $task['description']);
     $this->assertEquals(2, $task['creator_id']);
     $this->assertTrue($w->receiveEmail(array('From' => 'me@localhost', 'Subject' => 'Email task', 'MailboxHash' => 'test1', 'TextBody' => '**boo**', 'HtmlBody' => '')));
     $task = $tf->getById(2);
     $this->assertNotEmpty($task);
     $this->assertEquals(1, $task['project_id']);
     $this->assertEquals('Email task', $task['title']);
     $this->assertEquals('**boo**', $task['description']);
     $this->assertEquals(2, $task['creator_id']);
 }
开发者ID:0xff-fanatic,项目名称:kanboard,代码行数:26,代码来源:PostmarkTest.php

示例5: testGetAll

 public function testGetAll()
 {
     $u = new User($this->container);
     $p = new Project($this->container);
     $cf = new CustomFilter($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'UnitTest 1')));
     $this->assertEquals(2, $p->create(array('name' => 'UnitTest 2')));
     $this->assertEquals(2, $u->create(array('username' => 'user 2')));
     $this->assertEquals(1, $cf->create(array('name' => 'My filter 1', 'filter' => 'color:blue', 'project_id' => 1, 'user_id' => 1)));
     $this->assertEquals(2, $cf->create(array('name' => 'My filter 2', 'filter' => 'color:red', 'project_id' => 1, 'user_id' => 1, 'is_shared' => 1)));
     $this->assertEquals(3, $cf->create(array('name' => 'My filter 3', 'filter' => 'color:green', 'project_id' => 1, 'user_id' => 2, 'is_shared' => 1)));
     $this->assertEquals(4, $cf->create(array('name' => 'My filter 4', 'filter' => 'color:brown', 'project_id' => 1, 'user_id' => 2, 'is_shared' => 0)));
     $this->assertEquals(5, $cf->create(array('name' => 'My filter 5', 'filter' => 'color:grey', 'project_id' => 2, 'user_id' => 2)));
     // Get filters for the project 1 and user 1
     $filters = $cf->getAll(1, 1);
     $this->assertCount(3, $filters);
     $this->assertEquals(1, $filters[0]['id']);
     $this->assertEquals('My filter 1', $filters[0]['name']);
     $this->assertEquals('color:blue', $filters[0]['filter']);
     $this->assertEquals(1, $filters[0]['project_id']);
     $this->assertEquals(1, $filters[0]['user_id']);
     $this->assertEquals(0, $filters[0]['is_shared']);
     $this->assertEquals('', $filters[0]['owner_name']);
     $this->assertEquals('admin', $filters[0]['owner_username']);
     $this->assertEquals(2, $filters[1]['id']);
     $this->assertEquals('My filter 2', $filters[1]['name']);
     $this->assertEquals('color:red', $filters[1]['filter']);
     $this->assertEquals(1, $filters[1]['project_id']);
     $this->assertEquals(1, $filters[1]['user_id']);
     $this->assertEquals(1, $filters[1]['is_shared']);
     $this->assertEquals('', $filters[1]['owner_name']);
     $this->assertEquals('admin', $filters[1]['owner_username']);
     $this->assertEquals(3, $filters[2]['id']);
     $this->assertEquals('My filter 3', $filters[2]['name']);
     $this->assertEquals('color:green', $filters[2]['filter']);
     $this->assertEquals(1, $filters[2]['project_id']);
     $this->assertEquals(2, $filters[2]['user_id']);
     $this->assertEquals(1, $filters[2]['is_shared']);
     $this->assertEquals('', $filters[2]['owner_name']);
     $this->assertEquals('user 2', $filters[2]['owner_username']);
     // Get filters for the project 1 and user 2
     $filters = $cf->getAll(1, 2);
     $this->assertCount(3, $filters);
     $this->assertEquals(2, $filters[0]['id']);
     $this->assertEquals('My filter 2', $filters[0]['name']);
     $this->assertEquals(3, $filters[1]['id']);
     $this->assertEquals('My filter 3', $filters[1]['name']);
     $this->assertEquals(4, $filters[2]['id']);
     $this->assertEquals('My filter 4', $filters[2]['name']);
     // Get filters for the project 2 and user 1
     $filters = $cf->getAll(2, 1);
     $this->assertCount(0, $filters);
     // Get filters for the project 2 and user 2
     $filters = $cf->getAll(2, 2);
     $this->assertCount(1, $filters);
     $this->assertEquals(5, $filters[0]['id']);
     $this->assertEquals('My filter 5', $filters[0]['name']);
     $this->assertEquals(0, $filters[0]['is_shared']);
 }
开发者ID:praveencs87,项目名称:kanboard,代码行数:59,代码来源:CustomFilterTest.php

示例6: register

 /**
  * POST /register.json
  */
 public function register($f3, $params)
 {
     // Create user
     $data = ['username' => $f3->get('POST.username'), 'fingerprint' => $f3->get('POST.keypair-fingerprint'), 'name' => $f3->get('POST.name'), 'password_salt' => $f3->get('POST.password-salt'), 'password_hash' => password_hash($f3->get('POST.password-hash'), PASSWORD_DEFAULT, ['cost' => \App::config()['security']['bcrypt_cost']]), 'private_key' => $f3->get('POST.keypair-private'), 'public_key' => $f3->get('POST.keypair-public'), 'symmetric_key' => $f3->get('POST.symmkey')];
     $user = \Model\User::create($data);
     // Log in user and return stssion token
     $token = \Helper\Security::generateToken($user->id);
     $this->_json(['user_id' => $user->id, 'token' => $token]);
 }
开发者ID:svlt,项目名称:back,代码行数:12,代码来源:user.php

示例7: testGetUserList

 public function testGetUserList()
 {
     $u = new User($this->registry);
     $p = new Project($this->registry);
     $n = new Notification($this->registry);
     $this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
     $this->assertEquals(2, $p->create(array('name' => 'UnitTest2')));
     // Email + Notifications enabled
     $this->assertTrue($u->create(array('username' => 'user1', 'email' => 'user1@here', 'notifications_enabled' => 1)));
     // No email + Notifications enabled
     $this->assertTrue($u->create(array('username' => 'user2', 'email' => '', 'notifications_enabled' => 1)));
     // Email + Notifications enabled
     $this->assertTrue($u->create(array('username' => 'user3', 'email' => 'user3@here', 'notifications_enabled' => 1)));
     // No email + notifications disabled
     $this->assertTrue($u->create(array('username' => 'user4')));
     $users = $n->getUsersList(1);
     $this->assertNotEmpty($users);
     $this->assertEquals(2, count($users));
     $this->assertEquals('user1@here', $users[0]['email']);
     $this->assertEquals('user3@here', $users[1]['email']);
     $users = $n->getUsersList(2);
     $this->assertNotEmpty($users);
     $this->assertEquals(2, count($users));
     $this->assertEquals('user1@here', $users[0]['email']);
     $this->assertEquals('user3@here', $users[1]['email']);
     // User 3 choose to receive notification only for project 2
     $n->saveSettings(4, array('notifications_enabled' => 1, 'projects' => array(2 => true)));
     $users = $n->getUsersList(1);
     $this->assertNotEmpty($users);
     $this->assertEquals(1, count($users));
     $this->assertEquals('user1@here', $users[0]['email']);
     $users = $n->getUsersList(2);
     $this->assertNotEmpty($users);
     $this->assertEquals(2, count($users));
     $this->assertEquals('user1@here', $users[0]['email']);
     $this->assertEquals('user3@here', $users[1]['email']);
     // User 1 excluded
     $users = $n->getUsersList(1, array(2));
     $this->assertEmpty($users);
     $users = $n->getUsersList(2, array(2));
     $this->assertNotEmpty($users);
     $this->assertEquals(1, count($users));
     $this->assertEquals('user3@here', $users[0]['email']);
 }
开发者ID:Dunstkreis,项目名称:kanboard,代码行数:44,代码来源:NotificationTest.php

示例8: testHandlePayload

 public function testHandlePayload()
 {
     $w = new Sendgrid($this->container);
     $p = new Project($this->container);
     $pp = new ProjectPermission($this->container);
     $u = new User($this->container);
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $this->assertEquals(2, $u->create(array('username' => 'me', 'email' => 'me@localhost')));
     $this->assertEquals(1, $p->create(array('name' => 'test1')));
     $this->assertEquals(2, $p->create(array('name' => 'test2', 'identifier' => 'TEST1')));
     // Empty payload
     $this->assertFalse($w->receiveEmail(array()));
     // Unknown user
     $this->assertFalse($w->receiveEmail(array('envelope' => '{"to":["a@b.c"],"from":"a.b.c"}', 'subject' => 'Email task')));
     // Project not found
     $this->assertFalse($w->receiveEmail(array('envelope' => '{"to":["a@b.c"],"from":"me@localhost"}', 'subject' => 'Email task')));
     // User is not member
     $this->assertFalse($w->receiveEmail(array('envelope' => '{"to":["something+test1@localhost"],"from":"me@localhost"}', 'subject' => 'Email task')));
     $this->assertTrue($pp->addMember(2, 2));
     // The task must be created
     $this->assertTrue($w->receiveEmail(array('envelope' => '{"to":["something+test1@localhost"],"from":"me@localhost"}', 'subject' => 'Email task')));
     $task = $tf->getById(1);
     $this->assertNotEmpty($task);
     $this->assertEquals(2, $task['project_id']);
     $this->assertEquals('Email task', $task['title']);
     $this->assertEquals('', $task['description']);
     $this->assertEquals(2, $task['creator_id']);
     // Html content
     $this->assertTrue($w->receiveEmail(array('envelope' => '{"to":["something+test1@localhost"],"from":"me@localhost"}', 'subject' => 'Email task', 'html' => '<strong>bold</strong> text')));
     $task = $tf->getById(2);
     $this->assertNotEmpty($task);
     $this->assertEquals(2, $task['project_id']);
     $this->assertEquals('Email task', $task['title']);
     $this->assertEquals('**bold** text', $task['description']);
     $this->assertEquals(2, $task['creator_id']);
     // Text content
     $this->assertTrue($w->receiveEmail(array('envelope' => '{"to":["something+test1@localhost"],"from":"me@localhost"}', 'subject' => 'Email task', 'text' => '**bold** text')));
     $task = $tf->getById(3);
     $this->assertNotEmpty($task);
     $this->assertEquals(2, $task['project_id']);
     $this->assertEquals('Email task', $task['title']);
     $this->assertEquals('**bold** text', $task['description']);
     $this->assertEquals(2, $task['creator_id']);
     // Text + html content
     $this->assertTrue($w->receiveEmail(array('envelope' => '{"to":["something+test1@localhost"],"from":"me@localhost"}', 'subject' => 'Email task', 'html' => '<strong>bold</strong> html', 'text' => '**bold** text')));
     $task = $tf->getById(4);
     $this->assertNotEmpty($task);
     $this->assertEquals(2, $task['project_id']);
     $this->assertEquals('Email task', $task['title']);
     $this->assertEquals('**bold** html', $task['description']);
     $this->assertEquals(2, $task['creator_id']);
 }
开发者ID:redarrow,项目名称:kanboard,代码行数:53,代码来源:SendgridTest.php

示例9: setUp

 /**
  * Test setup
  */
 public function setUp()
 {
     // Create Environment
     $db = $this->getDb();
     $db->selectCollection(Bucket::$collection);
     // Empty Database
     $this->emptyDb();
     // Create user
     $user = User::create(array('email' => 'test@hoardhq.com'));
     $apikey = $user->createApiKey();
     $apikeys = array_keys($user->apikeys);
     $this->apikey = $apikeys[0];
 }
开发者ID:marcqualie,项目名称:hoard,代码行数:16,代码来源:TestCase.php

示例10: assertCliUser

 /**
  * Create CLI User (Requires API Key Access)
  */
 public function assertCliUser()
 {
     $this->user = User::findOne(array('email' => 'cli@hoardhq.com'));
     if (!$this->user) {
         $this->user = User::create(array('email' => 'cli@hoardhq.com'));
         $this->user->createApiKey();
     }
     $apikeys = array_keys($this->user->apikeys);
     $this->apikey = isset($apikeys[0]) ? $apikeys[0] : false;
     if (!$this->apikey) {
         $this->user->createApiKey();
         $this->assertCliUser();
     }
 }
开发者ID:marcqualie,项目名称:hoard,代码行数:17,代码来源:Command.php

示例11: 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']);
 }
开发者ID:cvalenti,项目名称:kanboard,代码行数:20,代码来源:UserTest.php

示例12: function

});
$server->register('closeTask', function ($task_id) use($task) {
    return $task->close($task_id);
});
$server->register('removeTask', function ($task_id) use($task) {
    return $task->remove($task_id);
});
$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);
});
/**
开发者ID:Null-Kelvin,项目名称:kanboard,代码行数:31,代码来源:jsonrpc.php

示例13: testDuplicateMixedResults

 public function testDuplicateMixedResults()
 {
     $p = new Project($this->container);
     $pp = new ProjectPermission($this->container);
     $a = new Action($this->container);
     $u = new User($this->container);
     $c = new Category($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'P1')));
     $this->assertEquals(2, $p->create(array('name' => 'P2')));
     $this->assertEquals(1, $c->create(array('name' => 'C1', 'project_id' => 1)));
     $this->assertEquals(2, $c->create(array('name' => 'C2', 'project_id' => 2)));
     $this->assertEquals(3, $c->create(array('name' => 'C1', 'project_id' => 2)));
     $this->assertEquals(2, $u->create(array('username' => 'unittest1')));
     $this->assertTrue($pp->addMember(1, 2));
     $this->assertEquals(1, $a->create(array('project_id' => 1, 'event_name' => Task::EVENT_CREATE_UPDATE, 'action_name' => 'TaskAssignSpecificUser', 'params' => array('column_id' => 1, 'user_id' => 2))));
     $action = $a->getById(1);
     $this->assertNotEmpty($action);
     $this->assertNotEmpty($action['params']);
     $this->assertEquals(2, $a->create(array('project_id' => 1, 'event_name' => Task::EVENT_CREATE_UPDATE, 'action_name' => 'TaskAssignCategoryColor', 'params' => array('color_id' => 'blue', 'category_id' => 1))));
     $action = $a->getById(2);
     $this->assertNotEmpty($action);
     $this->assertNotEmpty($action['params']);
     $this->assertEquals('category_id', $action['params'][1]['name']);
     $this->assertEquals(1, $action['params'][1]['value']);
     $actions = $a->getAllByProject(1);
     $this->assertNotEmpty($actions);
     $this->assertCount(2, $actions);
     $this->assertTrue($a->duplicate(1, 2));
     $actions = $a->getAllByProject(2);
     $this->assertNotEmpty($actions);
     $this->assertCount(1, $actions);
     $actions = $a->getAll();
     $this->assertNotEmpty($actions);
     $this->assertCount(3, $actions);
     $action = $a->getById($actions[2]['id']);
     $this->assertNotEmpty($action);
     $this->assertNotEmpty($action['params']);
     $this->assertEquals('color_id', $action['params'][0]['name']);
     $this->assertEquals('blue', $action['params'][0]['value']);
     $this->assertEquals('category_id', $action['params'][1]['name']);
     $this->assertEquals(3, $action['params'][1]['value']);
 }
开发者ID:redarrow,项目名称:kanboard,代码行数:42,代码来源:ActionTest.php

示例14: testCommentCreatedWithUser

 public function testCommentCreatedWithUser()
 {
     $this->container['dispatcher']->addListener(GithubWebhook::EVENT_ISSUE_COMMENT, array($this, 'onCommentCreatedWithUser'));
     $p = new Project($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'foobar')));
     $tc = new TaskCreation($this->container);
     $this->assertEquals(1, $tc->create(array('title' => 'boo', 'reference' => 3, 'project_id' => 1)));
     $u = new User($this->container);
     $this->assertEquals(2, $u->create(array('username' => 'fguillot')));
     $pp = new ProjectPermission($this->container);
     $this->assertTrue($pp->addMember(1, 2));
     $g = new GithubWebhook($this->container);
     $g->setProjectId(1);
     $this->assertNotFalse($g->parsePayload('issue_comment', json_decode(file_get_contents(__DIR__ . '/../fixtures/github_comment_created.json'), true)));
 }
开发者ID:redarrow,项目名称:kanboard,代码行数:15,代码来源:GithubWebhookTest.php

示例15: testPrepareCreation

 public function testPrepareCreation()
 {
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $tp = new TaskPermission($this->container);
     $p = new Project($this->container);
     $u = new User($this->container);
     $us = new UserSession($this->container);
     $this->assertNotFalse($u->create(array('username' => 'toto', 'password' => '123456')));
     $this->assertNotFalse($u->create(array('username' => 'toto2', 'password' => '123456')));
     $this->assertEquals(1, $p->create(array('name' => 'Project #1')));
     $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'creator_id' => 1)));
     $this->assertEquals(2, $tc->create(array('title' => 'Task #2', 'project_id' => 1, 'creator_id' => 2)));
     $this->assertEquals(3, $tc->create(array('title' => 'Task #3', 'project_id' => 1, 'creator_id' => 3)));
     $this->assertEquals(4, $tc->create(array('title' => 'Task #4', 'project_id' => 1)));
     // User #1 can remove everything
     $user = $u->getbyId(1);
     $this->assertNotEmpty($user);
     $us->refresh($user);
     $task = $tf->getbyId(1);
     $this->assertNotEmpty($task);
     $this->assertTrue($tp->canRemoveTask($task));
     // User #2 can't remove the task #1
     $user = $u->getbyId(2);
     $this->assertNotEmpty($user);
     $us->refresh($user);
     $task = $tf->getbyId(1);
     $this->assertNotEmpty($task);
     $this->assertFalse($tp->canRemoveTask($task));
     // User #1 can remove everything
     $user = $u->getbyId(1);
     $this->assertNotEmpty($user);
     $us->refresh($user);
     $task = $tf->getbyId(2);
     $this->assertNotEmpty($task);
     $this->assertTrue($tp->canRemoveTask($task));
     // User #2 can remove his own task
     $user = $u->getbyId(2);
     $this->assertNotEmpty($user);
     $us->refresh($user);
     $task = $tf->getbyId(2);
     $this->assertNotEmpty($task);
     $this->assertTrue($tp->canRemoveTask($task));
     // User #1 can remove everything
     $user = $u->getbyId(1);
     $this->assertNotEmpty($user);
     $us->refresh($user);
     $task = $tf->getbyId(3);
     $this->assertNotEmpty($task);
     $this->assertTrue($tp->canRemoveTask($task));
     // User #2 can't remove the task #3
     $user = $u->getbyId(2);
     $this->assertNotEmpty($user);
     $us->refresh($user);
     $task = $tf->getbyId(3);
     $this->assertNotEmpty($task);
     $this->assertFalse($tp->canRemoveTask($task));
     // User #1 can remove everything
     $user = $u->getbyId(1);
     $this->assertNotEmpty($user);
     $us->refresh($user);
     $task = $tf->getbyId(4);
     $this->assertNotEmpty($task);
     $this->assertTrue($tp->canRemoveTask($task));
     // User #2 can't remove the task #4
     $user = $u->getbyId(2);
     $this->assertNotEmpty($user);
     $us->refresh($user);
     $task = $tf->getbyId(4);
     $this->assertNotEmpty($task);
     $this->assertFalse($tp->canRemoveTask($task));
 }
开发者ID:rbertani,项目名称:kanboard,代码行数:72,代码来源:TaskPermissionTest.php


注:本文中的Model\User::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。