Ejemplo n.º 1
0
 public function testApply()
 {
     $stateKey = 'sk';
     $this->registry->expects($this->once())->method('registry')->with($this->equalTo('current_category'))->will($this->returnValue($this->category));
     $this->stateKeyGenerator->expects($this->once())->method('toString')->with($this->equalTo($this->category))->will($this->returnValue($stateKey));
     $this->state->expects($this->any())->method('getFilters')->will($this->returnValue([$this->filter]));
     $this->filter->expects($this->once())->method('getFilter')->will($this->returnValue($this->abstractFilter));
     $this->filter->expects($this->once())->method('getValueString')->will($this->returnValue('t'));
     $this->abstractFilter->expects($this->once())->method('getRequestVar')->will($this->returnValue('t'));
     $result = $this->model->apply();
     $this->assertInstanceOf('\\Magento\\Catalog\\Model\\Layer', $result);
 }
Ejemplo n.º 2
0
 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);
 }