Пример #1
0
 /**
  * @param string $url
  * @param string $targetClass
  *
  * @return BaseResponse
  *
  * @throws RuntimeException
  */
 protected function doGetObjectsRequest(string $url, string $targetClass) : BaseResponse
 {
     // TODO Do something on response error codes
     $rawResponse = $this->client->get($url);
     // TODO Catch error on malformatted json
     $deserializedResponse = $this->serializer->deserialize($rawResponse->getContent(), $targetClass, 'json');
     return $deserializedResponse;
 }
Пример #2
0
 /**
  * @test
  * @group  small
  * @covers ::get
  * @covers ::<private>
  *
  * @expectedException \InvalidArgumentException
  */
 public function wrongUrl()
 {
     $response = $this->restClient->get('noUrl');
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $response);
     $this->assertNotEquals(200, $response->getStatusCode());
 }
Пример #3
0
 /**
  * @test
  * @group  small
  * @covers ::get
  * @covers ::<private>
  */
 public function get()
 {
     $response = new Response('content');
     $this->curl->expects($this->once())->method('sendRequest')->with($this->equalTo($this->mockControllerUrl), $this->equalTo('GET'), $this->equalTo(array()))->will($this->returnValue($response));
     $this->assertSame($response, $this->restClient->get($this->mockControllerUrl));
 }