6 declare(strict_types=1);
15 use PHPUnit\Framework\TestCase;
25 private $getStockItemConfig;
30 private $saveStockItemConfig;
35 private $isProductSalableForRequestedQty;
40 private $getStockItemConfiguration;
45 private $saveStockItemConfiguration;
56 $this->isProductSalableForRequestedQty
59 GetStockItemConfigurationInterface::class
62 SaveStockItemConfigurationInterface::class
92 $result = $this->isProductSalableForRequestedQty->execute($sku, $stockId, $requestedQty);
93 $this->assertEquals($expectedResult,
$result->isSalable());
102 [
'SKU-2', 10, 1,
false],
132 $result = $this->isProductSalableForRequestedQty->execute($sku, $stockId, $requestedQty);
133 $this->assertEquals($expectedResult,
$result->isSalable());
142 [
'SKU-1', 10, 2.5,
true],
143 [
'SKU-1', 10, 2,
true],
144 [
'SKU-2', 30, 2.5,
false],
145 [
'SKU-2', 30, 2,
true]
176 $result = $this->isProductSalableForRequestedQty->execute($sku, $stockId, $requestedQty);
177 $this->assertEquals($expectedResult,
$result->isSalable());
186 [
'SKU-1', 10, 1,
false],
187 [
'SKU-1', 10, 7,
true],
188 [
'SKU-1', 10, 8,
true],
189 [
'SKU-2', 10, 1,
false],
190 [
'SKU-2', 10, 7,
false],
191 [
'SKU-3', 10, 1,
false],
192 [
'SKU-3', 10, 7,
false],
193 [
'SKU-1', 20, 1,
false],
194 [
'SKU-1', 20, 7,
false],
195 [
'SKU-2', 20, 1,
false],
196 [
'SKU-2', 20, 7,
false],
197 [
'SKU-3', 20, 1,
false],
198 [
'SKU-3', 20, 7,
false],
199 [
'SKU-1', 30, 1,
false],
200 [
'SKU-1', 30, 7,
true],
201 [
'SKU-1', 30, 8,
true],
202 [
'SKU-2', 30, 1,
false],
203 [
'SKU-2', 30, 7,
false],
204 [
'SKU-3', 30, 1,
false],
205 [
'SKU-3', 30, 7,
false],
229 public function testExecuteWithMinSaleQty(
236 $stockItemConfiguration = $this->getStockItemConfiguration->execute($sku, $stockId);
237 $stockItemConfiguration->setUseConfigMinSaleQty(
false);
238 $stockItemConfiguration->setMinSaleQty(7);
239 $this->saveStockItemConfiguration->execute($sku, $stockId, $stockItemConfiguration);
241 $result = $this->isProductSalableForRequestedQty->execute($sku, $stockId, $requestedQty);
242 $this->assertEquals($expectedResult,
$result->isSalable());
251 [
'SKU-1', 10, 1,
false],
252 [
'SKU-1', 10, 7,
true],
253 [
'SKU-1', 10, 8,
true],
254 [
'SKU-3', 10, 1,
false],
255 [
'SKU-3', 10, 7,
false],
256 [
'SKU-2', 20, 1,
false],
257 [
'SKU-2', 20, 7,
false],
258 [
'SKU-1', 30, 1,
false],
259 [
'SKU-1', 30, 7,
true],
260 [
'SKU-1', 30, 8,
true],
261 [
'SKU-2', 30, 1,
false],
262 [
'SKU-2', 30, 7,
false],
263 [
'SKU-3', 30, 1,
false],
264 [
'SKU-3', 30, 7,
false],
295 $result = $this->isProductSalableForRequestedQty->execute($sku, $stockId, $requestedQty);
296 $this->assertEquals($expectedResult,
$result->isSalable());
305 [
'SKU-1', 10, 1,
true],
306 [
'SKU-1', 10, 6,
true],
307 [
'SKU-1', 10, 7,
false],
308 [
'SKU-2', 10, 1,
false],
309 [
'SKU-2', 10, 7,
false],
310 [
'SKU-3', 10, 1,
false],
311 [
'SKU-3', 10, 7,
false],
312 [
'SKU-1', 20, 1,
false],
313 [
'SKU-1', 20, 7,
false],
314 [
'SKU-2', 20, 1,
true],
315 [
'SKU-2', 20, 6,
false],
316 [
'SKU-2', 20, 7,
false],
317 [
'SKU-3', 20, 1,
false],
318 [
'SKU-3', 20, 7,
false],
319 [
'SKU-1', 30, 1,
true],
320 [
'SKU-1', 30, 6,
true],
321 [
'SKU-1', 30, 7,
false],
322 [
'SKU-2', 30, 1,
true],
323 [
'SKU-2', 30, 6,
false],
324 [
'SKU-2', 30, 7,
false],
325 [
'SKU-3', 30, 1,
false],
326 [
'SKU-3', 30, 7,
false],
351 public function testExecuteWithMaxSaleQty(
358 $stockItemConfiguration = $this->getStockItemConfiguration->execute($sku, $stockId);
359 $stockItemConfiguration->setUseConfigMaxSaleQty(
false);
360 $stockItemConfiguration->setMaxSaleQty(6);
361 $this->saveStockItemConfiguration->execute($sku, $stockId, $stockItemConfiguration);
363 $result = $this->isProductSalableForRequestedQty->execute($sku, $stockId, $requestedQty);
364 $this->assertEquals($expectedResult,
$result->isSalable());
373 [
'SKU-1', 10, 1,
true],
374 [
'SKU-1', 10, 6,
true],
375 [
'SKU-1', 10, 7,
false],
376 [
'SKU-3', 10, 1,
false],
377 [
'SKU-3', 10, 7,
false],
378 [
'SKU-2', 20, 1,
true],
379 [
'SKU-2', 20, 6,
false],
380 [
'SKU-2', 20, 7,
false],
381 [
'SKU-1', 30, 1,
true],
382 [
'SKU-1', 30, 6,
true],
383 [
'SKU-1', 30, 7,
false],
384 [
'SKU-2', 30, 1,
true],
385 [
'SKU-2', 30, 6,
false],
386 [
'SKU-2', 30, 7,
false],
387 [
'SKU-3', 30, 1,
false],
388 [
'SKU-3', 30, 7,
false],
420 $result = $this->isProductSalableForRequestedQty->execute($sku, $stockId, $requestedQty);
421 $this->assertEquals($expectedResult,
$result->isSalable());
430 [
'SKU-1', 10, 1,
false],
431 [
'SKU-1', 10, 3,
true],
432 [
'SKU-1', 10, 6,
true],
433 [
'SKU-1', 10, 9,
false],
434 [
'SKU-2', 10, 1,
false],
435 [
'SKU-2', 10, 3,
false],
436 [
'SKU-3', 10, 1,
false],
437 [
'SKU-3', 10, 3,
false],
438 [
'SKU-1', 20, 1,
false],
439 [
'SKU-1', 20, 3,
false],
440 [
'SKU-2', 20, 1,
false],
441 [
'SKU-2', 20, 3,
true],
442 [
'SKU-2', 20, 6,
false],
443 [
'SKU-3', 20, 1,
false],
444 [
'SKU-3', 20, 3,
false],
445 [
'SKU-1', 30, 1,
false],
446 [
'SKU-1', 30, 3,
true],
447 [
'SKU-1', 30, 6,
true],
448 [
'SKU-1', 30, 9,
false],
449 [
'SKU-2', 30, 1,
false],
450 [
'SKU-2', 30, 3,
true],
451 [
'SKU-2', 30, 6,
false],
452 [
'SKU-3', 30, 1,
false],
453 [
'SKU-3', 30, 3,
false],
478 public function testExecuteWithQtyIncrements(
485 $stockItemConfiguration = $this->getStockItemConfiguration->execute($sku, $stockId);
486 $stockItemConfiguration->setUseConfigEnableQtyInc(
false);
487 $stockItemConfiguration->setEnableQtyIncrements(
true);
488 $stockItemConfiguration->setUseConfigQtyIncrements(
false);
489 $stockItemConfiguration->setQtyIncrements(3);
490 $this->saveStockItemConfiguration->execute($sku, $stockId, $stockItemConfiguration);
492 $result = $this->isProductSalableForRequestedQty->execute($sku, $stockId, $requestedQty);
493 $this->assertEquals($expectedResult,
$result->isSalable());
502 [
'SKU-1', 10, 1,
false],
503 [
'SKU-1', 10, 3,
true],
504 [
'SKU-1', 10, 6,
true],
505 [
'SKU-1', 10, 9,
false],
506 [
'SKU-3', 10, 1,
false],
507 [
'SKU-3', 10, 3,
false],
508 [
'SKU-2', 20, 1,
false],
509 [
'SKU-2', 20, 3,
true],
510 [
'SKU-2', 20, 6,
false],
511 [
'SKU-1', 30, 1,
false],
512 [
'SKU-1', 30, 3,
true],
513 [
'SKU-1', 30, 6,
true],
514 [
'SKU-1', 30, 9,
false],
515 [
'SKU-2', 30, 1,
false],
516 [
'SKU-2', 30, 3,
true],
517 [
'SKU-2', 30, 6,
false],
518 [
'SKU-3', 30, 1,
false],
519 [
'SKU-3', 30, 3,
false],
executeWithMinSaleQtyDataProvider()
executeWithDecimalQtyDataProvider()
executeWithUseConfigMaxSaleQtyDataProvider()
testExecuteWithDecimalQty(string $sku, int $stockId, float $requestedQty, bool $expectedResult)
testExecuteWithUseConfigMinSaleQty(string $sku, int $stockId, int $requestedQty, bool $expectedResult)
executeWithMaxSaleQtyDataProvider()
testExecuteWithUseConfigQtyIncrements(string $sku, int $stockId, int $requestedQty, bool $expectedResult)
testExecuteWithMissingConfiguration(string $sku, int $stockId, int $requestedQty, bool $expectedResult)
executeWithMissingConfigurationDataProvider()
executeWithUseConfigMinSaleQtyDataProvider()
executeWithUseConfigQtyIncrementsDataProvider()
testExecuteWithUseConfigMaxSaleQty(string $sku, int $stockId, int $requestedQty, bool $expectedResult)
static getObjectManager()
executeWithQtyIncrementsDataProvider()