public function testGetOrderItemFromFactory() { $orderItemId = 1; $orderItemMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Item')->disableOriginalConstructor()->getMock(); $orderItemMock->expects($this->once())->method('load')->with($orderItemId)->willReturnSelf(); $this->orderItemFactoryMock->expects($this->once())->method('create')->willReturn($orderItemMock); $this->item->setData(CreditmemoItemInterface::ORDER_ITEM_ID, $orderItemId); $result = $this->item->getOrderItem(); $this->assertInstanceOf('Magento\\Sales\\Model\\Order\\Item', $result); }
/** * Whether to show 'Return to stock' checkbox for item * * @param Item $item * @return bool */ public function canReturnItemToStock($item = null) { if (null !== $item) { if (!$item->hasCanReturnToStock()) { $productId = $item->getOrderItem()->getProductId(); if ($productId && $this->stockItemService->getManageStock($productId)) { $item->setCanReturnToStock(true); } else { $item->setCanReturnToStock(false); } } $canReturnToStock = $item->getCanReturnToStock(); } else { $canReturnToStock = $this->_scopeConfig->getValue(\Magento\CatalogInventory\Model\Stock\Item::XML_PATH_CAN_SUBTRACT, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); } return $canReturnToStock; }
/** * Whether to show 'Return to stock' checkbox for item * * @param Item $item * @return bool */ public function canReturnItemToStock($item = null) { if (null !== $item) { if (!$item->hasCanReturnToStock()) { $stockItem = $this->stockRegistry->getStockItem($item->getOrderItem()->getProductId(), $item->getOrderItem()->getStore()->getWebsiteId()); $item->setCanReturnToStock($stockItem->getManageStock()); } return $item->getCanReturnToStock(); } return $this->canReturnToStock(); }