Skip to content

Commit

Permalink
magento#25675 Added Unit tests to test QuoteItemQtyList::getQty method
Browse files Browse the repository at this point in the history
  • Loading branch information
molneek committed Feb 1, 2020
1 parent 3cece5f commit 84cde70
Showing 1 changed file with 64 additions and 0 deletions.
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);
}
}

0 comments on commit 84cde70

Please sign in to comment.