Skip to content

Commit

Permalink
MSI-724: Implement IsCorrectQtyConditionTest::testExecuteWithQtyIncre…
Browse files Browse the repository at this point in the history
…ments
  • Loading branch information
RomaKis committed Apr 25, 2018
1 parent 3321569 commit 3575780
Showing 1 changed file with 76 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Magento\InventorySales\Test\Integration\IsProductSalableForRequestedQty;

use Magento\InventoryConfigurationApi\Api\Data\StockItemConfigurationInterface;
use Magento\InventoryConfigurationApi\Api\GetStockItemConfigurationInterface;
use Magento\InventoryConfigurationApi\Api\SaveStockItemConfigurationInterface;
use Magento\InventorySalesApi\Api\IsProductSalableForRequestedQtyInterface;
Expand All @@ -30,6 +31,16 @@ class IsCorrectQtyConditionTest extends TestCase
*/
private $isProductSalableForRequestedQty;

/**
* @var GetStockItemConfigurationInterface
*/
private $getStockItemConfiguration;

/**
* @var SaveStockItemConfigurationInterface
*/
private $saveStockItemConfiguration;

/**
* @inheritdoc
*/
Expand All @@ -41,6 +52,12 @@ protected function setUp()
$this->saveStockItemConfig = Bootstrap::getObjectManager()->get(SaveStockItemConfigurationInterface::class);
$this->isProductSalableForRequestedQty
= Bootstrap::getObjectManager()->get(IsProductSalableForRequestedQtyInterface::class);
$this->getStockItemConfiguration = Bootstrap::getObjectManager()->get(
GetStockItemConfigurationInterface::class
);
$this->saveStockItemConfiguration = Bootstrap::getObjectManager()->get(
SaveStockItemConfigurationInterface::class
);
}

/**
Expand Down Expand Up @@ -85,8 +102,65 @@ public function testExecuteWithMaxSaleQty()
$this->markTestIncomplete('Still to implement');
}

public function testExecuteWithQtyIncrements()
/**
* @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/products.php
* @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php
* @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php
* @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php
* @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php
* @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php
*
* @param string $sku
* @param int $stockId
* @param int $requestedQty
* @param bool $expectedResult
*
* @return void
*
* @dataProvider executeWithQtyIncrementsDataProvider
*/
public function testExecuteWithQtyIncrements(
string $sku,
int $stockId,
int $requestedQty,
bool $expectedResult
): void {
/** @var StockItemConfigurationInterface $stockItemConfiguration */
$stockItemConfiguration = $this->getStockItemConfiguration->execute($sku, $stockId);
$stockItemConfiguration->setUseConfigEnableQtyInc(false);
$stockItemConfiguration->setEnableQtyIncrements(true);
$stockItemConfiguration->setUseConfigQtyIncrements(false);
$stockItemConfiguration->setQtyIncrements(3);
$this->saveStockItemConfiguration->execute($sku, $stockId, $stockItemConfiguration);

$result = $this->isProductSalableForRequestedQty->execute($sku, $stockId, $requestedQty);
$this->assertEquals($expectedResult, $result->isSalable());
}

/**
* @return array
*/
public function executeWithQtyIncrementsDataProvider(): array
{
$this->markTestIncomplete('Still to implement');
return [
['SKU-1', 10, 1, false],
['SKU-1', 10, 3, true],
['SKU-1', 10, 6, true],
['SKU-1', 10, 9, false],
['SKU-3', 10, 1, false],
['SKU-3', 10, 3, false],
['SKU-2', 20, 1, false],
['SKU-2', 20, 3, true],
['SKU-2', 20, 6, false],
['SKU-1', 30, 1, false],
['SKU-1', 30, 3, true],
['SKU-1', 30, 6, true],
['SKU-1', 30, 9, false],
['SKU-2', 30, 1, false],
['SKU-2', 30, 3, true],
['SKU-2', 30, 6, false],
['SKU-3', 30, 1, false],
['SKU-3', 30, 3, false],
];
}
}

0 comments on commit 3575780

Please sign in to comment.