本文整理汇总了PHP中ApiTester::sendPOST方法的典型用法代码示例。如果您正苦于以下问题:PHP ApiTester::sendPOST方法的具体用法?PHP ApiTester::sendPOST怎么用?PHP ApiTester::sendPOST使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ApiTester
的用法示例。
在下文中一共展示了ApiTester::sendPOST方法的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: 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);
}
示例3: testSubmitLocation
public function testSubmitLocation()
{
$token = $this->doLogin('player1@mailinator.com', '123456');
$latLng = AppBundle\Helper\LatLngHelper::getRandomLatLngNear(46.308245, 16.337884);
$this->tester->haveHttpHeader('Content-type', 'application/json');
$this->tester->haveHttpHeader('X-Api-token', $token);
$this->tester->sendPOST('/api/locations', json_encode(['lat' => $latLng['lat'], 'lng' => $latLng['lng']]));
$this->tester->seeResponseCodeIs(200);
$this->tester->seeResponseIsJson();
$this->tester->seeResponseJsonMatchesJsonPath('$.status');
$this->tester->seeResponseJsonMatchesJsonPath('$.message');
}
示例4: invalidTime
public function invalidTime(ApiTester $I)
{
$I->am('an invalid device');
$I->wantTo('verify the endpoint returns validation failures - invalid time');
//Send a bad code to the endpoint
$I->haveHttpHeader('Content-Type', 'application/json');
$I->haveHttpHeader('Accept', 'application/json');
$I->sendPOST('/acs', ['device' => 'main-door', 'tag' => 'ABCDEF123456', 'message' => 'boot', 'service' => 'entry', 'time' => 'abcdefgh']);
$I->canSeeResponseCodeIs(422);
}
示例5: create
/**
* @depends WebserviceIsAvailable
*/
public function create(ApiTester $I)
{
$I->wantTo('POST a new Contact in com_contacts');
$I->amHttpAuthenticated('admin', 'admin');
$I->sendPOST('index.php' . '?option=contact' . '&api=Hal' . '&webserviceClient=administrator' . '&webserviceVersion=1.0.0' . "&name={$this->name}" . '&catid=4');
$I->seeResponseCodeIs(201);
$I->seeResponseIsJson();
$contactIDs = $I->grabDataFromResponseByJsonPath('$.id');
$this->id = $contactIDs[0];
$I->comment("The id of the new created user is: {$this->id}");
}
示例6: createUser
public function createUser(ApiTester $I, \Codeception\Scenario $scenario)
{
//$scenario->skip('ownCloud master is broken');
$I->wantTo('create a user via the provisioning API');
$I->amHttpAuthenticated('admin', 'admin');
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
$I->sendPOST($this->apiUrl . '/users', ['userid' => $this->userId, 'password' => 'test' . $this->userId]);
$I->seeResponseCodeIs(200);
$I->seeResponseIsXml();
$I->seeXmlResponseIncludes(XmlUtils::toXml(['status' => 'ok']));
}
示例7: 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']);
}
示例8: successfullEnd
public function successfullEnd(ApiTester $I)
{
$I->am('a valid user');
$I->wantTo('verify the endpoint returns a success response and creates the proper records');
$user = $I->getActiveKeyholderMember();
$keyFob = $I->getMemberKeyFob($user->id);
//Send a bad code to the endpoint
$I->sendPOST('/access-control/device', ['data' => $keyFob->key_id . '|welder|start']);
//The device endpoint always returns 200
$I->canSeeResponseCodeIs(200);
//Make sure a success is returned and a session started
$I->canSeeResponseContainsJson(['valid' => '1']);
$I->seeInDatabase('equipment_log', ['user_id' => $user->id, 'device' => 'welder', 'active' => 1]);
$I->sendPOST('/access-control/device', ['data' => $keyFob->key_id . '|welder|end']);
$I->canSeeResponseCodeIs(200);
$I->dontSeeHttpHeader('Set-Cookie');
$I->dontSeeHttpHeader('Built-By');
$I->canSeeResponseContainsJson(['valid' => '1']);
//Make sure our database record is not active
$I->seeInDatabase('equipment_log', ['user_id' => $user->id, 'device' => 'welder', 'active' => 0]);
//And make sure there is no other active record
$I->cantSeeInDatabase('equipment_log', ['user_id' => $user->id, 'device' => 'welder', 'active' => 1]);
}
示例9: createDiscussion
public function createDiscussion(ApiTester $I)
{
$I->wantTo('create a discussion via API');
$I->amAuthenticated();
$I->sendPOST($this->endpoint, ['discussions' => ['title' => 'foo', 'content' => 'bar']]);
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->expect('the discussion is included in the response');
$I->seeResponseContainsJson(['title' => 'foo']);
$I->expect('posts are included in the response');
$I->seeResponseContainsJson(['type' => 'comment', 'contentHtml' => '<p>bar</p>']);
$I->expect('the discussion was created in the database');
$id = $I->grabDataFromJsonResponse('discussions.id');
$I->seeRecord('discussions', ['id' => $id, 'title' => 'foo']);
}
示例10: ApiTester
<?php
$request_body = ['interaction_id' => 'SD000000009', 'message' => 'Hey yo this is a test'];
$response_body = ['success' => 'Request for additional information successful!'];
$I = new ApiTester($scenario);
$I->wantTo('send request for additional information to user (through push notification and log update)');
//$I->haveHttpHeader('Content-Type', 'application/json');
//$I->sendGET('/request_info?id=SD000000008');
$I = new ApiTester($scenario);
$I->wantTo('ask for additional information');
$I->haveHttpHeader('Content-Type', 'application/json');
$I->sendPOST('/request_info/', $request_body);
//$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson($response_body);
示例11: variantsProbabilityInvalid
public function variantsProbabilityInvalid(ApiTester $I)
{
$I->createAndLoginUser();
$I->createProjectAndSetHeader();
# invalid variants_probability
$data = $I->getTableShortData();
$data['variants_probability'] = 'invalid';
$I->sendPOST('api/v1/admin/tables', $data);
$I->seeResponseCodeIs(422);
$I->seeResponseContains('variants_probability');
# more than 100
$data['variants_probability'] = 'percent';
$data['variants'][0]['probability'] = 30;
$data['variants'][0]['title'] = 'Variant 1';
$data['variants'][1] = ['title' => 'Variant 2', 'default_title' => 'Variant 2', 'default_description' => 'Description Variant 2', 'default_decision' => 'Decline', 'probability' => 71, 'rules' => $I->getVariantRules()];
$I->sendPOST('api/v1/admin/tables', $data);
$I->seeResponseCodeIs(422);
$I->seeResponseContains('variants_probability');
# less than 100
$data['variants'][0]['probability'] = 28;
$I->sendPOST('api/v1/admin/tables', $data);
$I->seeResponseCodeIs(422);
$I->seeResponseContains('variants_probability');
}
示例12: unknownDeviceSystemMessage
public function unknownDeviceSystemMessage(ApiTester $I)
{
$I->am('sending a valid system message');
$I->wantTo('confirm it is received and handled correctly');
//Post the keyfob to the endpoint
$I->sendPOST('/access-control/main-door', ['data' => ':unknown|unknown']);
//The endpoint always returns 200
$I->seeResponseCodeIs(200);
//Confirm an access log record was created
//$I->seeInDatabase('access_log', ['user_id'=>$user->id, 'key_fob_id'=>$keyFob->id, 'response'=>200, 'service'=>'main-door']);
}
示例13: ApiTester
<?php
$I = new ApiTester($scenario);
$I->wantTo('Get list of hotels');
$I->sendPOST('/hotels-api', []);
$I->seeResponseContains('{"id":"1","title":"Tonyresort","image":"http:\\/\\/andriuss.ktu.ongr.rocks\\/src\\/Frontend\\/Files\\/hotels\\/images\\/source\\/download(6).jpg","country":"Lithuania","city":"Vilnius"},{"id":"3","title":"Kaunas","image":"http:\\/\\/andriuss.ktu.ongr.rocks\\/src\\/Frontend\\/Files\\/hotels\\/images\\/source\\/36207618.jpg","country":"Lithuania","city":"Kaunas"},{"id":"4","title":"Gaia Village","image":"http:\\/\\/andriuss.ktu.ongr.rocks\\/src\\/Frontend\\/Files\\/hotels\\/images\\/source\\/211050_xl.jpg","country":null,"city":null},{"id":"5","title":"Europa Royale","image":"http:\\/\\/andriuss.ktu.ongr.rocks\\/src\\/Frontend\\/Files\\/hotels\\/images\\/source\\/big_4ac32e645761a.jpg","country":null,"city":null}');
示例14: 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();
}
示例15: count
$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];
$I->sendGET('/teams/26?expand=games');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContains('games');
$games = $I->grabDataFromResponseByJsonPath('$.games')[0];
\PHPUnit_Framework_Assert::assertEquals(3, count($games));
// Join one player to the game
$I->sendPUT("/games/{$gameId}", ['join_player' => 33]);
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();