Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ManageStockConditionTest.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
12 use PHPUnit\Framework\TestCase;
13 
14 class ManageStockConditionTest extends TestCase
15 {
19  private $isProductSalableForRequestedQty;
20 
24  protected function setUp()
25  {
26  parent::setUp();
27 
28  $this->isProductSalableForRequestedQty
29  = Bootstrap::getObjectManager()->get(IsProductSalableForRequestedQtyInterface::class);
30  }
31 
50  public function testExecuteWithManageStockFalse(string $sku, int $stockId, float $qty, bool $expectedResult)
51  {
52  $isSalable = $this->isProductSalableForRequestedQty->execute($sku, $stockId, $qty)->isSalable();
53  self::assertEquals($expectedResult, $isSalable);
54  }
55 
59  public function executeWithManageStockFalseDataProvider(): array
60  {
61  return [
62  ['SKU-1', 10, 1, true],
63  ['SKU-1', 20, 1, false],
64  ['SKU-1', 30, 1, true],
65  ['SKU-2', 10, 1, false],
66  ['SKU-2', 20, 1, true],
67  ['SKU-2', 30, 1, true],
68  ['SKU-3', 10, 1, true],
69  ['SKU-3', 20, 1, false],
70  ['SKU-3', 30, 1, true],
71  ];
72  }
73 }