Пример #1
0
 /**
  * @dataProvider getFormatAndBody
  */
 public function testCreateFindOneRequest($format, $expectedBody, $parameters, $requirements, $expectedQueryString)
 {
     $this->factory->setFormat($format);
     $this->urlGenerator->expects($this->once())->method('getFindOneUrl')->with('blogs', 42, $parameters, $requirements)->will($this->returnValue('/blogs/42' . $expectedQueryString));
     $request = $this->factory->createFindOneRequest(Blog::class, 42, $parameters);
     $this->assertEquals('GET', $request->getMethod());
     $this->assertEquals('application/' . $format, $request->getHeaderLine('Content-Type'));
     $this->assertEquals('/blogs/42' . $expectedQueryString, $request->getUri());
     $this->assertEquals('', (string) $request->getBody());
 }
Пример #2
0
 /**
  * @param $id
  * @param array $parameters
  * @param array $requirements
  *
  * @return object
  */
 public function findOneById($id, array $parameters = [], array $requirements = [])
 {
     $request = $this->requestFactory->createFindOneRequest($this->class, $id, $parameters, $requirements);
     $response = $this->client->send($request);
     return $this->responseMapper->map($response, $this->class, 'json');
 }