Exemplo n.º 1
0
 /**
  * @inheritdoc
  */
 public function getRandomIdsForLastEntityNotInPivot($uri, $take)
 {
     $entities = $this->uriParser->entities($uri);
     $idEntities = $this->uriParser->idEntities($uri);
     // ids for the where clause on the pivot table
     $ids = $this->uriParser->ids($uri);
     return $this->idRetriever->getRandomIdsNotInPivot($entities, $idEntities, $ids, $take);
 }
Exemplo n.º 2
0
 function it_gets_random_ids_for_the_last_entity_not_in_pivot(Parser $parser, \LaraPackage\RandomId\Contracts\Retriever $idRetriever)
 {
     $resource = '/sites/1/products/2/images';
     $entities = ['sites', 'products', 'images'];
     $idEntities = ['sites', 'products'];
     $ids = [1, 2];
     $randomIdNotInPivot = ['id' => 56];
     $count = 2;
     $parser->entities($resource)->shouldBeCalled()->willReturn($entities);
     $parser->idEntities($resource)->shouldBeCalled()->willReturn($idEntities);
     $parser->ids($resource)->shouldBeCalled()->willReturn($ids);
     $idRetriever->getRandomIdsNotInPivot($entities, $idEntities, $ids, $count)->shouldBeCalled()->willReturn($randomIdNotInPivot);
     $this->getRandomIdsForLastEntityNotInPivot($resource, $count)->shouldReturn($randomIdNotInPivot);
 }
Exemplo n.º 3
0
 /**
  * @inheritdoc
  */
 public function ids()
 {
     return $this->parser->ids($this->uri());
 }
Exemplo n.º 4
0
 function it_returns_item_ids(Request $request, Parser $parser)
 {
     $uri = '/sites/1/products/2/images/1,4,5';
     $ids = [1, 2, [1, 4, 5]];
     $result = [1, 4, 5];
     $request->getRequestUri()->shouldBeCalled()->willReturn($uri);
     $parser->ids($uri)->shouldBeCalled()->willReturn($ids);
     $this->itemIds()->shouldReturn($result);
 }