|
12 | 12 | use Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection as ProductAttributeCollection;
|
13 | 13 | use Magento\Catalog\Observer\SwitchPriceAttributeScopeOnConfigChange;
|
14 | 14 | 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; |
15 | 18 | use Magento\Framework\App\Config\ReinitableConfigInterface;
|
16 | 19 |
|
17 | 20 | /**
|
@@ -108,6 +111,41 @@ public function testExport(): void
|
108 | 111 | $this->assertEquals(1, $occurrencesCount);
|
109 | 112 | }
|
110 | 113 |
|
| 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 | + |
111 | 149 | /**
|
112 | 150 | * Verify successful export of the product with custom attributes containing json and markup
|
113 | 151 | *
|
|
0 commit comments