Example #1
0
 public function testGetRangeItemCounts()
 {
     $range = 10;
     $count = [50, 20, 20];
     $this->resource->expects($this->once())->method('getCount')->with($range)->will($this->returnValue($count));
     $this->assertSame($count, $this->target->getRangeItemCounts($range));
 }
Example #2
0
 /**
  * @return number
  */
 private function getRange()
 {
     $maxPrice = $this->getMaxPriceInt();
     $index = 1;
     do {
         $range = pow(10, strlen(floor($maxPrice)) - $index);
         $items = $this->resource->getCount($range);
         $index++;
     } while ($range > self::MIN_RANGE_POWER && count($items) < 2);
     return $range;
 }
Example #3
0
 /**
  * Get information about products count in range
  *
  * @param   int $range
  * @return  int
  */
 public function getRangeItemCounts($range)
 {
     $items = array_key_exists($range, $this->rangeItemCounts) ? $this->rangeItemCounts[$range] : null;
     if ($items === null) {
         $items = $this->resource->getCount($range);
         // checking max number of intervals
         $i = 0;
         $lastIndex = null;
         $maxIntervalsNumber = $this->getRangeMaxIntervalsValue();
         $calculation = $this->getRangeCalculationValue();
         foreach ($items as $k => $v) {
             ++$i;
             if ($calculation == self::RANGE_CALCULATION_MANUAL && $i > 1 && $i > $maxIntervalsNumber) {
                 $items[$lastIndex] += $v;
                 unset($items[$k]);
             } else {
                 $lastIndex = $k;
             }
         }
         $this->rangeItemCounts[$range] = $items;
     }
     return $items;
 }
Example #4
0
 /**
  * {@inheritdoc}
  */
 public function loadNext($data, $rightIndex, $upper = null)
 {
     $prices = $this->resource->loadNextPrices($data, $rightIndex, $upper);
     return $this->arrayValuesToFloat($prices);
 }