Exemple #1
0
 /**
  * @inheritdoc
  */
 public function cursor(\LaraPackage\Api\Contracts\Resource\Collection $cursor, \LaraPackage\Api\Contracts\Entity\Transformer\Transformer $transformer)
 {
     $resource = $this->fractalFactory->createCollection($cursor->getData(), $transformer);
     $fractalCursor = $this->fractalFactory->createCursor($cursor->getCurrent(), $cursor->getPrevious(), $cursor->getNext(), $cursor->getCount());
     $resource->setCursor($fractalCursor);
     $this->setPayload($resource);
     $this->removePrevCursor($payload);
 }
 function it_returns_an_empty_collection_for_no_results(\LaraPackage\Api\Contracts\Resource\Collection $cursor, Fractal\Pagination\Cursor $fractalCursor, FractalFactory $fractalFactory, \LaraPackage\Api\Contracts\Entity\Transformer\Transformer $transformer, Fractal\Resource\Collection $fractalCollection, Fractal\Manager $manager, Fractal\Scope $scope)
 {
     $expected = [];
     $cursorData = new \ArrayIterator($expected);
     $current = 0;
     $previous = 0;
     $next = 0;
     $count = 0;
     $fractalFactory->createCollection($cursorData, $transformer)->shouldBeCalled()->willReturn($fractalCollection);
     $fractalFactory->createCursor($current, $previous, $next, $count)->shouldBeCalled()->willReturn($fractalCursor);
     $this->setPayloadAssertions($fractalFactory, $fractalCollection, $manager, $scope, $cursorData);
     $fractalCollection->setCursor($fractalCursor)->shouldBeCalled();
     $cursor->getData()->shouldBeCalled()->willReturn($cursorData);
     $cursor->getCurrent()->shouldBeCalled()->willReturn($current);
     $cursor->getPrevious()->shouldBeCalled()->willReturn($previous);
     $cursor->getNext()->shouldBeCalled()->willReturn($next);
     $cursor->getCount()->shouldBeCalled()->willReturn($count);
     $this->cursor($cursor, $transformer);
     $this->getIterator()->getArrayCopy()->shouldReturn($expected);
 }