Ejemplo n.º 1
0
 /**
  * @dataProvider pricesSegmentationDataProvider
  */
 public function testPricesSegmentation($categoryId, $intervalsNumber, $intervalItems)
 {
     $this->_layer->setCurrentCategory($categoryId);
     $collection = $this->_layer->getProductCollection();
     $memoryUsedBefore = memory_get_usage();
     $this->_model->setPricesModel($this->_filter)->setStatistics($collection->getMinPrice(), $collection->getMaxPrice(), $collection->getPriceStandardDeviation(), $collection->getSize());
     if (!is_null($intervalsNumber)) {
         $this->assertEquals($intervalsNumber, $this->_model->getIntervalsNumber());
     }
     $items = $this->_model->calculateSeparators();
     $this->assertEquals(array_keys($intervalItems), array_keys($items));
     for ($i = 0; $i < count($intervalItems); ++$i) {
         $this->assertInternalType('array', $items[$i]);
         $this->assertEquals($intervalItems[$i]['from'], $items[$i]['from']);
         $this->assertEquals($intervalItems[$i]['to'], $items[$i]['to']);
         $this->assertEquals($intervalItems[$i]['count'], $items[$i]['count']);
     }
     // Algorythm should use less than 10M
     $this->assertLessThan(10 * 1024 * 1024, memory_get_usage() - $memoryUsedBefore);
 }
Ejemplo n.º 2
0
 /**
  * @expectedException \Magento\Framework\Exception\LocalizedException
  * @expectedExceptionMessage Please correct the category.
  */
 public function testSetCurrentCategoryNotFoundException()
 {
     $this->category->expects($this->once())->method('getId')->will($this->returnValue(null));
     $this->model->setCurrentCategory($this->category);
 }