示例#1
0
 /**
  * @covers \Magento\Catalog\Model\Layer\Category\CollectionFilter::filter
  * @covers \Magento\Catalog\Model\Layer\Category\CollectionFilter::__construct
  */
 public function testFilter()
 {
     $collectionMock = $this->getMock('\\Magento\\Catalog\\Model\\Resource\\Product\\Collection', [], [], '', false);
     $categoryMock = $this->getMock('\\Magento\\Catalog\\Model\\Category', [], [], '', false);
     $categoryMock->expects($this->once())->method('getId');
     $this->catalogConfigMock->expects($this->once())->method('getProductAttributes');
     $this->visibilityMock->expects($this->once())->method('getVisibleInCatalogIds');
     $collectionMock->expects($this->once())->method('addAttributeToSelect')->will($this->returnValue($collectionMock));
     $collectionMock->expects($this->once())->method('addMinimalPrice')->will($this->returnValue($collectionMock));
     $collectionMock->expects($this->once())->method('addFinalPrice')->will($this->returnValue($collectionMock));
     $collectionMock->expects($this->once())->method('addTaxPercents')->will($this->returnValue($collectionMock));
     $collectionMock->expects($this->once())->method('addUrlRewrite')->will($this->returnValue($collectionMock));
     $collectionMock->expects($this->once())->method('setVisibility')->will($this->returnValue($collectionMock));
     $this->model->filter($collectionMock, $categoryMock);
 }
示例#2
0
 /**
  * Initialize product collection
  *
  * @param \Magento\Catalog\Model\Resource\Product\Collection $collection
  * @return \Magento\Catalog\Model\Layer
  */
 public function prepareProductCollection($collection)
 {
     $this->collectionFilter->filter($collection, $this->getCurrentCategory());
     return $this;
 }