Skip to content

Commit c9212f1

Browse files
committed
ACP2E-962: [Premier] Value of Maximum Qty Allowed in Shopping Cart is different when exported
- add test
1 parent 2417f88 commit c9212f1

File tree

1 file changed

+38
-0
lines changed
  • dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Export

1 file changed

+38
-0
lines changed

dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Export/ProductTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
use Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection as ProductAttributeCollection;
1313
use Magento\Catalog\Observer\SwitchPriceAttributeScopeOnConfigChange;
1414
use Magento\CatalogImportExport\Model\Export\Product\Type\Simple as SimpleProductType;
15+
use Magento\CatalogInventory\Api\StockConfigurationInterface;
16+
use Magento\CatalogInventory\Api\StockItemRepositoryInterface;
17+
use Magento\CatalogInventory\Model\Stock\Item;
1518
use Magento\Framework\App\Config\ReinitableConfigInterface;
1619

1720
/**
@@ -108,6 +111,41 @@ public function testExport(): void
108111
$this->assertEquals(1, $occurrencesCount);
109112
}
110113

114+
/**
115+
* Verify successful export of product with stock data with 'use config max sale quantity is enabled
116+
*
117+
* @magentoDataFixture /Magento/Catalog/_files/product_without_options_with_stock_data.php
118+
* @magentoDbIsolation enabled
119+
* @return void
120+
*/
121+
public function testExportWithStock(): void
122+
{
123+
$maxSaleQty = '19187';
124+
$minSaleQty = '179';
125+
/** @var StockItemRepositoryInterface $stockRepository */
126+
$stockRepository = $this->objectManager->get(StockItemRepositoryInterface::class);
127+
/** @var StockConfigurationInterface $stockConfiguration */
128+
$stockConfiguration = $this->objectManager->get(StockConfigurationInterface::class);
129+
130+
$product = $this->productRepository->get('simple');
131+
/** @var Item $stockItem */
132+
$stockItem = $product->getExtensionAttributes()->getStockItem();
133+
$stockItem->setMaxSaleQty($maxSaleQty);
134+
$stockItem->setMinSaleQty($minSaleQty);
135+
$stockRepository->save($stockItem);
136+
137+
$this->model->setWriter(
138+
$this->objectManager->create(
139+
\Magento\ImportExport\Model\Export\Adapter\Csv::class
140+
)
141+
);
142+
$exportData = $this->model->export();
143+
$this->assertStringContainsString((string)$stockConfiguration->getMaxSaleQty(), $exportData);
144+
$this->assertStringNotContainsString($maxSaleQty, $exportData);
145+
$this->assertStringNotContainsString($minSaleQty, $exportData);
146+
$this->assertStringContainsString('Simple Product Without Custom Options', $exportData);
147+
}
148+
111149
/**
112150
* Verify successful export of the product with custom attributes containing json and markup
113151
*

0 commit comments

Comments
 (0)