当前位置: 首页>>代码示例>>PHP>>正文


PHP ApiTester::grabResponse方法代码示例

本文整理汇总了PHP中ApiTester::grabResponse方法的典型用法代码示例。如果您正苦于以下问题:PHP ApiTester::grabResponse方法的具体用法?PHP ApiTester::grabResponse怎么用?PHP ApiTester::grabResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ApiTester的用法示例。


在下文中一共展示了ApiTester::grabResponse方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
 }
开发者ID:excrucio,项目名称:RSC2015R-returnCaca,代码行数:28,代码来源:ApiCaptureFlagTest.php

示例2: testGetLocationsWithFilters

 public function testGetLocationsWithFilters()
 {
     $token = $this->doLogin('player1@mailinator.com', '123456');
     $this->tester->haveHttpHeader('Content-type', 'application/json');
     $this->tester->haveHttpHeader('X-Api-token', $token);
     $filter = ['game' => 1];
     $this->tester->sendGET('/api/locations', $filter);
     $this->checkLocationList();
     $data = json_decode($this->tester->grabResponse(), true);
     foreach ($data['data'] as $item) {
         $this->assertEquals($filter['game'], $item['game']);
     }
 }
开发者ID:excrucio,项目名称:RSC2015R-returnCaca,代码行数:13,代码来源:ApiLocationTest.php

示例3: checkDecisionAccess

 public function checkDecisionAccess(ApiTester $I)
 {
     $user = $I->createAndLoginUser();
     $I->createProjectAndSetHeader();
     $table = $I->createTable($I->getShortTableDataMatchingTypeAll());
     $decisions = ['points' => 15, 'request' => ['string' => 'Invalid', 'numeric' => 1, 'bool' => false]];
     $data = $I->makeDecision($table->_id, $decisions['request'], 'scoring');
     $I->sendGET('api/v1/admin/decisions');
     $I->assertContains($data->_id, $I->grabResponse());
     $second_user = $I->createUser(true);
     $I->loginUser($second_user);
     $I->createProject(true);
     $I->sendGET('api/v1/admin/decisions');
     $I->assertNotContains($data->_id, $I->grabResponse());
     $I->loginUser($user);
     $I->sendPOST('api/v1/projects/users', ['user_id' => $second_user->_id, 'role' => 'manager', 'scope' => ['tables_create', 'tables_view', 'tables_update', 'decisions_view']]);
     $I->loginUser($second_user);
     $I->sendGET('api/v1/admin/decisions');
     $I->assertContains($data->_id, $I->grabResponse());
 }
开发者ID:Nebo15,项目名称:gandalf.api,代码行数:20,代码来源:DecisionsCest.php

示例4: testLoginUser

 public function testLoginUser()
 {
     $this->checkIsLogin('', false);
     $this->tester->haveHttpHeader('Content-type', 'application/json');
     $this->tester->sendPOST('/api/login', json_encode(['email' => 'user@mailinator.com', 'password' => '123456']));
     $this->tester->seeResponseCodeIs(200);
     $this->tester->seeResponseIsJson();
     $this->checkGenericLoginData();
     $response = json_decode($this->tester->grabResponse(), true);
     $token = $response['data']['token'];
     // Check login is true
     $this->checkIsLogin($token, true);
     // 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);
 }
开发者ID:excrucio,项目名称:RSC2015R-returnCaca,代码行数:21,代码来源:TestApiLoginLogoutTest.php

示例5: 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']);
     }
 }
开发者ID:excrucio,项目名称:RSC2015R-returnCaca,代码行数:22,代码来源:ApiStatsTest.php

示例6:

$archiveID = $I->grabHttpHeader('x-amz-archive-id');
$I->haveHttpHeader('Content-Type', 'application/json');
$I->sendPOST('/-/vaults/testvault/jobs', ['Type' => 'archive-retrieval', 'ArchiveId' => $archiveID]);
$I->seeResponseCodeIs(202);
$jobID = $I->grabHttpHeader('x-amz-job-id');
$I->sendGET("/-/vaults/testvault/jobs/{$jobID}");
$I->seeResponseCodeIs(200);
$I->seeResponseContainsJson(['StatusCode' => 'InProgress']);
$I->sendPOST("/-/vaults/testvault/jobs/{$jobID}/force-complete", []);
$I->seeResponseCodeIs(200);
$I->sendGET("/-/vaults/testvault/jobs/{$jobID}");
$I->seeResponseCodeIs(200);
$I->seeResponseContainsJson(['StatusCode' => 'Succeeded']);
$I->sendGET("/-/vaults/testvault/jobs/{$jobID}/output");
$I->seeResponseCodeIs(200);
$this->assertTrue($I->grabResponse() === $data);
$I->haveHttpHeader('Range', 'bytes=0-1');
$I->sendGET("/-/vaults/testvault/jobs/{$jobID}/output");
$I->seeResponseCodeIs(206);
$this->assertTrue($I->grabResponse() === 'AB');
$I->haveHttpHeader('Range', 'bytes=2-3');
$I->sendGET("/-/vaults/testvault/jobs/{$jobID}/output");
$I->seeResponseCodeIs(206);
$this->assertTrue($I->grabResponse() === 'CD');
$I->haveHttpHeader('Content-Type', 'application/json');
$I->sendPOST('/-/vaults/testvault/jobs', ['Type' => 'archive-retrieval', 'ArchiveId' => $archiveID, 'RetrievalByteRange' => '1-1048575']);
$I->seeResponseCodeIs(202);
$jobID = $I->grabHttpHeader('x-amz-job-id');
$I->sendPOST("/-/vaults/testvault/jobs/{$jobID}/force-complete", []);
$I->seeResponseCodeIs(200);
$I->haveHttpHeader('Range', '');
开发者ID:sebcode,项目名称:gsandbox,代码行数:31,代码来源:RetrieveArchiveCept.php

示例7: ApiTester

<?php

$I = new ApiTester($scenario);
$I->wantTo('Insert items and checkout');
/**
 * @var array $item1
 * @var array $item2
 * @var int   $order
 */
require "_AddItems.php";
$I->amGoingTo('checkout');
$I->sendPATCH('cart');
$I->seeCodeAndJson(200, ['id' => $order, 'total' => floatify($item1['final_price'] + $item2['final_price'])]);
$I->amGoingTo('verify the order was really ~closed~');
$I->sendGET('cart');
$I->assertEquals(sizeof(json_decode($I->grabResponse())->items), 0, 'verify the cart is now empty');
开发者ID:igorsantos07,项目名称:developer-shop,代码行数:16,代码来源:CheckoutCept.php

示例8: 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');
开发者ID:igorsantos07,项目名称:developer-shop,代码行数:17,代码来源:DetailsCept.php

示例9: consumers

 public function consumers(ApiTester $I)
 {
     $faker = $I->getFaker();
     $I->createAndLoginUser();
     $I->createProjectAndSetHeader();
     $I->createConsumer();
     $I->sendPOST('api/v1/projects/consumers', ['description' => $faker->text('20'), 'scope' => ['decisions_view', 'decisions_make']]);
     $consumer = json_decode($I->grabResponse())->data[0];
     $I->assertConsumers('$.data[*]', 201);
     $text = $faker->text('20');
     $I->sendPUT('api/v1/projects/consumers', ['description' => $text, 'scope' => ['decisions_view', 'decisions_make'], 'client_id' => $consumer->client_id]);
     $I->seeResponseContains($text);
     $I->assertConsumers();
     $I->sendDELETE('api/v1/projects/consumers', ['client_id' => $consumer->client_id]);
     $I->cantSeeResponseContains($consumer->client_id);
     $I->assertConsumers();
 }
开发者ID:Nebo15,项目名称:gandalf.api,代码行数:17,代码来源:ProjectsCest.php

示例10: invitation

 public function invitation(ApiTester $I)
 {
     $faker = $I->getFaker();
     $I->createAndLoginUser();
     $first_project = $I->createProjectAndSetHeader();
     $second_user_email = $faker->email;
     $I->sendPOST('api/v1/invite', ['email' => $second_user_email, 'role' => 'manager', 'scope' => ['tables_create', 'tables_view']]);
     $I->seeResponseCodeIs(200);
     $second_project = $I->createProject(true);
     $I->setHeader('X-Application', $second_project->_id);
     $I->sendPOST('api/v1/invite', ['email' => $second_user_email, 'role' => 'manager', 'scope' => ['tables_create', 'tables_view']]);
     $I->seeResponseCodeIs(200);
     $I->logout();
     $I->loginClient($I->getCurrentClient());
     $I->loginUser($I->createUser(true, $second_user_email));
     $I->sendGET('api/v1/projects');
     $I->seeResponseCodeIs(200);
     $I->assertContains($first_project->_id, $I->grabResponse());
     $I->assertContains($second_project->_id, $I->grabResponse());
 }
开发者ID:Nebo15,项目名称:gandalf.api,代码行数:20,代码来源:UsersCest.php

示例11: ApiTester

/** @var Faker\Generator $faker */
$faker = Fixtures::get('faker');
$orgs = Fixtures::get('orgs');
$sm_orgs = Fixtures::get('small_orgs');
$I = new ApiTester($scenario);
$I->wantTo('list of developers of an organization');
$I->amGoingTo('Get a non-existent organization');
$I->sendGET('dev/organization/' . $faker->lexify('??????????'));
$I->seeResponseCodeIs(404);
$I->amGoingTo('Get an existent organization on different information levels');
$get_org = function ($level, $orgs) use($I) {
    $I->amGoingTo("Request Org {$level} information");
    $query = $level ? '?level=' . $level : '';
    $I->sendGET('dev/organization/' . $orgs[array_rand($orgs)] . $query);
    $I->seeResponseCodeIs(200);
    $org = json_decode($I->grabResponse(), true);
    $I->assertTrue(is_numeric($org['size']), 'has total of members');
    $I->assertTrue(is_array($org['members']), 'has list of members');
    $I->assertGreaterThanOrEqual(1, $org['size'], 'organization has at least one member');
    $I->assertEquals(sizeof($org['members']), $org['size'], 'total is correctly calculated');
    $I->assertTrue(is_string($org['members'][0]['username']), 'first member has "username"');
    return $org;
};
$org = $get_org('basic', $orgs);
$I->assertEmpty($org['members'][0]['name']);
$I->assertEmpty($org['members'][0]['repos']);
$I->assertEmpty($org['members'][0]['rate']);
$org = $get_org(null, $orgs);
$I->assertTrue(is_string($org['members'][0]['name']));
$I->assertTrue(is_numeric($org['members'][0]['repos']));
$I->assertEmpty($org['members'][0]['rate']);
开发者ID:igorsantos07,项目名称:developer-shop,代码行数:31,代码来源:OrganizationCept.php


注:本文中的ApiTester::grabResponse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。