public function testApply() { $this->assertEmpty($this->_model->getLayer()->getState()->getFilters()); $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $request = $objectManager->get('Magento\\TestFramework\\Request'); $request->setParam('attribute', $this->_attributeOptionId); $this->_model->apply($request); $this->assertNotEmpty($this->_model->getLayer()->getState()->getFilters()); }
public function testGetItems() { $attributeCode = 'attributeCode'; $attributeValue = 'attributeValue'; $attributeLabel = 'attributeLabel'; $this->attribute->expects($this->once())->method('getAttributeCode')->will($this->returnValue($attributeCode)); $this->target->setAttributeModel($this->attribute); $this->request->expects($this->once())->method('getParam')->with($attributeCode)->will($this->returnValue($attributeValue)); $this->frontend->expects($this->once())->method('getOption')->with($attributeValue)->will($this->returnValue($attributeLabel)); $filterItem = $this->createFilterItem(0, $attributeLabel, $attributeValue, 0); $this->state->expects($this->once())->method('addFilter')->with($filterItem)->will($this->returnSelf()); $expectedFilterItems = []; $result = $this->target->apply($this->request)->getItems(); $this->assertEquals($expectedFilterItems, $result); }