Ejemplo n.º 1
0
 /**
  * Add items to interval collection
  *
  * @param Collection $collection
  * @param string $from
  * @param string $to
  * @param string $periodType
  * @return void
  */
 public function prepareIntervalsCollection($collection, $from, $to, $periodType = self::REPORT_PERIOD_TYPE_DAY)
 {
     $intervals = $this->getIntervals($from, $to, $periodType);
     foreach ($intervals as $interval) {
         $item = $this->_itemFactory->create();
         $item->setPeriod($interval);
         $item->setIsEmpty();
         $collection->addItem($item);
     }
 }
Ejemplo n.º 2
0
 /**
  * @param string $from
  * @param string $to
  * @param string $period
  * @param array $results
  * @dataProvider intervalsDataProvider
  * @return void
  */
 public function testPrepareIntervalsCollection($from, $to, $period, $results)
 {
     $collection = $this->getMockBuilder('Magento\\Framework\\Data\\Collection')->disableOriginalConstructor()->setMethods(['addItem'])->getMock();
     $item = $this->getMockBuilder('Magento\\Reports\\Model\\Item')->disableOriginalConstructor()->setMethods(['setPeriod', 'setIsEmpty'])->getMock();
     $this->itemFactoryMock->expects($this->exactly(count($results)))->method('create')->willReturn($item);
     $item->expects($this->exactly(count($results)))->method('setIsEmpty');
     $collection->expects($this->exactly(count($results)))->method('addItem');
     foreach ($results as $key => $result) {
         $item->expects($this->at($key + $key))->method('setPeriod')->with($result);
     }
     $this->data->prepareIntervalsCollection($collection, $from, $to, $period);
 }