Skip to content

Commit

Permalink
Merge pull request magento#1020 from magento-engcom/723
Browse files Browse the repository at this point in the history
MSI-723: Implement IsCorrectQtyConditionTest::testExecuteWithMaxSaleQty
  • Loading branch information
maghamed authored May 3, 2018
2 parents 5759c2f + 86f0b63 commit 93a93f6
Showing 1 changed file with 72 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 @@ -80,9 +97,62 @@ public function testExecuteWithUseConfigMaxSaleQty()
$this->markTestIncomplete('Still to implement');
}

public function testExecuteWithMaxSaleQty()
/**
* @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 executeWithMaxSaleQtyDataProvider
*/
public function testExecuteWithMaxSaleQty(
string $sku,
int $stockId,
int $requestedQty,
bool $expectedResult
): void {
/** @var StockItemConfigurationInterface $stockItemConfiguration */
$stockItemConfiguration = $this->getStockItemConfiguration->execute($sku, $stockId);
$stockItemConfiguration->setUseConfigMaxSaleQty(false);
$stockItemConfiguration->setMaxSaleQty(6);
$this->saveStockItemConfiguration->execute($sku, $stockId, $stockItemConfiguration);

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

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

public function testExecuteWithQtyIncrements()
Expand Down

0 comments on commit 93a93f6

Please sign in to comment.