Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
MinQtyConditionTest.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 MinQtyConditionTest extends TestCase
15 {
19  private $isProductSalable;
20 
24  protected function setUp()
25  {
26  parent::setUp();
27 
28  $this->isProductSalable = Bootstrap::getObjectManager()->get(IsProductSalableInterface::class);
29  }
30 
49  public function testExecuteWithMinQty(string $sku, int $stockId, bool $expectedResult)
50  {
51  $isSalable = $this->isProductSalable->execute($sku, $stockId);
52  self::assertEquals($expectedResult, $isSalable);
53  }
54 
58  public function executeWithMinQtyDataProvider(): array
59  {
60  return [
61  ['SKU-1', 10, true],
62  ['SKU-1', 20, false],
63  ['SKU-1', 30, true],
64  ['SKU-2', 10, false],
65  ['SKU-2', 20, false],
66  ['SKU-2', 30, false],
67  ['SKU-3', 10, false],
68  ['SKU-3', 20, false],
69  ['SKU-3', 30, false],
70  ];
71  }
72 
92  public function testExecuteWithManageStockFalseAndMinQty(string $sku, int $stockId, bool $expectedResult)
93  {
94  $isSalable = $this->isProductSalable->execute($sku, $stockId);
95  self::assertEquals($expectedResult, $isSalable);
96  }
97 
101  public function executeWithManageStockFalseAndMinQty(): array
102  {
103  return [
104  ['SKU-1', 10, true],
105  ['SKU-1', 20, false],
106  ['SKU-1', 30, true],
107  ['SKU-2', 10, false],
108  ['SKU-2', 20, true],
109  ['SKU-2', 30, true],
110  ['SKU-3', 10, true],
111  ['SKU-3', 20, false],
112  ['SKU-3', 30, true],
113  ];
114  }
115 }
testExecuteWithManageStockFalseAndMinQty(string $sku, int $stockId, bool $expectedResult)