本文整理汇总了PHP中ApiTester::seeResponseMatchesJsonType方法的典型用法代码示例。如果您正苦于以下问题:PHP ApiTester::seeResponseMatchesJsonType方法的具体用法?PHP ApiTester::seeResponseMatchesJsonType怎么用?PHP ApiTester::seeResponseMatchesJsonType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ApiTester
的用法示例。
在下文中一共展示了ApiTester::seeResponseMatchesJsonType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: export
public function export(ApiTester $I)
{
$I->createAndLoginUser();
$I->createProjectAndSetHeader();
$I->createTable();
$I->sendGET('api/v1/projects/export');
$I->seeResponseCodeIs(200);
$I->seeResponseMatchesJsonType(['url' => 'string'], '$.data');
$I->assertTrue(false !== file_get_contents($I->getResponseFields()->data->url));
}
示例2: obtainAuthCodeGrant
function obtainAuthCodeGrant(ApiTester $I)
{
$user = factory(App\Models\User::class, 1)->create();
$user->password = 'password';
$user->save();
$I->amLoggedAs($user);
$client = factory(App\Models\OAuthClient::class, 1)->create();
$grant = \App\Models\OAuthGrant::find('authorization_code');
$client->oauth_grants()->attach($grant);
$scope = \App\Models\OAuthScope::find('user_read');
$client->oauth_scopes()->attach($scope);
$endpoint = factory(App\Models\OAuthClientEndpoint::class, 1)->make();
$endpoint->oauth_client()->associate($client);
$endpoint->save();
$I->wantTo('Perform a full 3rd party authorisation flow and get an access token');
$I->amOnPage('authorize?client_id=' . $client->id . '&redirect_uri=' . $endpoint->redirect_uri . '&response_type=code&scope=user_read');
$I->click('approve');
$I->seeInCurrentUrl('code=');
$url = Request::fullUrl();
$parts = parse_url($url);
parse_str($parts['query'], $query);
$code = $query['code'];
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
$I->sendPOST('oauth/access_token', ['grant_type' => 'authorization_code', 'client_id' => $client->id, 'client_secret' => $client->secret, 'redirect_uri' => $endpoint->redirect_uri, 'code' => $code]);
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseMatchesJsonType(['access_token' => 'string']);
}
示例3: createInvalid
public function createInvalid(ApiTester $I)
{
$I->createAndLoginUser();
$I->createProjectAndSetHeader();
$table_id = $I->createTable()->_id;
$I->sendPOST("api/v1/tables/{$table_id}/decisions", ['internal_credit_history' => 'okay']);
$I->seeResponseCodeIs(422);
$I->seeResponseMatchesJsonType(['borrowers_phone_verification' => 'array', 'contact_person_phone_verification' => 'array', 'property' => 'array', 'employment' => 'array'], '$.data');
$I->sendPOST("api/v1/tables/{$table_id}/decisions", ['internal_credit_history' => 'okay', 'borrowers_phone_verification' => 'okay', 'contact_person_phone_verification' => 'okay', 'property' => 'okay', 'employment' => 'okay']);
$I->seeResponseCodeIs(422);
$I->seeResponseMatchesJsonType(['property' => 'array', 'employment' => 'array'], '$.data');
}
示例4: ApiTester
<?php
/** @var AcceptanceTester $I */
$I = new ApiTester($scenario);
$I->wantTo('get list of frameworks');
$I->sendGET('/api/frameworks');
$I->seeResponseCodeIs(200);
$I->dontSeeResponseCodeIs(500);
$I->canSeeHttpHeader('Content-Type', 'application/json');
$I->seeResponseIsJson();
$I->seeResponseContainsJson(['name' => 'Phalcon', 'version' => '2.0.8']);
$I->seeResponseMatchesJsonType(['name' => 'string', 'version' => 'string:regex(~\\d\\.\\d\\.\\d~)']);
示例5: ApiTester
<?php
Yii::$app->redis->executeCommand('FLUSHDB');
use Codeception\Util\Debug;
$model = new \app\models\Message();
$model->author_email = 'test@gmail.com';
$model->author_name = 'test';
$model->message = str_repeat('A', 140);
$model->save();
$I = new ApiTester($scenario);
$I->wantTo('Ver uma mensagem');
$I->sendGET('messages/' . $model->id);
$I->seeResponseIsJson();
$I->seeResponseMatchesJsonType(['id' => 'string', 'author_name' => 'string', 'author_email' => 'string:email', 'creation_time' => 'string', 'message' => 'string']);