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


PHP ApiTester::sendPOST方法代码示例

本文整理汇总了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);
 }
开发者ID:excrucio,项目名称:RSC2015R-returnCaca,代码行数:28,代码来源:ApiCaptureFlagTest.php

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

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

示例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);
 }
开发者ID:adamstrawson,项目名称:BBMembershipSystem,代码行数:10,代码来源:ACSCest.php

示例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}");
 }
开发者ID:thangredweb,项目名称:redCORE,代码行数:14,代码来源:administrator.contact.1.0.0.Cest.php

示例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']));
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:11,代码来源:OcsCreateUserCest.php

示例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']);
 }
开发者ID:resulaslan,项目名称:sample-l4-app,代码行数:13,代码来源:PostsResourceCest.php

示例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]);
 }
开发者ID:adamstrawson,项目名称:BBMembershipSystem,代码行数:23,代码来源:DeviceAccessControlCest.php

示例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']);
 }
开发者ID:Qiang1234,项目名称:core,代码行数:15,代码来源:DiscussionsResourceCest.php

示例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);
开发者ID:GM-Team,项目名称:web,代码行数:15,代码来源:RequestInfoCept.php

示例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');
 }
开发者ID:Nebo15,项目名称:gandalf.api,代码行数:24,代码来源:TablesCest.php

示例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']);
 }
开发者ID:adamstrawson,项目名称:BBMembershipSystem,代码行数:11,代码来源:AccessControlCest.php

示例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}');
开发者ID:andsci,项目名称:hotels,代码行数:6,代码来源:ListHotelsCept.php

示例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();
 }
开发者ID:Nebo15,项目名称:gandalf.api,代码行数:12,代码来源:ProjectsCest.php

示例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();
开发者ID:AndriyK,项目名称:team,代码行数:31,代码来源:GamesCept.php


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