Skip to content

Commit

Permalink
Merge pull request #43 from Kumatetsu/fix/142445
Browse files Browse the repository at this point in the history
[FIX#142445] Phiremock Le(o)gacy
  • Loading branch information
Guillaume DUBOST authored Jun 13, 2019
2 parents 630e0ca + 3838706 commit 7ceda26
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/HttpApiMockContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public function queLeProxyEffectueUneRequeteSurEtRenvoieStatusHTTPAvecLImageCont
public function queLeProxyEffectueUneRequeteSurAvecLeCorpsEtRenvoieLeStatusHTTP($proxy_name, $method, $url, $req_body, $status_code, $body = null)
{
$response = self::prepareMockResponse($status_code, $body);
$req_body = self::prepareReqBody($req_body);

$method_name = strtolower($method) . 'Request';

Expand All @@ -121,6 +122,16 @@ public function queLeProxyEffectueUneRequeteSurAvecLeCorpsEtRenvoieLeStatusHTTP(
self::$phiremock->createExpectation($expectation);
}

private function prepareReqBody($req_body) {
$body = trim(file_get_contents($this->requests_path . $req_body));

if (!$body) {
throw new \Exception("File not found : {$this->requests_path}${body}");
}

return $body;
}

private function prepareMockResponse($status_code, $body)
{
$response = \Mcustiel\Phiremock\Client\Utils\Respond::withStatusCode(intval($status_code))->andHeader('Content-Type', 'application/json');
Expand Down

0 comments on commit 7ceda26

Please sign in to comment.