protected function setUp() { $this->_inventory = $this->getMock('Mage_CatalogInventory_Model_Stock_Item', array('getIsInStock', 'getQty', 'loadByProduct'), array(), '', false); $this->_model = $this->getMock('Mage_Catalog_Model_Product_Attribute_Backend_Stock', array('getAttribute'), array(array('inventory' => $this->_inventory))); $attribute = $this->getMock('Varien_Object', array('getAttributeCode')); $attribute->expects($this->atLeastOnce())->method('getAttributeCode')->will($this->returnValue(self::ATTRIBUTE_NAME)); $this->_model->expects($this->atLeastOnce())->method('getAttribute')->will($this->returnValue($attribute)); }