From 98c151eff3501f6dba18c90b931964973d784bc7 Mon Sep 17 00:00:00 2001 From: Mariano Custiel Date: Mon, 22 Jan 2018 20:15:52 +0100 Subject: [PATCH] Added tests to check big responses and several requests created in one cest --- ...parkles - 12543.mp4 => Sparkles-12543.mp4} | Bin tests/tests/acceptance/BinaryContentCest.php | 6 +-- tests/tests/acceptance/ClientCest.php | 47 ++++++++++++++++++ 3 files changed, 50 insertions(+), 3 deletions(-) rename tests/tests/_data/fixtures/{Sparkles - 12543.mp4 => Sparkles-12543.mp4} (100%) diff --git a/tests/tests/_data/fixtures/Sparkles - 12543.mp4 b/tests/tests/_data/fixtures/Sparkles-12543.mp4 similarity index 100% rename from tests/tests/_data/fixtures/Sparkles - 12543.mp4 rename to tests/tests/_data/fixtures/Sparkles-12543.mp4 diff --git a/tests/tests/acceptance/BinaryContentCest.php b/tests/tests/acceptance/BinaryContentCest.php index 25f06b7..ce318cb 100644 --- a/tests/tests/acceptance/BinaryContentCest.php +++ b/tests/tests/acceptance/BinaryContentCest.php @@ -32,11 +32,11 @@ public function shouldCreateAnExpectationWithBinaryResponseTest(AcceptanceTester $request->setMethod('get'); $request->setUrl(new Condition('isEqualTo', '/show-me-the-image')); - $responseContents = file_get_contents(Configuration::dataDir() . '/fixtures/number-1943293_640.jpg'); + $responseContents = file_get_contents(Configuration::dataDir() . '/fixtures/Sparkles-12543.mp4'); $response = new Response(); $response->setStatusCode(200); - $response->setHeaders(['Content-Type' => 'image/jpeg', 'Content-Encoding' => 'base64']); + $response->setHeaders(['Content-Type' => 'video/mp4', 'Content-Encoding' => 'base64']); $response->setBody('phiremock.base64:' . base64_encode($responseContents)); $expectation->setRequest($request)->setResponse($response); @@ -44,7 +44,7 @@ public function shouldCreateAnExpectationWithBinaryResponseTest(AcceptanceTester $I->sendGET('/show-me-the-image'); $I->seeResponseCodeIs(200); - $I->seeHttpHeader('Content-Type', 'image/jpeg'); + $I->seeHttpHeader('Content-Type', 'video/mp4'); $responseBody = $I->grabResponse(); $I->assertEquals($responseContents, $responseBody); } diff --git a/tests/tests/acceptance/ClientCest.php b/tests/tests/acceptance/ClientCest.php index 32c3bab..b22b5e6 100644 --- a/tests/tests/acceptance/ClientCest.php +++ b/tests/tests/acceptance/ClientCest.php @@ -252,4 +252,51 @@ public function shortcutShouldWorkAsExpected(AcceptanceTester $I) $I->seeResponseCodeIs(200); $I->seeResponseEquals('Everything worked as expected'); } + + public function severalExpectationsAddedInOneCestTest(AcceptanceTester $I) + { + $expectation = new Expectation(); + $request = new Request(); + $request->setMethod('get'); + $request->setUrl(new Condition('isEqualTo', '/potato')); + $response = new Response(); + $response->setStatusCode(201); + $response->setBody('Tomato!'); + $expectation->setRequest($request)->setResponse($response); + $this->phiremock->createExpectation($expectation); + + $expectation = new Expectation(); + $request = new Request(); + $request->setMethod('post'); + $request->setUrl(new Condition('isEqualTo', '/tomato')); + $response = new Response(); + $response->setStatusCode(201); + $response->setBody('Potato!'); + $expectation->setRequest($request)->setResponse($response); + $this->phiremock->createExpectation($expectation); + + $expectation = new Expectation(); + $request = new Request(); + $request->setMethod('get'); + $request->setUrl(new Condition('isEqualTo', '/coconut')); + $response = new Response(); + $response->setStatusCode(201); + $response->setBody('Coconut!'); + $expectation->setRequest($request)->setResponse($response); + $this->phiremock->createExpectation($expectation); + + $expectation = new Expectation(); + $request = new Request(); + $request->setMethod('get'); + $request->setUrl(new Condition('isEqualTo', '/banana')); + $response = new Response(); + $response->setStatusCode(201); + $response->setBody('Banana!'); + $expectation->setRequest($request)->setResponse($response); + $this->phiremock->createExpectation($expectation); + + $expectations = $this->phiremock->listExpectations(); + + $I->assertCount(4, $expectations); + } }