示例#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);
 }
示例#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);
 }
示例#3
0
 /**
  * @inheritdoc
  */
 public function ids()
 {
     return $this->parser->ids($this->uri());
 }
示例#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);
 }