/** * @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); }
public function testPrepareProductCollection() { $this->registry->expects($this->once())->method('registry')->with($this->equalTo('current_category'))->will($this->returnValue($this->category)); $this->collectionFilter->expects($this->once())->method('filter')->with($this->equalTo($this->collection), $this->equalTo($this->category)); $result = $this->model->prepareProductCollection($this->collection); $this->assertInstanceOf('\\Magento\\Catalog\\Model\\Layer', $result); }
/** * 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; }