コード例 #1
0
 /**
  * @param $responseStr
  */
 protected function addResponse($responseStr)
 {
     $streamMock = $this->getMockBuilder(StreamInterface::class)->getMock();
     $streamMock->expects($this->once())->method('getContents')->willReturn($responseStr);
     $response = $this->getMockBuilder(ResponseInterface::class)->getMock();
     $response->expects($this->once())->method('getBody')->willReturn($streamMock);
     $this->mockClient->addResponse($response);
 }
コード例 #2
0
 /**
  * Get the client under test.
  *
  * @param ResponseInterface $response The response to return.
  * @param VenueFactory $factory       The venue factory.
  *
  * @return Client
  */
 private function getClient(ResponseInterface $response = null, VenueFactory $factory = null)
 {
     if ($response === null) {
         $response = $this->getMockResponse('');
     }
     if ($factory === null) {
         $factory = $this->getMockVenueFactory();
     }
     $httpClient = new MockHttpClient();
     $httpClient->addResponse($response);
     return new Client(new Configuration('3244few432', '423r234f234'), new HttpMethodsClient($httpClient, $this->getMockMessageFactory()), $factory);
 }