Skip to content

Commit

Permalink
[FIX#142445] Leo je te retiens
Browse files Browse the repository at this point in the history
jtm quand mm <3
  • Loading branch information
Jean BILLAUD committed Jun 13, 2019
1 parent 991762d commit 3838706
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 3838706

Please sign in to comment.