-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…to version #26650
- Loading branch information
Showing
2 changed files
with
77 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...to/CatalogInventory/Test/Unit/Model/Quote/Item/QuantityValidator/QuoteItemQtyListTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\CatalogInventory\Test\Unit\Model\Quote\Item\QuantityValidator; | ||
|
||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; | ||
use PHPUnit\Framework\TestCase; | ||
use Magento\CatalogInventory\Model\Quote\Item\QuantityValidator\QuoteItemQtyList; | ||
|
||
/** | ||
* Class QuoteItemQtyListTest | ||
*/ | ||
class QuoteItemQtyListTest extends TestCase | ||
{ | ||
/** | ||
* @var QuoteItemQtyList | ||
*/ | ||
private $quoteItemQtyList; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $itemQtyTestValue; | ||
|
||
/** | ||
* Sets up the fixture, for example, open a network connection. | ||
* This method is called before a test is executed. | ||
*/ | ||
protected function setUp() | ||
{ | ||
$objectManagerHelper = new ObjectManager($this); | ||
$this->quoteItemQtyList = $objectManagerHelper->getObject(QuoteItemQtyList::class); | ||
} | ||
|
||
/** | ||
* This tests the scenario when item has not quote_item_id and after save gets a value. | ||
* | ||
* @return void | ||
*/ | ||
public function testSingleQuoteItemQty() | ||
{ | ||
$this->itemQtyTestValue = 1; | ||
$qty = $this->quoteItemQtyList->getQty(125, null, 11232, 1); | ||
$this->assertEquals($this->itemQtyTestValue, $qty); | ||
|
||
$qty = $this->quoteItemQtyList->getQty(125, 1, 11232, 1); | ||
$this->assertEquals($this->itemQtyTestValue, $qty); | ||
} | ||
|
||
/** | ||
* This tests the scenario when item has been added twice to the cart. | ||
* | ||
* @return void | ||
*/ | ||
public function testMultipleQuoteItemQty() | ||
{ | ||
$this->itemQtyTestValue = 1; | ||
$qty = $this->quoteItemQtyList->getQty(127, 1, 112, 1); | ||
$this->assertEquals($this->itemQtyTestValue, $qty); | ||
|
||
$this->itemQtyTestValue = 2; | ||
$qty = $this->quoteItemQtyList->getQty(127, 2, 112, 1); | ||
$this->assertEquals($this->itemQtyTestValue, $qty); | ||
} | ||
} |