예제 #1
0
 public function testItCanGetWillReturnErrorResponseBecauseOfInvalidParams()
 {
     $this->fields = new Fields();
     $this->fields->addField('superhero', 'power');
     $this->resource = new GetResource($this->serializer, $this->fields, $this->included);
     $response = $this->resource->get(10, Post::class, $this->findOneCallable);
     $this->assertInstanceOf(Response::class, $response);
     $this->assertEquals(400, $response->getStatusCode());
 }
 /**
  * Get single resource.
  *
  * @param $id
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function show($id)
 {
     $apiRequest = RequestFactory::create();
     $resource = new GetResource($this->serializer, $apiRequest->getFields(), $apiRequest->getIncludedRelationships());
     $find = $this->findResourceCallable($id);
     return $this->addHeaders($resource->get($id, get_class($this->getDataModel()), $find));
 }
 /**
  * @param Request $request
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function getAction(Request $request)
 {
     $find = $this->findResourceCallable($request);
     $resource = new GetResource($this->serializer);
     return $this->addHeaders($resource->get($request->id, get_class($this->getDataModel()), $find));
 }