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


PHP ApiTester::createUser方法代码示例

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


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

示例1: checkApplicationableAccess

 public function checkApplicationableAccess(ApiTester $I)
 {
     $first_user = $I->createUser(true);
     /** Main user, Project admin */
     $second_user = $I->createUser(true);
     /** Test user, Project admin */
     $I->loginUser($first_user);
     $I->createProjectAndSetHeader();
     $table = $I->createTable();
     $I->sendGET('api/v1/admin/tables/' . $table->_id);
     $I->seeResponseCodeIs(200);
     $I->logout();
     $I->loginUser($second_user);
     $I->sendGET('api/v1/admin/tables/' . $table->_id);
     $I->seeResponseCodeIs(403);
     $I->sendPOST('api/v1/projects/users', ['user_id' => $second_user->_id]);
     $I->seeResponseCodeIs(403);
     $I->loginUser($first_user);
     $I->sendPOST('api/v1/projects/users', ['user_id' => $second_user->_id]);
     $I->seeResponseCodeIs(422);
     $I->seeResponseContains('The role field is required');
     $I->seeResponseContains('The scope field is required');
     $I->sendPOST('api/v1/projects/users', ['user_id' => $second_user->_id, 'role' => 'manager', 'scope' => ['tables_create', 'tables_view', 'uncreated_scope']]);
     $I->seeResponseCodeIs(422);
     $I->seeResponseContains('The selected scope is invalid.');
     $I->sendPOST('api/v1/projects/users', ['user_id' => $second_user->_id, 'role' => 'manager', 'scope' => ['tables_create', 'tables_view', 'tables_update']]);
     $I->seeResponseCodeIs(201);
     $I->loginUser($second_user);
     $I->sendGET('api/v1/admin/tables/' . $table->_id);
     $I->seeResponseCodeIs(200);
     $I->loginUser($first_user);
     $I->sendDELETE('api/v1/projects/users', ['user_id' => $second_user->_id]);
     $I->seeResponseCodeIs(200);
     $I->loginUser($second_user);
     $I->sendGET('api/v1/admin/tables/' . $table->_id);
     $I->seeResponseCodeIs(403);
 }
开发者ID:Nebo15,项目名称:gandalf.api,代码行数:37,代码来源:TablesCest.php

示例2: checkDecisionAccess

 public function checkDecisionAccess(ApiTester $I)
 {
     $user = $I->createAndLoginUser();
     $I->createProjectAndSetHeader();
     $table = $I->createTable($I->getShortTableDataMatchingTypeAll());
     $decisions = ['points' => 15, 'request' => ['string' => 'Invalid', 'numeric' => 1, 'bool' => false]];
     $data = $I->makeDecision($table->_id, $decisions['request'], 'scoring');
     $I->sendGET('api/v1/admin/decisions');
     $I->assertContains($data->_id, $I->grabResponse());
     $second_user = $I->createUser(true);
     $I->loginUser($second_user);
     $I->createProject(true);
     $I->sendGET('api/v1/admin/decisions');
     $I->assertNotContains($data->_id, $I->grabResponse());
     $I->loginUser($user);
     $I->sendPOST('api/v1/projects/users', ['user_id' => $second_user->_id, 'role' => 'manager', 'scope' => ['tables_create', 'tables_view', 'tables_update', 'decisions_view']]);
     $I->loginUser($second_user);
     $I->sendGET('api/v1/admin/decisions');
     $I->assertContains($data->_id, $I->grabResponse());
 }
开发者ID:Nebo15,项目名称:gandalf.api,代码行数:20,代码来源:DecisionsCest.php

示例3: getCurrentUserScope

 public function getCurrentUserScope(ApiTester $I)
 {
     $user = $I->createAndLoginUser();
     $I->createProjectAndSetHeader();
     $I->loginClient($I->getCurrentClient());
     $second_user = $I->createUser(true);
     $I->loginUser($user);
     $I->sendPOST('api/v1/projects/users', ['user_id' => $second_user->_id, 'role' => 'manager', 'scope' => ['tables_view', 'tables_update']]);
     $I->loginUser($second_user);
     $I->sendGET('api/v1/projects/users');
     $I->assertProjectUser();
 }
开发者ID:Nebo15,项目名称:gandalf.api,代码行数:12,代码来源:ProjectsCest.php

示例4: removeTokens

 public function removeTokens(ApiTester $I)
 {
     $user = $I->createUser();
     $I->getMongo();
     $tokens = ['reset_password' => ["token" => '$2y$10$iiPJClTgDWOgP0SR1ZgwLeMO4qNZkGFXHRjRpkyl.xC2K6OLPxExK', "expired" => time() + 30], 'verify_email' => ["token" => '$3y$10$iiPJClTgDWOgP0SR1ZgwLeMO4qNZkGFXHRjRpkyl.xC1K6OLPxExK', "expired" => time() - 1]];
     $filter = ['_id' => new MongoDB\BSON\ObjectID($user->_id)];
     $bulk = new MongoDB\Driver\BulkWrite();
     $bulk->update($filter, ['$set' => ['tokens' => $tokens, 'refreshTokens.0.expires' => time() - 1]]);
     $I->getMongo()->executeBulkWrite('gandalf_test.users', $bulk);
     exec('php artisan tokens:delete');
     $query = new MongoDB\Driver\Query($filter);
     $rows = $I->getMongo()->executeQuery('gandalf_test.users', $query);
     $user = $rows->toArray()[0];
     $I->assertFalse(property_exists($user->tokens, 'verify_email'), 'Expired verify_email token don\'t deleted');
     $I->assertEquals(0, count($user->refreshTokens), 'Expired refresh token do not deleted');
 }
开发者ID:Nebo15,项目名称:gandalf.api,代码行数:16,代码来源:UsersCest.php


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