forked from magento/magento2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
magento#25675 Added Unit tests to test QuoteItemQtyList::getQty method
- Loading branch information
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
...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,64 @@ | ||
<?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; | ||
|
||
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); | ||
} | ||
} |