Skip to content

Commit

Permalink
Added tests to check big responses and several requests created in on…
Browse files Browse the repository at this point in the history
…e cest
  • Loading branch information
mcustiel committed Jan 22, 2018
1 parent 69d85a5 commit 98c151e
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/tests/acceptance/BinaryContentCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ 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);
$this->phiremock->createExpectation($expectation);

$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);
}
Expand Down
47 changes: 47 additions & 0 deletions tests/tests/acceptance/ClientCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 98c151e

Please sign in to comment.