本文整理汇总了PHP中ApiTester::sendGET方法的典型用法代码示例。如果您正苦于以下问题:PHP ApiTester::sendGET方法的具体用法?PHP ApiTester::sendGET怎么用?PHP ApiTester::sendGET使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ApiTester
的用法示例。
在下文中一共展示了ApiTester::sendGET方法的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: 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']));
}
示例3: 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']);
}
}
示例4: getAll
/**
* getAll record
*
* @param \ApiTester $I
*/
public function getAll(ApiTester $I)
{
$I->wantTo('Get all user related conversion messages.');
$I->sendGET('http://currencyfairtest.com/api/messages');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson('SUCCESS');
}
示例5: showDiscussion
public function showDiscussion(ApiTester $I)
{
$I->wantTo('show a single discussion via API');
$discussion = Factory::create('Flarum\\Core\\Models\\Discussion');
$I->sendGET($this->endpoint . '/' . $discussion->id);
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->expect('the discussion in the response exists');
$I->seeResponseContainsJson(['discussions' => ['id' => (string) $discussion->id, 'title' => $discussion->title]]);
}
示例6: checkUserExists
public function checkUserExists(ApiTester $I, \Codeception\Scenario $scenario)
{
//$scenario->skip('ownCloud master is broken');
$I->wantTo('make sure the user exists');
$I->amHttpAuthenticated('admin', 'admin');
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
$I->sendGET($this->apiUrl . '/users/' . $this->userId);
$I->seeResponseCodeIs(200);
$I->seeResponseIsXml();
$I->seeXmlResponseIncludes(XmlUtils::toXml(['status' => 'ok']));
}
示例7: 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"');
}
示例8: 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']);
}
示例9: getCurrentUserScope
public function getCurrentUserScope(ApiTester $I)
{
$user = $I->createAndLoginUser();
$I->createProjectAndSetHeader();
$I->loginClient($I->getCurrentClient());
$second_user = $I->createUser(true);
$I->loginUser($user);
$I->sendPOST('api/v1/projects/users', ['user_id' => $second_user->_id, 'role' => 'manager', 'scope' => ['tables_view', 'tables_update']]);
$I->loginUser($second_user);
$I->sendGET('api/v1/projects/users');
$I->assertProjectUser();
}
示例10: ApiTester
<?php
$I = new ApiTester($scenario);
$I->wantTo('check games resource');
$I->sendGET('/teams/26?expand=games');
$I->seeResponseCodeIs(401);
$token = $I->login('q@q.q', 'q');
// show list of games for team
$I->haveHttpHeader('Authorization', "Bearer {$token}");
$I->sendGET('/teams/26?expand=games');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContains('games');
$games = $I->grabDataFromResponseByJsonPath('$.games')[0];
\PHPUnit_Framework_Assert::assertEquals(2, count($games));
$I->seeResponseContains('training');
$I->seeResponseContains('evening game');
// check for empty list for team with no games
$I->sendGET('/teams/27?expand=games');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContains('games');
$games = $I->grabDataFromResponseByJsonPath('$.games')[0];
\PHPUnit_Framework_Assert::assertEquals(0, count($games));
// create game
$I->sendPOST('/games', ['team_id' => 26, 'datetime' => date("Y-m-d H:i:s"), 'location' => "home", 'title' => "important game"]);
$I->seeResponseCodeIs(201);
$I->seeResponseIsJson();
$I->seeResponseContains('important game');
$I->seeResponseContains('home');
$gameId = $I->grabDataFromResponseByJsonPath('$.id')[0];
示例11: silksImageNotNullIfHorseracing
public function silksImageNotNullIfHorseracing(ApiTester $I)
{
$I->sendGET($this->endpoint . SOURCE);
$tips = $I->grabDataFromResponseByJsonPath('$.tips');
foreach ($tips[0] as $tip) {
if ($tip['sportname'] == 'Horse Racing') {
$I->assertNotNull($tip['silks_image'], 'silks_image is NULL at HorseRacing');
}
}
}
示例12: ApiTester
<?php
$I = new ApiTester($scenario);
$I->wantTo('Test the database/export endpoint via GET');
$I->haveHttpHeader('X-PublicKey', '248512b6a66f365a4e42f10ed0c854844767b8ca8eb0f74589953991e9f233b6');
$I->haveHttpHeader('X-Hash', 'e651e0f6450f89d82ab0a34c1d421097a635897f5e719179e49263ff145e6ed9');
$I->sendGET('database/export');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(array('assets' => array(0 => array('AssetID' => '4b67517f4462a', 'GenericAssetID' => '12636', 'UMDNS' => '12636', 'AssetFullName' => 'Dash', 'ManufacturerID' => '4c44276c3c2c0', 'Model' => '4000 ', 'SerialNumber' => 'SD008484463GA', 'InternalIventoryNumber' => '01382928', 'LocationID' => '4b6b4f5120321', 'ResponsiblePers' => NULL, 'AssetStatusID' => '1', 'AssetUtilizationID' => '1', 'PurchaseDate' => NULL, 'InstallationDate' => NULL, 'Lifetime' => '10', 'PurchasePrice' => '131174', 'CurrentValue' => '104939', 'WarrantyContractID' => '1', 'AgentID' => '4c90677ca7db7', 'WarrantyContractExp' => NULL, 'WarrantyContractNotes' => NULL, 'EmployeeID' => '4cb6b8bbb9df6', 'SupplierID' => '4b595a7124c8b', 'DonorID' => '4c9066fc81b53', 'Notes' => NULL, 'Picture' => 'gen_images/12636.jpg', 'lastmodified' => '2010-02-05 01:47:18', 'by_user' => 'demo', 'URL_Manual' => NULL, 'MetrologyDocument' => NULL, 'MetrologyDate' => NULL, 'Metrology' => '0'))));
$I->seeResponseContainsJson(array('location' => array(0 => array('LocationID' => '4b6b4f5120321', 'FacilityID' => '11', 'DeptID' => '2', 'Roomnb' => '', 'Floor' => '', 'Building' => '', 'NotetoTech' => '-'))));
$I->seeResponseContainsJson(array('facilities' => array(0 => array('FacilityID' => '11', 'DistrictID' => '10001', 'FacilityName' => 'Central Hosptial'))));
$I->seeResponseContainsJson(array('facilities' => array(0 => array('FacilityID' => '11', 'DistrictID' => '10001', 'FacilityName' => 'Central Hosptial'))));
$I->seeResponseContainsJson(array('contacttype' => array(0 => array('ContactTypeID' => '1', 'ContactTypeName' => 'Manufacturer'))));
$I->seeResponseContainsJson(array('contact' => array(0 => array('ContactID' => '4ac3718e8d251', 'ContactTypeID' => '3', 'ContactName' => 'Nespecificat', 'ContactPersonName' => NULL, 'ContactTitle' => NULL, 'Address' => NULL, 'City' => NULL, 'PostalCode' => NULL, 'CountryID' => '99999', 'PhoneNumber' => NULL, 'FaxNumber' => NULL, 'Website' => '', 'Services' => NULL))));
$I->seeResponseContainsJson(array('donors' => array(0 => array('DonorID' => '0', 'ContactID' => '4ac3718e8d251'))));
$I->seeResponseContainsJson(array('agents' => array(0 => array('AgentID' => '0', 'ContactID' => '4ac3718e8d251'))));
$I->seeResponseContainsJson(array('suppliers' => array(0 => array('SupplierID' => '4b59581a8bb8f', 'ContactID' => '4b59581a8abf1'))));
$I->seeResponseContainsJson(array('manufactures' => array(0 => array('ManufacturerID' => '4b0be58d2806b', 'ContactID' => '4b0be58d2612c'))));
$I->seeResponseContainsJson(array('consumables' => array(0 => array('ConsumableID' => '1', 'Name' => 'Sensor debit', 'ManufacturerID' => '4c62506a58149', 'PartNumber' => '121', 'PackageQty' => '1', 'SupplierID' => '4c36d8223e3cf', 'UnitPrice' => '1', 'Notes' => '1', 'lastmodified' => '2012-01-17 14:15:11', 'by_user' => 'demo', 'TypeCons' => NULL))));
$I->seeResponseContainsJson(array('consumables_linked' => array(0 => array('Consumable_linkedID' => '1', 'ConsumableID' => '1', 'AssetID' => '4f154ff62df0e', 'AnnualConsumption' => '100', 'Notes' => 'Order 2 month before'))));
$I->seeResponseContainsJson(array('employees' => array(0 => array('EmployeeID' => '0', 'LoginID' => '3', 'FirstName' => 'admin', 'LastName' => 'admin', 'Position' => NULL, 'TechnicianYN' => '1', 'LocationID' => '4b0be83d5d1d7', 'WorkPhone' => NULL, 'HandPhone' => NULL, 'Email' => NULL, 'Fax' => NULL, 'Accesslevel' => ' AND (facilities.FacilityID=12)'))));
$I->seeResponseContainsJson(array('department' => array(3 => array('DeptID' => '4', 'DepartmentDesc' => 'Allergology'))));
$I->seeResponseContainsJson(array('essential_equipment' => array(0 => array('EssentialEquipmentID' => '1', 'FacilityID' => '11', 'GenericAssetID' => '10134', 'MinimalQuantity' => '2', 'Notes' => NULL))));
$I->seeResponseContainsJson(array('assetgenericname' => array(0 => array('GenericAssetID' => '10134', 'GenericAssetCode' => '10134', 'GenericAssetName' => 'Anaesthesia Units', 'AssetCategoryID' => '5', 'GenericPicture' => 'gen_images/10134.jpg'))));
$I->seeResponseContainsJson(array('assetutilization' => array(0 => array('AssetUtilizationID' => '1', 'AssetUtilizationDesc' => 'Normal'))));
$I->seeResponseContainsJson(array('assetstatus' => array(0 => array('AssetStatusID' => '1', 'AssetStatusDesc' => 'Fully functional'))));
$I->seeResponseContainsJson(array('assetcategory' => array(0 => array('AssetCategoryID' => '1', 'AssetCategoryNr' => '1', 'AssetCategoryName' => 'Dental'))));
$I->seeResponseContainsJson(array('intervention' => array(0 => array('IntervID' => '532c5b53aab95', 'Date' => '2014-03-21', 'EmployeeID' => '4d64045c4a525', 'AssetStatusID' => '1', 'AssetID_Visit' => '4b67517f4462a', 'Request_id' => '52fddba460044', 'FaildPart' => 'Cable', 'FailurCategID' => '2', 'FailureCauseID' => '0', 'Interv_desc' => 'Description Intervention', 'Interv_desc_eg' => '', 'Comments' => 'Comments', 'RespEng' => '4c8fcac9f06fa', 'TotalWork' => '0', 'TotalCosts' => '0', 'lastmodified' => '2014-03-21 16:59:22', 'by_user' => 'demo'))));
$I->seeResponseContainsJson(array('request' => array(0 => array('Request_id' => '52fddba460044', 'Request_date' => '2014-02-14', 'Request_desc' => 'Repair', 'Request_desc_eg' => 'Repair', 'AssetID' => '4b67517f4462a', 'Request_st_id' => '1', 'Request_contact_name' => 'Agata Correia', 'Request_note' => 'Notes', 'lastmodified' => '2014-02-14 10:02:53', 'by_user' => 'demo', 'VisiTpID' => '1'))));
$I->seeResponseContainsJson(array('request_st' => array(0 => array('Request_st_id' => '1', 'Request_st_desc' => 'Open'))));
示例13: ApiTester
<?php
$I = new ApiTester($scenario);
$I->wantTo('Get all projects');
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
$I->sendGET('/projects');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson([['id' => 1, 'name' => 'Birdie'], ['id' => 2, 'name' => 'Fiskpinne'], ['id' => 3, 'name' => 'KulGrej']]);
示例14: hash
$treeHash->update($data);
$treeHash = bin2hex($treeHash->complete());
$hash = hash('sha256', $data);
$I->haveHttpHeader('Content-Type', 'application/octet-stream');
$I->haveHttpHeader('x-amz-archive-description', 'test123');
$I->haveHttpHeader('x-amz-sha256-tree-hash', $treeHash);
$I->haveHttpHeader('x-amz-content-sha256', $hash);
$I->sendPOST('/-/vaults/testvault/archives', $data);
$I->seeResponseCodeIs(201);
$I->seeResponseEquals('');
$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');
示例15: ApiTester
<?php
$scenario->group('rels');
$I = new ApiTester($scenario);
$I->wantTo('load the initial rels');
$I->sendGET('/rels');
$I->grabDataFromResponseByJsonPath('$');
$I->seeResponseContainsJson(['loadList' => '/list/elements', 'addToList' => '/list/elements', 'removeFromList' => '/list/elements']);