diff --git a/src/HttpApiMockContext.php b/src/HttpApiMockContext.php index de9b643..2f53723 100644 --- a/src/HttpApiMockContext.php +++ b/src/HttpApiMockContext.php @@ -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'; @@ -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');