protected function validateResponseOrThrowException(Expectation $expectation, LoggerInterface $logger) { if ($this->responseIsInvalid($expectation->getResponse())) { $logger->error('Invalid response specified in expectation'); throw new \RuntimeException('Invalid response specified in expectation'); } }
private function getResponseWithBody(Expectation $expectation, ResponseInterface $httpResponse, ServerRequestInterface $httpRequest) { $responseBody = $expectation->getResponse()->getBody(); if ($responseBody) { $responseBody = $this->fillWithUrlMatches($expectation, $httpRequest, $responseBody); $responseBody = $this->fillWithBodyMatches($expectation, $httpRequest, $responseBody); $httpResponse = $httpResponse->withBody(new StringStream($responseBody)); } return $httpResponse; }
public function createResponse(Expectation $expectation, TransactionData $transactionData) { $responseConfig = $expectation->getResponse(); $httpResponse = $transactionData->getResponse(); $httpResponse = $this->getResponseWithBody($responseConfig, $httpResponse); $httpResponse = $this->getResponseWithStatusCode($responseConfig, $httpResponse); $httpResponse = $this->getResponseWithHeaders($responseConfig, $httpResponse); $this->processDelay($responseConfig); return $httpResponse; }