Beispiel #1
0
 protected function setUp()
 {
     $category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Model\\Category');
     $category->load(4);
     $layer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Model\\Layer\\Category', ['data' => ['current_category' => $category]]);
     /** @var $attribute \Magento\Catalog\Model\Entity\Attribute */
     $attribute = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Model\\Entity\\Attribute');
     $attribute->loadByCode('catalog_product', 'weight');
     $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\CatalogSearch\\Model\\Layer\\Filter\\Decimal', ['layer' => $layer]);
     $this->_model->setAttributeModel($attribute);
 }
 protected function setUp()
 {
     $this->request = $this->getMockBuilder('\\Magento\\Framework\\App\\RequestInterface')->disableOriginalConstructor()->setMethods(['getParam'])->getMockForAbstractClass();
     $this->layer = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Layer')->disableOriginalConstructor()->setMethods(['getState', 'getProductCollection'])->getMock();
     $this->filterItemFactory = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Layer\\Filter\\ItemFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->filterItem = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Layer\\Filter\\Item')->disableOriginalConstructor()->setMethods(['setFilter', 'setLabel', 'setValue', 'setCount'])->getMock();
     $this->filterItem->expects($this->any())->method($this->anything())->will($this->returnSelf());
     $this->filterItemFactory->expects($this->any())->method('create')->will($this->returnValue($this->filterItem));
     $this->fulltextCollection = $this->fulltextCollection = $this->getMockBuilder('\\Magento\\CatalogSearch\\Model\\ResourceModel\\Fulltext\\Collection')->disableOriginalConstructor()->getMock();
     $this->layer->expects($this->any())->method('getProductCollection')->will($this->returnValue($this->fulltextCollection));
     $filterDecimalFactory = $this->getMockBuilder('\\Magento\\Catalog\\Model\\ResourceModel\\Layer\\Filter\\DecimalFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $resource = $this->getMockBuilder('\\Magento\\Catalog\\Model\\ResourceModel\\Layer\\Filter\\Decimal')->disableOriginalConstructor()->setMethods([])->getMock();
     $filterDecimalFactory->expects($this->once())->method('create')->will($this->returnValue($resource));
     $this->attribute = $this->getMockBuilder('\\Magento\\Eav\\Model\\Entity\\Attribute')->disableOriginalConstructor()->setMethods(['getAttributeCode', 'getFrontend', 'getIsFilterable'])->getMock();
     $this->state = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Layer\\State')->disableOriginalConstructor()->setMethods(['addFilter'])->getMock();
     $this->layer->expects($this->any())->method('getState')->will($this->returnValue($this->state));
     $objectManagerHelper = new ObjectManagerHelper($this);
     $this->target = $objectManagerHelper->getObject('Magento\\CatalogSearch\\Model\\Layer\\Filter\\Decimal', ['filterItemFactory' => $this->filterItemFactory, 'layer' => $this->layer, 'filterDecimalFactory' => $filterDecimalFactory]);
     $this->target->setAttributeModel($this->attribute);
 }