示例#1
0
 function it_gets_random_ids_from_a_table(TableFetcher $tableFetcher)
 {
     $take = 4;
     $randomIds = [3, 6, 7, 2];
     $table = 'images';
     $tableFetcher->getRandomIds($table, $take)->shouldBeCalled()->willReturn($randomIds);
     $this->getRandomIdsFromTable($table, $take)->shouldReturn($randomIds);
 }
示例#2
0
 /**
  * @inheritdoc
  */
 public function getRandomIdsNotInPivot(array $entities, array $idEntities, array $ids, $count)
 {
     // the table to retrieve ids from
     $table = last($entities);
     $pivotTable = $this->tableHelper->getTable($entities);
     $pivotColumn = $this->tableHelper->getLastEntityAsIdColumnName($entities);
     $columnNames = $this->tableHelper->getIdColumnNames($entities, $idEntities);
     if (count($entities) === count($ids)) {
         array_pop($ids);
     }
     $pivotWhereJoinColumns = array_combine($columnNames, $ids);
     return $this->db->getRandomIdsFromTableWhereNotInPivot($table, $pivotTable, $pivotColumn, $count, $pivotWhereJoinColumns);
 }