Exemplo n.º 1
0
 /**
  * @depends testApply
  */
 public function testGetItemsWithApply()
 {
     $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     $request = $objectManager->get('Magento\\TestFramework\\Request');
     $request->setParam('attribute', $this->_attributeOptionId);
     $this->_model->apply($request);
     $items = $this->_model->getItems();
     $this->assertInternalType('array', $items);
     $this->assertEmpty($items);
 }
 public function testGetItemsWithApply()
 {
     $attributeCode = 'attributeCode';
     $attributeValue = 'attributeValue';
     $attributeLabel = 'attributeLabel';
     $this->attribute->expects($this->exactly(2))->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->fulltextCollection->expects($this->once())->method('addFieldToFilter')->with($attributeCode, $attributeValue)->will($this->returnSelf());
     $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);
 }