本文整理匯總了PHP中ApiTester::getResponseFields方法的典型用法代碼示例。如果您正苦於以下問題:PHP ApiTester::getResponseFields方法的具體用法?PHP ApiTester::getResponseFields怎麽用?PHP ApiTester::getResponseFields使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ApiTester
的用法示例。
在下文中一共展示了ApiTester::getResponseFields方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: decisionType
public function decisionType(ApiTester $I)
{
$I->createAndLoginUser();
$I->createProjectAndSetHeader();
# alpha_num
$tableData = $I->getTableShortData();
$tableData['decision_type'] = 'alpha_num';
$I->createTable($tableData);
# numeric invalid
$tableData['decision_type'] = 'numeric';
$tableData['variants'][0]['than'] = 'string';
$tableData['variants'][0]['default_decision'] = 'string';
$I->sendPOST('api/v1/admin/tables', $tableData);
$I->seeResponseCodeIs(422);
$response = $I->getResponseFields()->data;
$I->assertTrue(array_key_exists('variants.0.default_decision', $response));
$I->assertTrue(array_key_exists('variants.0.rules.0.than', $response));
$I->assertTrue(array_key_exists('variants.0.rules.1.than', $response));
# numeric valid
$tableData['variants'][0]['default_decision'] = 1;
$tableData['variants'][0]['rules'][0]['than'] = -202;
$tableData['variants'][0]['rules'][1]['than'] = 123.34;
$I->createTable($tableData);
# json
$tableData = $I->getTableShortData();
$tableData['decision_type'] = 'json';
$tableData['variants'][0]['default_decision'] = '{}';
$tableData['variants'][0]['rules'][0]['than'] = '{"ok":true}';
$tableData['variants'][0]['rules'][1]['than'] = '[123,456]';
$I->createTable($tableData);
# invalid json
$tableData['variants'][0]['rules'][1]['than'] = '{invalid json}';
$I->sendPOST('api/v1/admin/tables', $tableData);
$I->seeResponseCodeIs(422);
$response = $I->getResponseFields()->data;
$I->assertTrue(array_key_exists('variants.0.rules.1.than', $response));
# for scoring decision_type is always numeric
$tableData = $I->getShortTableDataMatchingTypeAll();
$tableData['decision_type'] = 'json';
$I->sendPOST('api/v1/admin/tables', $tableData);
$I->seeResponseCodeIs(422);
$I->seeResponseContains('decision_type');
}
示例2: find
public function find(ApiTester $I, $scenario)
{
$usersList = [$I->createUser(true), $I->createUser(true), $I->createUser(true), $I->createUser(true)];
$user = $I->createAndLoginUser();
$I->sendGET('api/v1/users');
$I->sendGET('api/v1/users?name=' . substr($usersList[0]->username, 0, 3));
$foundUsers = json_encode($I->getResponseFields()->data);
$I->assertContains($usersList[0]->username, $foundUsers);
$I->assertContains($usersList[0]->_id, $foundUsers);
list($email) = explode('@', $usersList[1]->temporary_email);
$I->sendGET('api/v1/users?name=' . $email . '@');
$foundUsers = json_encode($I->getResponseFields()->data);
$I->assertContains($usersList[1]->username, $foundUsers);
$I->assertContains($usersList[1]->_id, $foundUsers);
$I->sendGET('api/v1/users?name=' . substr($user->username, 0, 3));
$foundUsers = json_encode($I->getResponseFields()->data);
$I->assertNotContains($user->username, $foundUsers);
$I->assertNotContains($user->_id, $foundUsers);
$I->loginUser($usersList[0]);
$I->sendGET('api/v1/users?name=' . substr($user->username, 0, 3));
$foundUsers = json_encode($I->getResponseFields()->data);
$I->assertContains($user->username, $foundUsers);
$I->assertContains($user->_id, $foundUsers);
}
示例3: settings
public function settings(ApiTester $I)
{
$I->createAndLoginUser();
$I->createProjectAndSetHeader();
$I->sendPUT('api/v1/projects', ['settings' => []]);
$I->assertProject();
$I->assertTrue($I->getResponseFields()->data->settings instanceof \StdClass);
}
示例4: hideMeta
public function hideMeta(ApiTester $I)
{
$I->createAndLoginUser();
$I->createProjectAndSetHeader(['settings' => ['show_meta' => false]]);
$I->createTable();
$I->makeDecision($I->getResponseFields()->data->_id, [], 'decision', false);
}