Ejemplo n.º 1
0
 public function testRespondWithItem()
 {
     $response = new Response($fractal = m::mock('League\\Fractal\\Manager'), $item = m::mock('Paxifi\\Support\\Response\\Item'), m::mock('Paxifi\\Support\\Response\\Collection'), m::mock('Paxifi\\Support\\Response\\Paginator'), m::mock('Paxifi\\Support\\Response\\Cursor'));
     $item->shouldReceive('setData')->andReturn('foo');
     $item->shouldReceive('setTransformer');
     $fractal->shouldReceive('toArray');
     $fractal->shouldReceive('createData')->with($item)->once()->andReturn($fractal);
     $response->withItem();
 }
Ejemplo n.º 2
0
 /**
  * Responds with single resource.
  *
  * @param mixed $data
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function respondWithItem($data)
 {
     $this->response->setTransformer($this->getTransformer())->setContent($data);
     return $this->respond($this->response->withItem());
 }