Exemplo n.º 1
0
 public function __construct(RequestBuilder $requestBuilder)
 {
     $this->expectation = $requestBuilder->build();
 }
Exemplo n.º 2
0
 /**
  * Counts the amount of times a request was executed in phiremock.
  *
  * @param \Mcustiel\Phiremock\Client\Utils\RequestBuilder $requestBuilder
  *
  * @return int
  */
 public function countExecutions(RequestBuilder $requestBuilder)
 {
     $expectation = $requestBuilder->build();
     $expectation->setResponse(new Response());
     $uri = $this->createBaseUri()->withPath(self::API_EXECUTIONS_URL);
     $request = (new PsrRequest())->withUri($uri)->withMethod('post')->withHeader('Content-Type', 'application/json')->withBody(new StringStream(json_encode($expectation)));
     $response = $this->connection->send($request);
     if ($response->getStatusCode() === 200) {
         $json = json_decode($response->getBody()->__toString());
         return $json->count;
     }
     $this->checkErrorResponse($response);
 }