private function checkGenericLoginData() { $this->tester->seeResponseJsonMatchesJsonPath('$.status'); $this->tester->seeResponseJsonMatchesJsonPath('$.data.username'); $this->tester->seeResponseJsonMatchesJsonPath('$.data.email'); $this->tester->seeResponseJsonMatchesJsonPath('$.data.registrationId'); }
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']); } }
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'); }
<?php Yii::$app->redis->executeCommand('FLUSHDB'); use Codeception\Util\Debug; $model = new \app\models\Message(); $model->author_email = '*****@*****.**'; $model->author_name = 'test'; $model->message = str_repeat('A', 140); $model->save(); $I = new ApiTester($scenario); $I->wantTo('Ver a lista de mensagens'); $I->sendGET('messages', []); $I->seeResponseIsJson(); $I->seeResponseJsonMatchesJsonPath('$[0].author_name'); $I->seeResponseJsonMatchesJsonPath('$[0].author_email'); $I->seeResponseJsonMatchesJsonPath('$[0].message'); $I->seeResponseJsonMatchesJsonPath('$[0].id'); $I->seeResponseJsonMatchesJsonPath('$[0].creation_time');
<?php $I = new ApiTester($scenario); $I->wantTo('log in as an anonymous user'); $I->sendPOST('users/login'); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); $I->seeResponseJsonMatchesJsonPath('$.skey'); $I->seeResponseJsonMatchesJsonPath('$.userid'); $I->seeResponseJsonMatchesJsonPath('$.email'); $guidResponse = $I->getRequestJSON(); $I->wantTo('log in as an anonymous user using a previous GUID'); $I->sendPOST('users/login', ['username' => $guidResponse['email']]); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); $I->seeResponseContainsJSON(['email' => $guidResponse['email']]); $I->seeResponseContainsJSON(['userid' => $guidResponse['userid']]); $I->wantTo('fail to log in with an unregistered CCID'); $I->sendPOST('users/login', ['username' => '@12345678']); $I->seeResponseCodeIs(401); $I->wantTo('fail to log in with an incorrect CCID password'); $I->sendPOST('users/login', ['username' => '*****@*****.**', 'password' => 'obviouslybadpassword']); $I->seeResponseCodeIs(401);
<?php $I = new ApiTester($scenario); $I->wantTo('get a list of all cards'); $I->amHttpAuthenticated('test_api', '123456'); $I->haveHttpHeader('Content-Type', 'application/json'); $I->sendGET('/cards'); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); $I->seeResponseJsonMatchesJsonPath('$[0].result');
<?php $I = new ApiTester($scenario); $I->wantTo('List vaults.'); $I->haveAuth(); $I->sendPUT('/-/vaults/testvault1'); $I->seeResponseCodeIs(201); $I->sendPUT('/-/vaults/testvault2'); $I->seeResponseCodeIs(201); $I->sendPUT('/-/vaults/testvault3'); $I->seeResponseCodeIs(201); $I->sendGET('/-/vaults'); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); $I->seeResponseJsonMatchesJsonPath('$.VaultList'); $I->seeResponseJsonMatchesJsonPath('$.VaultList[*].VaultName'); $I->seeResponseJsonMatchesJsonPath('$.VaultList[*].CreationDate'); $I->seeResponseJsonMatchesJsonPath('$.VaultList[*].LastInventoryDate'); $I->seeResponseJsonMatchesJsonPath('$.VaultList[*].NumberOfArchives'); $I->seeResponseJsonMatchesJsonPath('$.VaultList[*].SizeInBytes'); $I->seeResponseJsonMatchesJsonPath('$.VaultList[*].VaultARN'); $I->sendDELETE('/-/vaults/testvault1'); $I->seeResponseCodeIs(204); $I->sendDELETE('/-/vaults/testvault2'); $I->seeResponseCodeIs(204); $I->sendDELETE('/-/vaults/testvault3'); $I->seeResponseCodeIs(204);
<?php $I = new ApiTester($scenario); $I->wantTo('validate that test route works properly'); $I->sendGET('/test'); $I->seeResponseIsJson(); $I->seeResponseJsonMatchesJsonPath('$.message');
<?php $I = new ApiTester($scenario); $I->wantTo('list the most recent photos in the feed'); $I->sendGET('photos'); $I->seeResponseCodeIs(200); //TODO: Check for reasonable values $I->seeResponseJsonMatchesJsonPath('$.next_id'); $I->seeResponseJsonMatchesJsonPath('$.from_id'); $I->seeResponseJsonMatchesJsonPath('$.count'); //TODO: check for Creative Commons values $I->seeResponseJsonMatchesJsonPath('$photos[*].itemid'); $I->seeResponseJsonMatchesJsonPath('$photos[*].url'); $I->seeResponseJsonMatchesJsonPath('$photos[*].title'); $I->seeResponseJsonMatchesJsonPath('$photos[*].description'); $I->seeResponseJsonMatchesJsonPath('$photos[*].category'); $I->seeResponseJsonMatchesJsonPath('$photos[*].approved'); $I->seeResponseJsonMatchesJsonPath('$photos[*].username'); $I->seeResponseJsonMatchesJsonPath('$photos[*].userid'); $I->seeResponseJsonMatchesJsonPath('$photos[*].makerid'); $I->seeResponseJsonMatchesJsonPath('$photos[*].makername');
<?php $I = new ApiTester($scenario); $I->wantTo('get the list of latest items from the master list'); $I->sendGET('items'); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); //TODO: ensure count is 20 // The responses are random, so we cannot check specific id/title/etc. values //TODO: check for Creative Commons values $I->seeResponseJsonMatchesJsonPath('$[*].id'); $I->seeResponseJsonMatchesJsonPath('$[*].makerid'); $I->seeResponseJsonMatchesJsonPath('$[*].title'); $I->seeResponseJsonMatchesJsonPath('$[*].description'); $I->seeResponseJsonMatchesJsonPath('$[*].uri'); $I->seeResponseJsonMatchesJsonPath('$[*].approved'); $I->seeResponseJsonMatchesJsonPath('$[*].category'); $I->seeResponseJsonMatchesJsonPath('$[*].name');