本文整理汇总了PHP中ApiTester::seeResponseCodeIs方法的典型用法代码示例。如果您正苦于以下问题:PHP ApiTester::seeResponseCodeIs方法的具体用法?PHP ApiTester::seeResponseCodeIs怎么用?PHP ApiTester::seeResponseCodeIs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ApiTester
的用法示例。
在下文中一共展示了ApiTester::seeResponseCodeIs方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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"');
}
示例5: 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']);
}
示例6: testTestUsersCreation
public function testTestUsersCreation(ApiTester $I)
{
$I->wantTo('make sure my test users have been created');
$I->amHttpAuthenticated('admin', 'admin');
$I->sendGET($this->baseUrl . '/users/' . $this->userId);
$I->seeResponseCodeIs(200);
$I->seeResponseIsXml();
$I->seeXmlResponseIncludes(XmlUtils::toXml(['status' => 'ok']));
$I->sendGET($this->baseUrl . '/users/' . $this->sharerUserId);
$I->seeResponseCodeIs(200);
$I->seeResponseIsXml();
$I->seeXmlResponseIncludes(XmlUtils::toXml(['status' => 'ok']));
}
示例7: deletePost
public function deletePost(ApiTester $I)
{
$id = $I->haveRecord('posts', $this->getPostAttributes(['title' => 'Game of Thrones']));
$I->sendDELETE($this->endpoint . "/{$id}");
$I->seeResponseCodeIs(200);
$I->dontSeeRecord('posts', ['id' => $id]);
}
示例8: deleteUser
public function deleteUser(ApiTester $I, \Codeception\Scenario $scenario)
{
//$scenario->skip('ownCloud master is broken');
$I->wantTo('delete the user');
$I->amHttpAuthenticated('admin', 'admin');
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
$I->sendDELETE($this->apiUrl . '/users/' . $this->userId);
$I->seeResponseCodeIs(200);
$I->seeResponseIsXml();
$I->seeXmlResponseIncludes(XmlUtils::toXml(['status' => 'ok']));
}
示例9: deleteDiscussion
public function deleteDiscussion(ApiTester $I)
{
$I->wantTo('delete a discussion via API');
$user = $I->amAuthenticated();
$user->groups()->attach(4);
// Make the user a moderator
$discussion = Factory::create('Flarum\\Core\\Models\\Discussion', ['start_user_id' => $user->id]);
$I->sendDELETE($this->endpoint . '/' . $discussion->id);
$I->seeResponseCodeIs(204);
$I->seeResponseEquals('');
$I->expect('the discussion was deleted in the database');
$I->dontSeeRecord('discussions', ['id' => $discussion->id]);
}
示例10: 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']);
}
}
示例11: ApiTester
<?php
use Codeception\Util\Fixtures;
/** @var Faker\Generator $faker */
$faker = Fixtures::get('faker');
$devs = Fixtures::get('devs');
$I = new ApiTester($scenario);
$I->wantTo('get the user price based on the GitHub API');
$I->amGoingTo('Get a non-existent user');
$I->sendGET('dev/' . $faker->lexify('??????????'));
$I->seeResponseCodeIs(404);
$I->amGoingTo('Get an existent user');
$I->sendGET('dev/' . $devs[array_rand($devs)]);
$I->seeResponseCodeIs(200);
$dev = json_decode($I->grabResponse());
$I->assertTrue(is_numeric($dev->rate), 'rate is numeric');
$I->assertTrue(is_string($dev->username) && strlen($dev->username) != 0, 'username is present and is string');
示例12: ApiTester
<?php
$request_body = ['interaction_id' => 'SD000000099', 'category' => 'Laptop', 'issue' => 'Wont turn on!', 'status' => 'Submitted', 'description' => 'Yes, I have it plugged in!', 'affected_service' => 'Laptop', 'notify_type' => 'CALLME', 'phase' => 'WIP', 'last_update_date' => '7-7-17, 7:57:57 PM EDT'];
$response_body = ['status' => 'Successful update'];
$I = new ApiTester($scenario);
$I->wantTo('update a ticket');
$I->haveHttpHeader('Content-Type', 'application/json');
$I->sendPOST('/tickets/', $request_body);
$I->seeResponseCodeIs(201);
$I->seeResponseIsJson();
$I->seeResponseContainsJson($response_body);
示例13: 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.');
}
示例14: ApiTester
<?php
$I = new ApiTester($scenario);
$I->wantTo('get new pid for a user');
$I->haveHttpHeader(' Content-Type', 'xxyyzz');
$I->sendPOST('http://localhost/api/v1/action/GetPid.php', json_encode(array('action' => 'GetPid')));
$I->seeResponseCodeIs(400);
$I->seeResponseIsJson();
示例15: 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]);