Ejemplo n.º 1
0
 protected function setUp()
 {
     $this->objectHelper = new \Magento\TestFramework\Helper\ObjectManager($this);
     $this->stockItemService = $this->getMockBuilder('Magento\\CatalogInventory\\Service\\V1\\StockItemService')->disableOriginalConstructor()->getMock();
     $this->model = $this->objectHelper->getObject('Magento\\Catalog\\Model\\Product\\Attribute\\Backend\\Stock', array('stockItemService' => $this->stockItemService));
     $attribute = $this->getMock('Magento\\Framework\\Object', array('getAttributeCode'));
     $attribute->expects($this->atLeastOnce())->method('getAttributeCode')->will($this->returnValue(self::ATTRIBUTE_NAME));
     $this->model->setAttribute($attribute);
 }
Ejemplo n.º 2
0
 protected function setUp()
 {
     $this->objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->stockRegistry = $this->getMockBuilder('Magento\\CatalogInventory\\Model\\StockRegistry')->disableOriginalConstructor()->setMethods(['getStockItem', '__wakeup'])->getMock();
     $this->stockItemMock = $this->getMock('Magento\\CatalogInventory\\Model\\Stock\\Item', ['getIsInStock', 'getQty', '__wakeup'], [], '', false);
     $this->stockRegistry->expects($this->any())->method('getStockItem')->will($this->returnValue($this->stockItemMock));
     $this->model = $this->objectHelper->getObject('Magento\\Catalog\\Model\\Product\\Attribute\\Backend\\Stock', ['stockRegistry' => $this->stockRegistry]);
     $attribute = $this->getMock('Magento\\Framework\\DataObject', ['getAttributeCode']);
     $attribute->expects($this->atLeastOnce())->method('getAttributeCode')->will($this->returnValue(self::ATTRIBUTE_NAME));
     $this->model->setAttribute($attribute);
 }