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


PHP AcceptanceTester::sendPOST方法代码示例

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


在下文中一共展示了AcceptanceTester::sendPOST方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createAnExpectationWithRegexReplacementFromBodyAndUrl

 public function createAnExpectationWithRegexReplacementFromBodyAndUrl(AcceptanceTester $I)
 {
     $expectation = PhiremockClient::on(A::postRequest()->andUrl(Is::matching('/&test=(\\d+)/'))->andBody(Is::matching('/a tomato (\\d+)/')))->then(Respond::withStatusCode(200)->andBody('the numbers are ${url.1} and ${body.1}'));
     $this->phiremock->createExpectation($expectation);
     $I->sendPOST('/potato?param1=123&test=456', 'this is a tomato 3kg it weights');
     $I->seeResponseCodeIs('200');
     $I->seeResponseContains('the numbers are 456 and 3');
 }
开发者ID:mcustiel,项目名称:phiremock,代码行数:8,代码来源:ReplacementCest.php

示例2: failOnEmptyHeadersInspecificationTest

 public function failOnEmptyHeadersInspecificationTest(AcceptanceTester $I)
 {
     $I->wantTo('fail when creating a specification with invalid headers');
     $request = new Request();
     $request->setUrl(new Condition('isEqualTo', '/the/request/url'));
     $response = (new Response())->setHeaders('potato');
     $specification = new Expectation();
     $specification->setRequest($request)->setResponse($response);
     $I->haveHttpHeader('Content-Type', 'application/json');
     $I->sendPOST('/__phiremock/expectations', $specification);
     $I->seeResponseCodeIs(500);
 }
开发者ID:mcustiel,项目名称:phiremock,代码行数:12,代码来源:HeadersSpecificationCest.php

示例3: failWhenInvalidValueSpecifiedTest

 public function failWhenInvalidValueSpecifiedTest(AcceptanceTester $I)
 {
     $I->wantTo('create an expectation that checks url using matches');
     $request = new Request();
     $request->setUrl(new Condition('isEqualTo', null));
     $response = new Response();
     $response->setStatusCode(201);
     $expectation = new Expectation();
     $expectation->setRequest($request)->setResponse($response);
     $I->haveHttpHeader('Content-Type', 'application/json');
     $I->sendPOST('/__phiremock/expectations', $expectation);
     $I->seeResponseCodeIs(500);
     $I->seeResponseIsJson();
     $I->seeResponseEquals('{"result" : "ERROR", "details" : ["Condition value can not be null"]}');
 }
开发者ID:mcustiel,项目名称:phiremock,代码行数:15,代码来源:UrlConditionCest.php

示例4: useDefaultWhenNoStatusCodeIsSetTest

 public function useDefaultWhenNoStatusCodeIsSetTest(AcceptanceTester $I)
 {
     $I->wantTo('fail when the status code is not set');
     $request = new Request();
     $request->setUrl(new Condition('isEqualTo', '/the/request/url'));
     $response = (new Response())->setStatusCode(null);
     $expectation = new Expectation();
     $expectation->setRequest($request)->setResponse($response);
     $I->haveHttpHeader('Content-Type', 'application/json');
     $I->sendPOST('/__phiremock/expectations', $expectation);
     $I->seeResponseCodeIs(201);
     $I->sendGET('/__phiremock/expectations');
     $I->seeResponseCodeIs(200);
     $I->seeResponseIsJson();
     $I->seeResponseEquals('[{"scenarioName":null,"scenarioStateIs":null,"newScenarioState":null,' . '"request":{"method":null,"url":{"isEqualTo":"\\/the\\/request\\/url"},"body":null,"headers":null},' . '"response":{"statusCode":200,"body":null,"headers":null,"delayMillis":null},' . '"proxyTo":null,"priority":0}]');
 }
开发者ID:mcustiel,项目名称:phiremock,代码行数:16,代码来源:StatusCodeSpecificationCest.php

示例5: returnCreatedExpectationTest

 public function returnCreatedExpectationTest(AcceptanceTester $I)
 {
     $request = new Request();
     $urlCondition = new Condition('isEqualTo', '/the/request/url');
     $request->setUrl($urlCondition);
     $response = new Response();
     $response->setStatusCode(201);
     $expectation = new Expectation();
     $expectation->setRequest($request)->setResponse($response);
     $I->haveHttpHeader('Content-Type', 'application/json');
     $I->sendPOST('/__phiremock/expectations', $expectation);
     $I->sendGET('/__phiremock/expectations');
     $I->seeResponseCodeIs('200');
     $I->seeResponseIsJson();
     $I->seeResponseEquals('[{"scenarioName":null,"scenarioStateIs":null,"newScenarioState":null,' . '"request":{"method":null,"url":{"isEqualTo":"\\/the\\/request\\/url"},"body":null,"headers":null},' . '"response":{"statusCode":201,"body":null,"headers":null,"delayMillis":null},' . '"proxyTo":null,"priority":0}]');
 }
开发者ID:mcustiel,项目名称:phiremock,代码行数:16,代码来源:ExpectationListCest.php

示例6: mockRequestWithDelayTest

 public function mockRequestWithDelayTest(AcceptanceTester $I)
 {
     $I->wantTo('mock a request with delay');
     $request = new Request();
     $request->setUrl(new Condition('isEqualTo', '/the/request/url'))->setMethod('GET');
     $response = new Response();
     $response->setDelayMillis(2000);
     $expectation = new Expectation();
     $expectation->setRequest($request)->setResponse($response);
     $I->haveHttpHeader('Content-Type', 'application/json');
     $I->sendPOST('/__phiremock/expectations', $expectation);
     $I->seeResponseCodeIs(201);
     $start = microtime(true);
     $I->sendGET('/the/request/url');
     $I->seeResponseCodeIs(200);
     $I->assertGreaterThan(2000, (microtime(true) - $start) * 1000);
 }
开发者ID:mcustiel,项目名称:phiremock,代码行数:17,代码来源:DelaySpecificationCest.php

示例7: responseExpectedWhenSeveralHeadersMatchesTest

 public function responseExpectedWhenSeveralHeadersMatchesTest(AcceptanceTester $I)
 {
     $I->wantTo('see if mocking based in several request headers works');
     $request = new Request();
     $request->setHeaders(['Content-type' => new Condition('isEqualTo', 'application/x-www-form-urlencoded'), 'X-Potato' => new Condition('matches', '/.*tomato.*/'), 'X-Tomato' => new Condition('isSameString', 'PoTaTo')]);
     $response = new Response();
     $response->setBody('Found');
     $expectation = new Expectation();
     $expectation->setRequest($request)->setResponse($response);
     $I->haveHttpHeader('Content-Type', 'application/json');
     $I->sendPOST('/__phiremock/expectations', $expectation);
     $I->seeResponseCodeIs(201);
     $I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
     $I->sendGET('/dontcare');
     $I->seeResponseCodeIs(404);
     $I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
     $I->haveHttpHeader('X-potato', 'a-tomato-0');
     $I->haveHttpHeader('X-tomato', 'potato');
     $I->sendGET('/dontcare');
     $I->seeResponseEquals('Found');
 }
开发者ID:mcustiel,项目名称:phiremock,代码行数:21,代码来源:HeadersConditionsCest.php

示例8: responseExpectedWhenRequestBodyCaseInsensitiveEqualsTest

 public function responseExpectedWhenRequestBodyCaseInsensitiveEqualsTest(AcceptanceTester $I)
 {
     $I->wantTo('see if mocking based in request body case insensitive equality works');
     $request = new Request();
     $request->setBody(new Condition('isSameString', 'pOtAtO'));
     $response = new Response();
     $response->setBody('Found');
     $expectation = new Expectation();
     $expectation->setRequest($request)->setResponse($response);
     $I->haveHttpHeader('Content-Type', 'application/json');
     $I->sendPOST('/__phiremock/expectations', $expectation);
     $I->seeResponseCodeIs(201);
     $I->sendPOST('/dontcare', 'potato');
     $I->seeResponseCodeIs(200);
     $I->seeResponseEquals('Found');
 }
开发者ID:mcustiel,项目名称:phiremock,代码行数:16,代码来源:BodyConditionCest.php

示例9: fullUrlShouldBeEvaluated

 public function fullUrlShouldBeEvaluated(AcceptanceTester $I)
 {
     $expectation = PhiremockClient::on(A::postRequest()->andUrl(Is::equalTo('/potato/coconut/?tomato=123'))->andBody(Is::containing('This is the body')))->then(Respond::withStatusCode(202)->andBody('Tomato!')->andDelayInMillis(2500)->andHeader('X-Tomato', 'Potato-received'));
     $this->phiremock->createExpectation($expectation);
     $I->sendPOST('/potato/coconut/?tomato=123', '{"key": "This is the body"}');
     $I->seeResponseCodeIs(202);
     $I->seeResponseEquals('Tomato!');
     $I->seeHttpHeader('X-Tomato', 'Potato-received');
 }
开发者ID:mcustiel,项目名称:phiremock,代码行数:9,代码来源:ClientCest.php

示例10: failWhenInvalidMethodSpecifiedTest

 public function failWhenInvalidMethodSpecifiedTest(AcceptanceTester $I)
 {
     $I->wantTo('create a specification that checks url using matches');
     $request = new Request();
     $request->setMethod('potato');
     $response = new Response();
     $response->setStatusCode(201);
     $expectation = new Expectation();
     $expectation->setRequest($request)->setResponse($response);
     $I->haveHttpHeader('Content-Type', 'application/json');
     $I->sendPOST('/__phiremock/expectations', $expectation);
     $I->seeResponseCodeIs(500);
     $I->seeResponseIsJson();
     $I->seeResponseEquals('{"result" : "ERROR", "details" : {"request":"method: Field method, was set with invalid value: \'potato\'"}}');
 }
开发者ID:mcustiel,项目名称:phiremock,代码行数:15,代码来源:MethodConditionCest.php

示例11: AcceptanceTester

<?php

$I = new AcceptanceTester($scenario);
$I->wantTo('Test AUTH related functions');
$newAccount = array('password_confirm' => 'password01*', 'email' => 'bbarton@email.com', 'first_name' => 'billy', 'last_name' => 'barton', 'user_type' => 'Owner', 'gender' => 'Female', 'relationship' => 'Mother', 'user' => '', 'password' => 'password01*', 'number' => '123-456-7890', 'primary' => 1, 'phone_type' => 'Office');
// create a brand new account
$I->sendPOST('auth/create', $newAccount);
$I->seeResponseIsJson();
$I->seeResponseCodeIs(201);
$result = $I->grabDataFromResponseByJsonPath('$.status');
// load a particular employee
// $I->sendGet("/employees/{$newEmployeeID[0]}");
// $I->seeResponseCodeIs(200);
// $I->seeResponseIsJson();
// $I->seeResponseJsonMatchesJsonPath('$.employee[0].id');
// now remove an employee
// $I->sendDELETE('employees/' . $newEmployeeID[0]);
// $I->seeResponseCodeIs(204);
开发者ID:jking6884,项目名称:smores-api,代码行数:18,代码来源:AuthCept.php

示例12: creationWithAllOptionsFilledTest

 public function creationWithAllOptionsFilledTest(AcceptanceTester $I)
 {
     $I->wantTo('create an expectation with all possible option filled');
     $request = (new Request())->setUrl(new Condition('isEqualTo', '/the/request/url'))->setBody(new Condition('isEqualTo', 'the body'))->setMethod('get')->setHeaders(['Content-Type' => new Condition('matches', '/json/'), 'Accepts' => new Condition('isEqualTo', 'application/json'), 'X-Some-Random-Header' => new Condition('isEqualTo', 'random value')]);
     $response = (new Response())->setStatusCode(201)->setBody('Response body')->setDelayMillis(5000)->setHeaders(['X-Special-Header' => 'potato', 'Location' => 'href://potato.tmt']);
     $expectation = (new Expectation())->setRequest($request)->setResponse($response)->setScenarioName('potato')->setScenarioStateIs('tomato')->setNewScenarioState('banana')->setPriority(3);
     $I->haveHttpHeader('Content-Type', 'application/json');
     $I->sendPOST('/__phiremock/expectations', $expectation);
     $I->sendGET('/__phiremock/expectations');
     $I->seeResponseCodeIs('200');
     $I->seeResponseIsJson();
     $I->seeResponseEquals('[{"scenarioName":"potato","scenarioStateIs":"tomato","newScenarioState":"banana",' . '"request":{' . '"method":"get","url":{"isEqualTo":"\\/the\\/request\\/url"},' . '"body":{"isEqualTo":"the body"},' . '"headers":{' . '"Content-Type":{"matches":"\\/json\\/"},' . '"Accepts":{"isEqualTo":"application\\/json"},' . '"X-Some-Random-Header":{"isEqualTo":"random value"}}},' . '"response":{' . '"statusCode":201,"body":"Response body","headers":{' . '"X-Special-Header":"potato",' . '"Location":"href:\\/\\/potato.tmt"},' . '"delayMillis":5000},' . '"proxyTo":null,"priority":3}]');
 }
开发者ID:mcustiel,项目名称:phiremock,代码行数:13,代码来源:ExpectationCreationCest.php

示例13: AcceptanceTester

$ur = 'users';
$tr = "{$ur}/\\{{$urx}}/token";
$ar = "{$ur}/\\{{$urx}}/articles";
$cr = "{$ar}/\\{{$arx}}/comments";
$app = Rest\App::instance();
$app->addResource($ur, Examples\User::class, $urx);
$app->addResource($tr, Examples\Token::class, $trx);
$app->addResource($ar, Examples\Article::class, $arx);
$app->addResource($cr, Examples\Comment::class, $crx);
$app->handle();
////////////////////////////////////////////////////////////////////////////////
$I = new AcceptanceTester($scenario);
$foo = 'foo';
$fooP = 'barbarbar';
$I->wantTo("Create create a user {$foo}");
$I->sendPOST('/users', ['username' => $foo, 'password' => 'bar']);
$I->seeResponseCodeIs(Rest\Response::BAD_REQUEST);
$I->seeHttpHeader('Status', '400 Password too short');
$I->sendPOST('/users', ['username' => $foo, 'password' => $fooP]);
$I->seeResponseCodeIs(201);
$I->seeHttpHeader('Location', "/users/{$foo}");
$I->seeResponseEquals(json_encode(['username' => $foo, 'password' => sha1($fooP)]));
$fooUrl = $I->grabHttpHeader('Location');
$I->wantTo('See the new user');
$I->sendGET($fooUrl);
$I->seeResponseCodeIs(200);
$I->seeResponseEquals(json_encode(['username' => $foo, 'login' => "/users/{$foo}/token", 'articles' => "/users/{$foo}/articles"]));
$rsp = json_decode($I->grabResponse());
$fooLogin = $rsp->login;
$fooArticles = $rsp->articles;
$I->wantTo("login with {$foo}");
开发者ID:ovide,项目名称:phest,代码行数:31,代码来源:ExamplesCept.php


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