123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Weee\Test\Unit\Block\Item\Price;
- use Magento\Weee\Model\Tax as WeeeDisplayConfig;
- class RendererTest extends \PHPUnit\Framework\TestCase
- {
- /**
- * @var \Magento\Weee\Block\Item\Price\Renderer
- */
- protected $renderer;
- /**
- * @var \Magento\Weee\Helper\Data|\PHPUnit_Framework_MockObject_MockObject
- */
- protected $weeeHelper;
- /**
- * @var \Magento\Directory\Model\PriceCurrency|\PHPUnit_Framework_MockObject_MockObject
- */
- protected $priceCurrency;
- /**
- * @var \Magento\Quote\Model\Quote\Item|\PHPUnit_Framework_MockObject_MockObject
- */
- protected $item;
- const STORE_ID = 'store_id';
- const ZONE = 'zone';
- protected function setUp()
- {
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $this->weeeHelper = $this->getMockBuilder(\Magento\Weee\Helper\Data::class)
- ->disableOriginalConstructor()
- ->setMethods([
- 'isEnabled',
- 'typeOfDisplay',
- 'getWeeeTaxInclTax',
- 'getRowWeeeTaxInclTax',
- 'getBaseRowWeeeTaxInclTax',
- 'getBaseWeeeTaxInclTax',
- ])
- ->getMock();
- $this->priceCurrency = $this->getMockBuilder(\Magento\Directory\Model\PriceCurrency::class)
- ->disableOriginalConstructor()
- ->setMethods(['format'])
- ->getMock();
- $this->item = $this->getMockBuilder(\Magento\Quote\Model\Quote\Item::class)
- ->disableOriginalConstructor()
- ->setMethods([
- '__wakeup',
- 'getWeeeTaxAppliedAmount',
- 'getPriceInclTax',
- 'getRowTotalInclTax',
- 'getCalculationPrice',
- 'getRowTotal',
- 'getWeeeTaxAppliedRowAmount',
- 'getStoreId',
- 'getBaseRowTotalInclTax',
- 'getBaseRowTotal',
- 'getBaseWeeeTaxAppliedRowAmnt',
- 'getBasePrice',
- 'getBaseWeeeTaxAppliedAmount',
- 'getBaseWeeeTaxInclTax',
- 'getBasePriceInclTax',
- 'getQtyOrdered'
- ])
- ->getMock();
- $this->item->expects($this->any())
- ->method('getStoreId')
- ->will($this->returnValue(self::STORE_ID));
- $this->renderer = $objectManager->getObject(
- \Magento\Weee\Block\Item\Price\Renderer::class,
- [
- 'weeeHelper' => $this->weeeHelper,
- 'priceCurrency' => $this->priceCurrency,
- ]
- );
- $this->renderer->setItem($this->item);
- $this->renderer->setZone(self::ZONE);
- }
- /**
- * @param bool $isWeeeEnabled
- * @param bool $showWeeeDetails
- * @param bool $hasWeeeAmount
- * @param bool $expectedValue
- * @dataProvider displayPriceWithWeeeDetailsDataProvider
- */
- public function testDisplayPriceWithWeeeDetails(
- $isWeeeEnabled,
- $showWeeeDetails,
- $hasWeeeAmount,
- $expectedValue
- ) {
- $this->weeeHelper->expects($this->once())
- ->method('isEnabled')
- ->will($this->returnValue($isWeeeEnabled));
- $this->weeeHelper->expects($this->any())
- ->method('typeOfDisplay')
- ->with(
- [WeeeDisplayConfig::DISPLAY_INCL_DESCR, WeeeDisplayConfig::DISPLAY_EXCL_DESCR_INCL],
- self::ZONE,
- self::STORE_ID
- )->will($this->returnValue($showWeeeDetails));
- $this->item->expects($this->any())
- ->method('getWeeeTaxAppliedAmount')
- ->will($this->returnValue($hasWeeeAmount));
- $this->assertEquals($expectedValue, $this->renderer->displayPriceWithWeeeDetails());
- }
- /**
- * @return array
- */
- public function displayPriceWithWeeeDetailsDataProvider()
- {
- $data = [
- 'weee_disabled_true_true' => [
- 'isWeeeEnabled' => false,
- 'showWeeeDetails' => true,
- 'hasWeeeAmount' => true,
- 'expectedValue' => false,
- ],
- 'weee_disabled_true_false' => [
- 'isWeeeEnabled' => false,
- 'showWeeeDetails' => true,
- 'hasWeeeAmount' => false,
- 'expectedValue' => false,
- ],
- 'weee_disabled_false_true' => [
- 'isWeeeEnabled' => false,
- 'showWeeeDetails' => false,
- 'hasWeeeAmount' => true,
- 'expectedValue' => false,
- ],
- 'weee_disabled_false_false' => [
- 'isWeeeEnabled' => false,
- 'showWeeeDetails' => false,
- 'hasWeeeAmount' => false,
- 'expectedValue' => false,
- ],
- 'weee_enabled_showdetail_true' => [
- 'isWeeeEnabled' => true,
- 'showWeeeDetails' => true,
- 'hasWeeeAmount' => true,
- 'expectedValue' => true,
- ],
- 'weee_enabled_showdetail_string_zero_false' => [
- 'isWeeeEnabled' => true,
- 'showWeeeDetails' => true,
- 'hasWeeeAmount' => "0.0000",
- 'expectedValue' => false,
- ],
- 'weee_enabled_showdetail_false' => [
- 'isWeeeEnabled' => true,
- 'showWeeeDetails' => true,
- 'hasWeeeAmount' => false,
- 'expectedValue' => false,
- ],
- 'weee_enabled_not_showing_detail_true' => [
- 'isWeeeEnabled' => true,
- 'showWeeeDetails' => false,
- 'hasWeeeAmount' => true,
- 'expectedValue' => false,
- ],
- 'weee_enabled_not_showing_detail_false' => [
- 'isWeeeEnabled' => true,
- 'showWeeeDetails' => false,
- 'hasWeeeAmount' => false,
- 'expectedValue' => false,
- ],
- ];
- return $data;
- }
- /**
- * @param $priceInclTax
- * @param $weeeTaxInclTax
- * @param $weeeEnabled
- * @param $includeWeee
- * @param $expectedValue
- * @dataProvider getDisplayPriceDataProvider
- */
- public function testGetUnitDisplayPriceInclTax(
- $priceInclTax,
- $weeeTaxInclTax,
- $weeeEnabled,
- $includeWeee,
- $expectedValue
- ) {
- $this->weeeHelper->expects($this->once())
- ->method('isEnabled')
- ->will($this->returnValue($weeeEnabled));
- $this->weeeHelper->expects($this->any())
- ->method('getWeeeTaxInclTax')
- ->with($this->item)
- ->will($this->returnValue($weeeTaxInclTax));
- $this->item->expects($this->once())
- ->method('getPriceInclTax')
- ->will($this->returnValue($priceInclTax));
- $this->weeeHelper->expects($this->any())
- ->method('typeOfDisplay')
- ->with([WeeeDisplayConfig::DISPLAY_INCL_DESCR, WeeeDisplayConfig::DISPLAY_INCL], self::ZONE)
- ->will($this->returnValue($includeWeee));
- $this->assertEquals($expectedValue, $this->renderer->getUnitDisplayPriceInclTax());
- }
- /**
- * @param $basePriceInclTax
- * @param $baseWeeeTaxInclTax
- * @param $weeeEnabled
- * @param $includeWeee
- * @param $expectedValue
- * @dataProvider getDisplayPriceDataProvider
- */
- public function testGetBaseUnitDisplayPriceInclTax(
- $basePriceInclTax,
- $baseWeeeTaxInclTax,
- $weeeEnabled,
- $includeWeee,
- $expectedValue
- ) {
- $this->weeeHelper->expects($this->once())
- ->method('isEnabled')
- ->will($this->returnValue($weeeEnabled));
- $this->weeeHelper->expects($this->any())
- ->method('getBaseWeeeTaxInclTax')
- ->with($this->item)
- ->will($this->returnValue($baseWeeeTaxInclTax));
- $this->item->expects($this->once())
- ->method('getBasePriceInclTax')
- ->will($this->returnValue($basePriceInclTax));
- $this->weeeHelper->expects($this->any())
- ->method('typeOfDisplay')
- ->with([WeeeDisplayConfig::DISPLAY_INCL_DESCR, WeeeDisplayConfig::DISPLAY_INCL], self::ZONE)
- ->will($this->returnValue($includeWeee));
- $this->assertEquals($expectedValue, $this->renderer->getBaseUnitDisplayPriceInclTax());
- }
- /**
- * @param $priceExclTax
- * @param $weeeTaxExclTax
- * @param $weeeEnabled
- * @param $includeWeee
- * @param $expectedValue
- * @dataProvider getDisplayPriceDataProvider
- */
- public function testGetUnitDisplayPriceExclTax(
- $priceExclTax,
- $weeeTaxExclTax,
- $weeeEnabled,
- $includeWeee,
- $expectedValue
- ) {
- $this->weeeHelper->expects($this->once())
- ->method('isEnabled')
- ->will($this->returnValue($weeeEnabled));
- $this->item->expects($this->any())
- ->method('getWeeeTaxAppliedAmount')
- ->will($this->returnValue($weeeTaxExclTax));
- $this->item->expects($this->once())
- ->method('getCalculationPrice')
- ->will($this->returnValue($priceExclTax));
- $this->weeeHelper->expects($this->any())
- ->method('typeOfDisplay')
- ->with([WeeeDisplayConfig::DISPLAY_INCL_DESCR, WeeeDisplayConfig::DISPLAY_INCL], self::ZONE)
- ->will($this->returnValue($includeWeee));
- $this->assertEquals($expectedValue, $this->renderer->getUnitDisplayPriceExclTax());
- }
- /**
- * @param $basePriceExclTax
- * @param $baseWeeeTaxExclTax
- * @param $weeeEnabled
- * @param $includeWeee
- * @param $expectedValue
- * @dataProvider getDisplayPriceDataProvider
- */
- public function testGetBaseUnitDisplayPriceExclTax(
- $basePriceExclTax,
- $baseWeeeTaxExclTax,
- $weeeEnabled,
- $includeWeee,
- $expectedValue
- ) {
- $this->weeeHelper->expects($this->once())
- ->method('isEnabled')
- ->will($this->returnValue($weeeEnabled));
- $this->item->expects($this->any())
- ->method('getBaseWeeeTaxAppliedAmount')
- ->will($this->returnValue($baseWeeeTaxExclTax));
- $this->item->expects($this->once())
- ->method('getBaseRowTotal')
- ->will($this->returnValue($basePriceExclTax));
- $this->item->expects($this->once())
- ->method('getQtyOrdered')
- ->will($this->returnValue(1));
- $this->weeeHelper->expects($this->any())
- ->method('typeOfDisplay')
- ->with([WeeeDisplayConfig::DISPLAY_INCL_DESCR, WeeeDisplayConfig::DISPLAY_INCL], self::ZONE)
- ->will($this->returnValue($includeWeee));
- $this->assertEquals($expectedValue, $this->renderer->getBaseUnitDisplayPriceExclTax());
- }
- /**
- * @param $rowTotal
- * @param $rowWeeeTaxExclTax
- * @param $weeeEnabled
- * @param $includeWeee
- * @param $expectedValue
- * @dataProvider getDisplayPriceDataProvider
- */
- public function testGetRowDisplayPriceExclTax(
- $rowTotal,
- $rowWeeeTaxExclTax,
- $weeeEnabled,
- $includeWeee,
- $expectedValue
- ) {
- $this->weeeHelper->expects($this->once())
- ->method('isEnabled')
- ->will($this->returnValue($weeeEnabled));
- $this->item->expects($this->any())
- ->method('getWeeeTaxAppliedRowAmount')
- ->will($this->returnValue($rowWeeeTaxExclTax));
- $this->item->expects($this->once())
- ->method('getRowTotal')
- ->will($this->returnValue($rowTotal));
- $this->weeeHelper->expects($this->any())
- ->method('typeOfDisplay')
- ->with([WeeeDisplayConfig::DISPLAY_INCL_DESCR, WeeeDisplayConfig::DISPLAY_INCL], self::ZONE)
- ->will($this->returnValue($includeWeee));
- $this->assertEquals($expectedValue, $this->renderer->getRowDisplayPriceExclTax());
- }
- /**
- * @param $baseRowTotal
- * @param $baseRowWeeeTaxExclTax
- * @param $weeeEnabled
- * @param $includeWeee
- * @param $expectedValue
- * @dataProvider getDisplayPriceDataProvider
- */
- public function testGetBaseRowDisplayPriceExclTax(
- $baseRowTotal,
- $baseRowWeeeTaxExclTax,
- $weeeEnabled,
- $includeWeee,
- $expectedValue
- ) {
- $this->weeeHelper->expects($this->once())
- ->method('isEnabled')
- ->will($this->returnValue($weeeEnabled));
- $this->item->expects($this->any())
- ->method('getBaseWeeeTaxAppliedRowAmnt')
- ->will($this->returnValue($baseRowWeeeTaxExclTax));
- $this->item->expects($this->once())
- ->method('getBaseRowTotal')
- ->will($this->returnValue($baseRowTotal));
- $this->weeeHelper->expects($this->any())
- ->method('typeOfDisplay')
- ->with([WeeeDisplayConfig::DISPLAY_INCL_DESCR, WeeeDisplayConfig::DISPLAY_INCL], self::ZONE)
- ->will($this->returnValue($includeWeee));
- $this->assertEquals($expectedValue, $this->renderer->getBaseRowDisplayPriceExclTax());
- }
- /**
- * @param $rowTotalInclTax
- * @param $rowWeeeTaxInclTax
- * @param $weeeEnabled
- * @param $includeWeee
- * @param $expectedValue
- * @dataProvider getDisplayPriceDataProvider
- */
- public function testGetRowDisplayPriceInclTax(
- $rowTotalInclTax,
- $rowWeeeTaxInclTax,
- $weeeEnabled,
- $includeWeee,
- $expectedValue
- ) {
- $this->weeeHelper->expects($this->once())
- ->method('isEnabled')
- ->will($this->returnValue($weeeEnabled));
- $this->weeeHelper->expects($this->any())
- ->method('getRowWeeeTaxInclTax')
- ->with($this->item)
- ->will($this->returnValue($rowWeeeTaxInclTax));
- $this->item->expects($this->once())
- ->method('getRowTotalInclTax')
- ->will($this->returnValue($rowTotalInclTax));
- $this->weeeHelper->expects($this->any())
- ->method('typeOfDisplay')
- ->with([WeeeDisplayConfig::DISPLAY_INCL_DESCR, WeeeDisplayConfig::DISPLAY_INCL], self::ZONE)
- ->will($this->returnValue($includeWeee));
- $this->assertEquals($expectedValue, $this->renderer->getRowDisplayPriceInclTax());
- }
- /**
- * @param $baseRowTotalInclTax
- * @param $baseRowWeeeTaxInclTax
- * @param $weeeEnabled
- * @param $includeWeee
- * @param $expectedValue
- * @dataProvider getDisplayPriceDataProvider
- */
- public function testGetBaseRowDisplayPriceInclTax(
- $baseRowTotalInclTax,
- $baseRowWeeeTaxInclTax,
- $weeeEnabled,
- $includeWeee,
- $expectedValue
- ) {
- $this->weeeHelper->expects($this->once())
- ->method('isEnabled')
- ->will($this->returnValue($weeeEnabled));
- $this->weeeHelper->expects($this->any())
- ->method('getBaseRowWeeeTaxInclTax')
- ->with($this->item)
- ->will($this->returnValue($baseRowWeeeTaxInclTax));
- $this->item->expects($this->once())
- ->method('getBaseRowTotalInclTax')
- ->will($this->returnValue($baseRowTotalInclTax));
- $this->weeeHelper->expects($this->any())
- ->method('typeOfDisplay')
- ->with([WeeeDisplayConfig::DISPLAY_INCL_DESCR, WeeeDisplayConfig::DISPLAY_INCL], self::ZONE)
- ->will($this->returnValue($includeWeee));
- $this->assertEquals($expectedValue, $this->renderer->getBaseRowDisplayPriceInclTax());
- }
- /**
- * @return array
- */
- public function getDisplayPriceDataProvider()
- {
- $data = [
- 'weee_disabled_true' => [
- 'price' => 100,
- 'weee' => 10,
- 'weee_enabled' => false,
- 'include_weee' => true,
- 'expected_value' => 100,
- ],
- 'weee_disabled_false' => [
- 'price' => 100,
- 'weee' => 10,
- 'weee_enabled' => false,
- 'include_weee' => false,
- 'expected_value' => 100,
- ],
- 'weee_enabled_include_weee' => [
- 'price' => 100,
- 'weee' => 10,
- 'weee_enabled' => true,
- 'include_weee' => true,
- 'expected_value' => 110,
- ],
- 'weee_enabled_not_include_weee' => [
- 'price' => 100,
- 'weee' => 10,
- 'weee_enabled' => true,
- 'include_weee' => false,
- 'expected_value' => 100,
- ],
- ];
- return $data;
- }
- /**
- * @param $priceInclTax
- * @param $weeeTaxInclTax
- * @param $weeeEnabled
- * @param $expectedValue
- * @dataProvider getFinalDisplayPriceDataProvider
- */
- public function testGetFinalUnitDisplayPriceInclTax(
- $priceInclTax,
- $weeeTaxInclTax,
- $weeeEnabled,
- $expectedValue
- ) {
- $this->weeeHelper->expects($this->once())
- ->method('isEnabled')
- ->will($this->returnValue($weeeEnabled));
- $this->weeeHelper->expects($this->any())
- ->method('getWeeeTaxInclTax')
- ->with($this->item)
- ->will($this->returnValue($weeeTaxInclTax));
- $this->item->expects($this->once())
- ->method('getPriceInclTax')
- ->will($this->returnValue($priceInclTax));
- $this->assertEquals($expectedValue, $this->renderer->getFinalUnitDisplayPriceInclTax());
- }
- /**
- * @param $basePriceInclTax
- * @param $baseWeeeTaxInclTax
- * @param $weeeEnabled
- * @param $expectedValue
- * @dataProvider getFinalDisplayPriceDataProvider
- */
- public function testGetBaseFinalUnitDisplayPriceInclTax(
- $basePriceInclTax,
- $baseWeeeTaxInclTax,
- $weeeEnabled,
- $expectedValue
- ) {
- $this->weeeHelper->expects($this->once())
- ->method('isEnabled')
- ->will($this->returnValue($weeeEnabled));
- $this->weeeHelper->expects($this->any())
- ->method('getBaseWeeeTaxInclTax')
- ->with($this->item)
- ->will($this->returnValue($baseWeeeTaxInclTax));
- $this->item->expects($this->once())
- ->method('getBasePriceInclTax')
- ->will($this->returnValue($basePriceInclTax));
- $this->assertEquals($expectedValue, $this->renderer->getBaseFinalUnitDisplayPriceInclTax());
- }
- /**
- * @param $priceExclTax
- * @param $weeeTaxExclTax
- * @param $weeeEnabled
- * @param $expectedValue
- * @dataProvider getFinalDisplayPriceDataProvider
- */
- public function testGetFinalUnitDisplayPriceExclTax(
- $priceExclTax,
- $weeeTaxExclTax,
- $weeeEnabled,
- $expectedValue
- ) {
- $this->weeeHelper->expects($this->once())
- ->method('isEnabled')
- ->will($this->returnValue($weeeEnabled));
- $this->item->expects($this->any())
- ->method('getWeeeTaxAppliedAmount')
- ->will($this->returnValue($weeeTaxExclTax));
- $this->item->expects($this->once())
- ->method('getCalculationPrice')
- ->will($this->returnValue($priceExclTax));
- $this->assertEquals($expectedValue, $this->renderer->getFinalUnitDisplayPriceExclTax());
- }
- /**
- * @param $basePriceExclTax
- * @param $baseWeeeTaxExclTax
- * @param $weeeEnabled
- * @param $expectedValue
- * @dataProvider getFinalDisplayPriceDataProvider
- */
- public function testGetBaseFinalUnitDisplayPriceExclTax(
- $basePriceExclTax,
- $baseWeeeTaxExclTax,
- $weeeEnabled,
- $expectedValue
- ) {
- $this->weeeHelper->expects($this->once())
- ->method('isEnabled')
- ->will($this->returnValue($weeeEnabled));
- $this->item->expects($this->any())
- ->method('getBaseWeeeTaxAppliedAmount')
- ->will($this->returnValue($baseWeeeTaxExclTax));
- $this->item->expects($this->once())
- ->method('getBaseRowTotal')
- ->will($this->returnValue($basePriceExclTax));
- $this->item->expects($this->once())
- ->method('getQtyOrdered')
- ->will($this->returnValue(1));
- $this->assertEquals($expectedValue, $this->renderer->getBaseFinalUnitDisplayPriceExclTax());
- }
- /**
- * @param $rowTotal
- * @param $rowWeeeTaxExclTax
- * @param $weeeEnabled
- * @param $expectedValue
- * @dataProvider getFinalDisplayPriceDataProvider
- */
- public function testGetFianlRowDisplayPriceExclTax(
- $rowTotal,
- $rowWeeeTaxExclTax,
- $weeeEnabled,
- $expectedValue
- ) {
- $this->weeeHelper->expects($this->once())
- ->method('isEnabled')
- ->will($this->returnValue($weeeEnabled));
- $this->item->expects($this->any())
- ->method('getWeeeTaxAppliedRowAmount')
- ->will($this->returnValue($rowWeeeTaxExclTax));
- $this->item->expects($this->once())
- ->method('getRowTotal')
- ->will($this->returnValue($rowTotal));
- $this->assertEquals($expectedValue, $this->renderer->getFinalRowDisplayPriceExclTax());
- }
- /**
- * @param $baseRowTotal
- * @param $baseRowWeeeTaxExclTax
- * @param $weeeEnabled
- * @param $expectedValue
- * @dataProvider getFinalDisplayPriceDataProvider
- */
- public function testGetBaseFianlRowDisplayPriceExclTax(
- $baseRowTotal,
- $baseRowWeeeTaxExclTax,
- $weeeEnabled,
- $expectedValue
- ) {
- $this->weeeHelper->expects($this->once())
- ->method('isEnabled')
- ->will($this->returnValue($weeeEnabled));
- $this->item->expects($this->any())
- ->method('getBaseWeeeTaxAppliedRowAmnt')
- ->will($this->returnValue($baseRowWeeeTaxExclTax));
- $this->item->expects($this->once())
- ->method('getBaseRowTotal')
- ->will($this->returnValue($baseRowTotal));
- $this->assertEquals($expectedValue, $this->renderer->getBaseFinalRowDisplayPriceExclTax());
- }
- /**
- * @param $rowTotalInclTax
- * @param $rowWeeeTaxInclTax
- * @param $weeeEnabled
- * @param $expectedValue
- * @dataProvider getFinalDisplayPriceDataProvider
- */
- public function testGetFinalRowDisplayPriceInclTax(
- $rowTotalInclTax,
- $rowWeeeTaxInclTax,
- $weeeEnabled,
- $expectedValue
- ) {
- $this->weeeHelper->expects($this->once())
- ->method('isEnabled')
- ->will($this->returnValue($weeeEnabled));
- $this->weeeHelper->expects($this->any())
- ->method('getRowWeeeTaxInclTax')
- ->with($this->item)
- ->will($this->returnValue($rowWeeeTaxInclTax));
- $this->item->expects($this->once())
- ->method('getRowTotalInclTax')
- ->will($this->returnValue($rowTotalInclTax));
- $this->assertEquals($expectedValue, $this->renderer->getFinalRowDisplayPriceInclTax());
- }
- /**
- * @param $baseRowTotalInclTax
- * @param $baseRowWeeeTaxInclTax
- * @param $weeeEnabled
- * @param $expectedValue
- * @dataProvider getFinalDisplayPriceDataProvider
- */
- public function testGetBaseFinalRowDisplayPriceInclTax(
- $baseRowTotalInclTax,
- $baseRowWeeeTaxInclTax,
- $weeeEnabled,
- $expectedValue
- ) {
- $this->weeeHelper->expects($this->once())
- ->method('isEnabled')
- ->will($this->returnValue($weeeEnabled));
- $this->weeeHelper->expects($this->any())
- ->method('getBaseRowWeeeTaxInclTax')
- ->with($this->item)
- ->will($this->returnValue($baseRowWeeeTaxInclTax));
- $this->item->expects($this->once())
- ->method('getBaseRowTotalInclTax')
- ->will($this->returnValue($baseRowTotalInclTax));
- $this->assertEquals($expectedValue, $this->renderer->getBaseFinalRowDisplayPriceInclTax());
- }
- /**
- * @return array
- */
- public function getFinalDisplayPriceDataProvider()
- {
- $data = [
- 'weee_disabled_true' => [
- 'price' => 100,
- 'weee' => 10,
- 'weee_enabled' => false,
- 'expected_value' => 100,
- ],
- 'weee_enabled_include_weee' => [
- 'price' => 100,
- 'weee' => 10,
- 'weee_enabled' => true,
- 'expected_value' => 110,
- ],
- ];
- return $data;
- }
- public function testGetTotalAmount()
- {
- $rowTotal = 100;
- $taxAmount = 10;
- $discountTaxCompensationAmount = 2;
- $discountAmount = 20;
- $weeeAmount = 5;
- $expectedValue = 97;
- $itemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class)
- ->disableOriginalConstructor()
- ->setMethods(
- [
- 'getRowTotal',
- 'getTaxAmount',
- 'getDiscountTaxCompensationAmount',
- 'getDiscountAmount',
- '__wakeup'
- ]
- )
- ->getMock();
- $itemMock->expects($this->once())
- ->method('getRowTotal')
- ->will($this->returnValue($rowTotal));
- $itemMock->expects($this->once())
- ->method('getTaxAmount')
- ->will($this->returnValue($taxAmount));
- $itemMock->expects($this->once())
- ->method('getDiscountTaxCompensationAmount')
- ->will($this->returnValue($discountTaxCompensationAmount));
- $itemMock->expects($this->once())
- ->method('getDiscountAmount')
- ->will($this->returnValue($discountAmount));
- $this->weeeHelper->expects($this->once())
- ->method('getRowWeeeTaxInclTax')
- ->with($itemMock)
- ->will($this->returnValue($weeeAmount));
- $this->assertEquals($expectedValue, $this->renderer->getTotalAmount($itemMock));
- }
- public function testGetBaseTotalAmount()
- {
- $baseRowTotal = 100;
- $baseTaxAmount = 10;
- $baseDiscountTaxCompensationAmount = 2;
- $baseDiscountAmount = 20;
- $baseWeeeAmount = 5;
- $expectedValue = $baseRowTotal + $baseTaxAmount + $baseDiscountTaxCompensationAmount -
- $baseDiscountAmount + $baseWeeeAmount;
- $itemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class)
- ->disableOriginalConstructor()
- ->setMethods(
- [
- 'getBaseRowTotal',
- 'getBaseTaxAmount',
- 'getBaseDiscountTaxCompensationAmount',
- 'getBaseDiscountAmount',
- '__wakeup'
- ]
- )
- ->getMock();
- $itemMock->expects($this->once())
- ->method('getBaseRowTotal')
- ->will($this->returnValue($baseRowTotal));
- $itemMock->expects($this->once())
- ->method('getBaseTaxAmount')
- ->will($this->returnValue($baseTaxAmount));
- $itemMock->expects($this->once())
- ->method('getBaseDiscountTaxCompensationAmount')
- ->will($this->returnValue($baseDiscountTaxCompensationAmount));
- $itemMock->expects($this->once())
- ->method('getBaseDiscountAmount')
- ->will($this->returnValue($baseDiscountAmount));
- $this->weeeHelper->expects($this->once())
- ->method('getBaseRowWeeeTaxInclTax')
- ->with($itemMock)
- ->will($this->returnValue($baseWeeeAmount));
- $this->assertEquals($expectedValue, $this->renderer->getBaseTotalAmount($itemMock));
- }
- }
|