本文整理汇总了PHP中ApiTester::createConsumer方法的典型用法代码示例。如果您正苦于以下问题:PHP ApiTester::createConsumer方法的具体用法?PHP ApiTester::createConsumer怎么用?PHP ApiTester::createConsumer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ApiTester
的用法示例。
在下文中一共展示了ApiTester::createConsumer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createFirst
public function createFirst(ApiTester $I)
{
$I->createAndLoginUser();
$I->createProjectAndSetHeader();
$table_data = $I->createTable();
$table_id_no_decisions = $table_data->_id;
$table_data = $I->createTable();
$table_id_with_decisions = $table_data->_id;
$decision_table = $I->makeDecision($table_id_with_decisions);
$I->assertEquals('Approve', $decision_table->final_decision);
$I->sendGET('api/v1/admin/decisions?table_id=' . $table_id_no_decisions);
$I->seeResponseCodeIs(404);
# filter by table_id
$I->sendGET('api/v1/admin/decisions?table_id=' . $table_id_with_decisions);
$I->assertTableDecisionsForAdmin('decision', '$.data[*]');
foreach ($I->getResponseFields()->data as $item) {
$I->sendGET('api/v1/admin/decisions/' . $item->_id);
$I->assertTableDecisionsForAdmin();
}
$I->sendGET('api/v1/admin/decisions/123');
$I->seeResponseCodeIs(404);
$decision_data = $I->makeDecision($table_id_with_decisions, ['borrowers_phone_verification' => 'invalid', 'contact_person_phone_verification' => 'invalid', 'internal_credit_history' => 'invalid', 'employment' => false, 'property' => false]);
$I->assertEquals($table_data->variants[0]->default_decision, $decision_data->final_decision);
$I->sendGET('api/v1/admin/decisions');
$I->assertTableDecisionsForAdmin('decision', '$.data[*]');
$decisions = $I->getResponseFields()->data;
$I->assertEquals('invalid', $decisions[0]->request->borrowers_phone_verification);
$I->assertEquals('Positive', $decisions[1]->request->borrowers_phone_verification);
foreach ($I->getResponseFields()->data as $item) {
$I->sendGET('api/v1/admin/decisions/' . $item->_id);
$I->assertTableDecisionsForAdmin();
}
$I->loginConsumer($I->createConsumer());
$I->sendGET('api/v1/admin/decisions');
$I->seeResponseCodeIs(401);
}
示例2: ruleIsset
public function ruleIsset(ApiTester $I)
{
$user = $I->createAndLoginUser();
$I->createProjectAndSetHeader();
$table = $I->createTable(['title' => 'Test title', 'description' => 'Test description', 'matching_type' => 'decision', 'decision_type' => 'alpha_num', 'fields' => [["key" => ' IS SET ', "title" => 'Test', "source" => "request", "type" => 'numeric', "preset" => ['condition' => '$lte', 'value' => 10]], ["key" => 'Second ', "title" => 'Second', "source" => "request", "type" => 'string', 'preset' => null]], 'variants' => [['default_decision' => 'Decline', 'rules' => [['than' => 'Approve', 'title' => '', 'description' => '', 'conditions' => [['field_key' => ' IS SET ', 'condition' => '$is_set', 'value' => true], ['field_key' => 'Second ', 'condition' => '$is_set', 'value' => true]]]]]]]);
$I->sendPOST("api/v1/tables/{$table->_id}/decisions", [' ISSET ' => 8]);
$I->seeResponseCodeIs(422);
# invalid request type
$I->sendPOST("api/v1/tables/{$table->_id}/decisions", ['is_set' => 'invalid_type', 'second' => 'test']);
$I->seeResponseCodeIs(422);
# invalid request type
$I->sendPOST("api/v1/tables/{$table->_id}/decisions", ['is_set' => 200, 'second' => false]);
$I->seeResponseCodeIs(422);
$I->loginConsumer($I->createConsumer());
$decision = $I->makeDecision($table->_id, ['is_set' => 1000, 'second' => 'test']);
$I->sendGET('api/v1/admin/decisions/' . $decision->_id);
$I->seeResponseCodeIs(401);
$I->loginUser($user);
$I->makeDecision($table->_id, ['is_set' => 1000, 'second' => 'test']);
$I->sendGET('api/v1/admin/decisions/' . $decision->_id);
$I->assertResponseDataFields(['final_decision' => 'Approve', 'rules' => [['conditions' => [['field_key' => 'is_set', 'matched' => true], ['field_key' => 'second', 'matched' => true]]]]]);
}
示例3: consumers
public function consumers(ApiTester $I)
{
$faker = $I->getFaker();
$I->createAndLoginUser();
$I->createProjectAndSetHeader();
$I->createConsumer();
$I->sendPOST('api/v1/projects/consumers', ['description' => $faker->text('20'), 'scope' => ['decisions_view', 'decisions_make']]);
$consumer = json_decode($I->grabResponse())->data[0];
$I->assertConsumers('$.data[*]', 201);
$text = $faker->text('20');
$I->sendPUT('api/v1/projects/consumers', ['description' => $text, 'scope' => ['decisions_view', 'decisions_make'], 'client_id' => $consumer->client_id]);
$I->seeResponseContains($text);
$I->assertConsumers();
$I->sendDELETE('api/v1/projects/consumers', ['client_id' => $consumer->client_id]);
$I->cantSeeResponseContains($consumer->client_id);
$I->assertConsumers();
}
示例4: accessForCheck
public function accessForCheck(ApiTester $I)
{
$first_user = $I->createUser(true, '', false);
$second_user = $I->createUser(true);
$I->loginUser($first_user);
$I->createProjectAndSetHeader();
$consumer = $I->createConsumer();
$table = $I->createTable();
$table_id = $table->_id;
$data = ['borrowers_phone_verification' => 'Positive', 'contact_person_phone_verification' => 'Positive', 'internal_credit_history' => 'Positive', 'employment' => true, 'property' => true, 'matching_rules_type' => 'decision'];
$I->sendPOST("api/v1/tables/{$table_id}/decisions", $data);
$I->canSeeResponseCodeIs(403);
$I->seeResponseContains("Project owner is not activated, try again later");
$I->sendPOST('api/v1/projects/users', ['user_id' => $second_user->_id, 'role' => 'manager', 'scope' => ['tables_view', 'decisions_make']]);
$I->loginUser($second_user);
$I->sendPOST("api/v1/tables/{$table_id}/decisions", $data);
$I->canSeeResponseCodeIs(403);
$I->seeResponseContains("Project owner is not activated, try again later");
$I->loginConsumer($consumer);
$I->sendPOST("api/v1/tables/{$table_id}/decisions", $data);
$I->canSeeResponseCodeIs(403);
$I->seeResponseContains("Project owner is not activated, try again later");
$I->logout();
$I->loginClient($I->getCurrentClient());
$I->sendPOST('api/v1/users/verify/email', ['token' => $first_user->sandbox->token_email->token]);
$I->seeResponseCodeIs(200);
$I->loginUser($first_user);
$I->makeDecision($table_id);
$I->loginConsumer($consumer);
$I->makeDecision($table_id);
$I->loginUser($second_user);
$I->makeDecision($table_id);
}