Ejemplo n.º 1
0
 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');
 }
Ejemplo n.º 2
0
 public function createAnExpectationWithProxyToTest(AcceptanceTester $I)
 {
     $expectation = PhiremockClient::on(A::postRequest()->andUrl(Is::equalTo('/potato'))->andHeader('X-Potato', Is::sameStringAs('bAnaNa'))->andScenarioState('PotatoScenario', 'Scenario.START')->andBody(Is::equalTo('{"key": "This is the body"}')))->proxyTo('https://es.wikipedia.org/wiki/Proxy');
     $this->phiremock->createExpectation($expectation);
     $I->sendGET('/__phiremock/expectations');
     $I->seeResponseCodeIs('200');
     $I->seeResponseIsJson();
     $I->seeResponseEquals('[{"scenarioName":"PotatoScenario","scenarioStateIs":"Scenario.START",' . '"newScenarioState":null,"request":{"method":"post","url":{"isEqualTo":"\\/potato"},' . '"body":{"isEqualTo":"{\\"key\\": \\"This is the body\\"}"},"headers":{"X-Potato":' . '{"isSameString":"bAnaNa"}}},"response":{"statusCode":200,"body":null,"headers":' . 'null,"delayMillis":null},' . '"proxyTo":"https:\\/\\/es.wikipedia.org\\/wiki\\/Proxy","priority":0}]');
 }
Ejemplo n.º 3
0
 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');
 }