Created
August 17, 2017 22:59
-
-
Save vrann/d917fabfecc8991ebe13cb15cc4345a0 to your computer and use it in GitHub Desktop.
Integration Test to expose an issue with the multiple save of the Quote with the Configurable product
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @magentoDataFixture Magento/ConfigurableProduct/_files/quote_with_configurable_product.php | |
*/ | |
public function testSaveQuoteMultipleTimes() | |
{ | |
/** @var \Magento\CatalogInventory\Model\Stock\Item $stockItem */ | |
$stockItem = Bootstrap::getObjectManager()->create(\Magento\CatalogInventory\Model\Stock\Item::class); | |
$stockItem->load(10, 'product_id'); | |
if (!$stockItem->getProductId()) { | |
$stockItem->setProductId(1); | |
} | |
$stockItem->setUseConfigManageStock(1); | |
$stockItem->setQty(1); | |
$stockItem->setIsQtyDecimal(0); | |
$stockItem->setIsInStock(1); | |
$stockItem->save(); | |
/** @var \Magento\CatalogInventory\Model\StockRegistryStorage $stockRegistry */ | |
$stockRegistry = Bootstrap::getObjectManager()->get(\Magento\CatalogInventory\Model\StockRegistryStorage::class); | |
$stockRegistry->removeStockStatus(10); | |
$stockRegistry->removeStockItem(10); | |
/** @var \Magento\Quote\Model\Quote $quote */ | |
$quoteObj = Bootstrap::getObjectManager()->create(\Magento\Quote\Model\Quote::class); | |
$quoteObj->load('test_cart_with_configurable', 'reserved_order_id'); | |
/** @var \Magento\Quote\Api\CartRepositoryInterface $mageQuoteRepository */ | |
$mageQuoteRepository = Bootstrap::getObjectManager()->create(\Magento\Quote\Api\CartRepositoryInterface::class); | |
$quote = $mageQuoteRepository->get($quoteObj->getId()); | |
$mageQuoteRepository->save($quote); | |
$mageQuoteRepository->save($quote); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment