本文整理汇总了PHP中ApiTester::seeResponseIsJson方法的典型用法代码示例。如果您正苦于以下问题:PHP ApiTester::seeResponseIsJson方法的具体用法?PHP ApiTester::seeResponseIsJson怎么用?PHP ApiTester::seeResponseIsJson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ApiTester
的用法示例。
在下文中一共展示了ApiTester::seeResponseIsJson方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCaptureFlag
public function testCaptureFlag()
{
$token = $this->doLogin('player1@mailinator.com', '123456');
$this->tester->haveHttpHeader('Content-type', 'application/json');
$this->tester->haveHttpHeader('X-Api-token', $token);
$region = rand(1, 4);
$this->tester->sendPOST('/api/capture-flag', json_encode(['regionId' => $region]));
$this->tester->seeResponseCodeIs(200);
$this->tester->seeResponseIsJson();
$this->tester->haveHttpHeader('Content-type', 'application/json');
$this->tester->haveHttpHeader('X-Api-token', $token);
$this->tester->sendGET('/api/player-status');
$this->tester->seeResponseCodeIs(200);
$this->tester->seeResponseIsJson();
$data = json_decode($this->tester->grabResponse(), true);
$myTeamId = $data['data']['id'];
$this->tester->haveHttpHeader('Content-type', 'application/json');
$this->tester->sendGET('/api/game-status/1');
$this->tester->seeResponseCodeIs(200);
$this->tester->seeResponseIsJson();
$data = json_decode($this->tester->grabResponse(), true);
$data = $data['data'];
$this->assertArrayHasKey('ownerRegion1', $data);
$this->assertArrayHasKey('ownerRegion2', $data);
$this->assertArrayHasKey('ownerRegion3', $data);
$this->assertArrayHasKey('ownerRegion4', $data);
// $this->assertEquals($data['ownerRegion' . $region]['id'], $myTeamId);
}
示例2: checkLocationList
private function checkLocationList()
{
$this->tester->seeResponseCodeIs(200);
$this->tester->seeResponseIsJson();
$this->tester->seeResponseJsonMatchesJsonPath('$.status');
$this->tester->seeResponseJsonMatchesJsonPath('$.data');
$this->tester->seeResponseJsonMatchesJsonPath('$.data[0].lat');
$this->tester->seeResponseJsonMatchesJsonPath('$.data[0].lng');
$this->tester->seeResponseJsonMatchesJsonPath('$.data[0].game');
}
示例3: doCheckLogout
public function doCheckLogout($token)
{
// Do Logout
$this->tester->haveHttpHeader('Content-type', 'application/json');
$this->tester->haveHttpHeader('X-Api-Token', $token);
$this->tester->sendPOST('/api/logout');
$this->tester->seeResponseCodeIs(200);
$this->tester->seeResponseIsJson();
// Check is logged out
$this->checkIsLogin($token, false);
}
示例4: createPost
public function createPost(ApiTester $I)
{
$I->sendPOST($this->endpoint, ['title' => 'Game of Rings', 'body' => 'By George Tolkien']);
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(['title' => 'Game of Rings']);
$id = $I->grabDataFromJsonResponse('id');
$I->seeRecord('posts', ['id' => $id, 'title' => 'Game of Rings']);
$I->sendGET($this->endpoint . "/{$id}");
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(['title' => 'Game of Rings']);
}
示例5: updatePost
public function updatePost(ApiTester $I)
{
$id = $I->haveRecord('posts', $this->getPostAttributes(['title' => 'Game of Thrones']));
$I->sendPUT($this->endpoint . "/{$id}", ['title' => 'Lord of Thrones']);
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(['title' => 'Lord of Thrones']);
$I->seeRecord('posts', ['title' => 'Lord of Thrones']);
$I->dontSeeRecord('posts', ['title' => 'Game of Thrones']);
}
示例6: delete
/**
* @depends update
*/
public function delete(ApiTester $I)
{
$I->wantTo('Delete a new Contact in com_contacts using DELETE');
$I->amHttpAuthenticated('admin', 'admin');
$I->sendDELETE('index.php' . '?option=contact' . '&api=Hal' . '&webserviceClient=administrator' . '&webserviceVersion=1.0.0' . "&id={$this->id}");
$I->seeResponseCodeIs(200);
$I->sendGET('index.php' . '?option=contact' . '&api=Hal' . '&webserviceClient=administrator' . '&webserviceVersion=1.0.0' . "&id={$this->id}");
$I->seeResponseCodeIs(404);
$I->seeResponseIsJson();
$I->seeResponseContains('"message":"Item not found with given key.","code":404,"type":"Exception"');
}
示例7: checkStatList
private function checkStatList()
{
$this->tester->seeResponseCodeIs(200);
$this->tester->seeResponseIsJson();
$data = json_decode($this->tester->grabResponse(), true);
$this->tester->seeResponseJsonMatchesJsonPath('$.status');
$this->tester->seeResponseJsonMatchesJsonPath('$.data');
foreach ($data['data']['stats'] as $item) {
$this->assertArrayHasKey('team', $item);
$this->assertArrayHasKey('player', $item);
$this->assertArrayHasKey('id', $item['player']);
$this->assertArrayHasKey('alias', $item['player']);
$this->assertArrayHasKey('level', $item['player']);
$this->assertArrayHasKey('isLive', $item['player']);
$this->assertArrayHasKey('isLive', $item);
$this->assertArrayHasKey('location', $item);
$this->assertArrayHasKey('player', $item['location']);
$this->assertArrayHasKey('lat', $item['location']);
$this->assertArrayHasKey('lng', $item['location']);
$this->assertArrayHasKey('game', $item['location']);
}
}
示例8: updateDiscussion
public function updateDiscussion(ApiTester $I)
{
$I->wantTo('update a discussion via API');
$user = $I->amAuthenticated();
$discussion = Factory::create('Flarum\\Core\\Models\\Discussion', ['start_user_id' => $user->id]);
$I->sendPUT($this->endpoint . '/' . $discussion->id, ['discussions' => ['title' => 'foo']]);
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->expect('the discussion title was updated');
$I->seeResponseContainsJson(['title' => 'foo']);
$I->expect('the discussion was updated in the database');
$id = $I->grabDataFromJsonResponse('discussions.id');
$I->seeRecord('discussions', ['id' => $id, 'title' => 'foo']);
}
示例9: inactiveMemberLogin
public function inactiveMemberLogin(ApiTester $I)
{
$I->am('an inactive member');
$I->wantTo('post to the main door endpoint and get an OK back');
$user = $I->getInactiveKeyholderMember();
$keyFob = $I->getMemberKeyFob($user->id);
//Post the keyfob to the endpoint
$I->sendPOST('/access-control/main-door', ['data' => $keyFob->key_id]);
//The endpoint always returns 200
$I->seeResponseCodeIs(200);
//Make sure a good response is returned
$I->seeResponseIsJson();
//Response contains their name
//$I->seeResponseContains($user->given_name);
//Make sure the request was allowed
$I->seeResponseContainsJson(['valid' => '0']);
//Confirm an access log record was created
$I->seeInDatabase('access_log', ['user_id' => $user->id, 'key_fob_id' => $keyFob->id, 'response' => 402, 'service' => 'main-door']);
}
示例10: ApiTester
<?php
include 'version.php';
$I = new ApiTester($scenario);
$I->wantTo('fetch the version information for the web app');
$I->sendGET('version');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(["api_version" => $api_version, "app_version" => $app_version, "webapp_version" => $webapp_version]);
示例11: 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']);
}
示例12: missingRateError
/**
* @param \ApiTester $I
*/
public function missingRateError(ApiTester $I)
{
$I->wantTo('Error while saving: missing rate.');
$I->sendPost('http://currencyfairtest.com/api/messages', ["userId" => "100", "currencyFrom" => "EUR", "amountSell" => "999.0000", "timePlaced" => "31-AUG-15 22:00:00"]);
$I->seeResponseCodeIs(400);
$I->seeResponseIsJson();
$I->seeResponseContains('ERROR');
$I->seeResponseContains('rate');
$I->seeResponseContains('The rate field is required.');
}
示例13: serversRespondsWitJson
public function serversRespondsWitJson(ApiTester $I)
{
$I->sendGET($this->endpoint . SOURCE);
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
}