Skip to content

Commit 1bad503

Browse files
authored
Merge pull request magento#1025 from magento-engcom/724
MSI-724: Implement IsCorrectQtyConditionTest::testExecuteWithQtyIncrements
2 parents 93a93f6 + 3575780 commit 1bad503

File tree

1 file changed

+59
-2
lines changed

1 file changed

+59
-2
lines changed

app/code/Magento/InventorySales/Test/Integration/IsProductSalableForRequestedQty/IsCorrectQtyConditionTest.php

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,65 @@ public function executeWithMaxSaleQtyDataProvider(): array
155155
];
156156
}
157157

158-
public function testExecuteWithQtyIncrements()
158+
/**
159+
* @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/products.php
160+
* @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php
161+
* @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php
162+
* @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php
163+
* @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php
164+
* @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php
165+
*
166+
* @param string $sku
167+
* @param int $stockId
168+
* @param int $requestedQty
169+
* @param bool $expectedResult
170+
*
171+
* @return void
172+
*
173+
* @dataProvider executeWithQtyIncrementsDataProvider
174+
*/
175+
public function testExecuteWithQtyIncrements(
176+
string $sku,
177+
int $stockId,
178+
int $requestedQty,
179+
bool $expectedResult
180+
): void {
181+
/** @var StockItemConfigurationInterface $stockItemConfiguration */
182+
$stockItemConfiguration = $this->getStockItemConfiguration->execute($sku, $stockId);
183+
$stockItemConfiguration->setUseConfigEnableQtyInc(false);
184+
$stockItemConfiguration->setEnableQtyIncrements(true);
185+
$stockItemConfiguration->setUseConfigQtyIncrements(false);
186+
$stockItemConfiguration->setQtyIncrements(3);
187+
$this->saveStockItemConfiguration->execute($sku, $stockId, $stockItemConfiguration);
188+
189+
$result = $this->isProductSalableForRequestedQty->execute($sku, $stockId, $requestedQty);
190+
$this->assertEquals($expectedResult, $result->isSalable());
191+
}
192+
193+
/**
194+
* @return array
195+
*/
196+
public function executeWithQtyIncrementsDataProvider(): array
159197
{
160-
$this->markTestIncomplete('Still to implement');
198+
return [
199+
['SKU-1', 10, 1, false],
200+
['SKU-1', 10, 3, true],
201+
['SKU-1', 10, 6, true],
202+
['SKU-1', 10, 9, false],
203+
['SKU-3', 10, 1, false],
204+
['SKU-3', 10, 3, false],
205+
['SKU-2', 20, 1, false],
206+
['SKU-2', 20, 3, true],
207+
['SKU-2', 20, 6, false],
208+
['SKU-1', 30, 1, false],
209+
['SKU-1', 30, 3, true],
210+
['SKU-1', 30, 6, true],
211+
['SKU-1', 30, 9, false],
212+
['SKU-2', 30, 1, false],
213+
['SKU-2', 30, 3, true],
214+
['SKU-2', 30, 6, false],
215+
['SKU-3', 30, 1, false],
216+
['SKU-3', 30, 3, false],
217+
];
161218
}
162219
}

0 commit comments

Comments
 (0)