protected function setUp() { $this->carrier = $this->getMock('Magento\\Shipping\\Model\\Carrier\\AbstractCarrier', [], [], '', false); $this->carrier->expects($this->any())->method('getConfigData')->will($this->returnCallback(function ($key) { $configData = ['max_package_weight' => 10]; return isset($configData[$key]) ? $configData[$key] : 0; })); $this->stockRegistry = $this->getMock('Magento\\CatalogInventory\\Model\\StockRegistry', [], [], '', false); $this->stockItemData = $this->getMock('Magento\\CatalogInventory\\Model\\Stock\\Item', [], [], '', false); $objectManagerHelper = new ObjectManagerHelper($this); $this->shipping = $objectManagerHelper->getObject('Magento\\Shipping\\Model\\Shipping', ['stockRegistry' => $this->stockRegistry]); }