Skip to content

Commit 1e852be

Browse files
committed
Merge remote-tracking branch 'origin/BUG#AC-3157' into Spartans_2_4_6_Quality_Backlog
2 parents 6c62b13 + 034142a commit 1e852be

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

app/code/Magento/Tax/Pricing/Render/Adjustment.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,7 @@ public function displayPriceExcludingTax()
183183
*/
184184
public function getDataPriceType(): string
185185
{
186-
return $this->amountRender->getPriceType() === 'finalPrice'
187-
? 'basePrice'
188-
: 'base' . ucfirst($this->amountRender->getPriceType());
186+
$priceType = $this->amountRender->getPriceType();
187+
return $priceType === 'finalPrice' ? 'basePrice' : ($priceType ? 'base' . ucfirst($priceType) : '');
189188
}
190189
}

app/code/Magento/Tax/Test/Unit/Pricing/Render/AdjustmentTest.php

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
class AdjustmentTest extends TestCase
3030
{
3131
/**
32-
* Context mock
33-
*
3432
* @var \Magento\Framework\View\Element\Template\Context
3533
*/
3634
protected $contextMock;
@@ -54,6 +52,11 @@ class AdjustmentTest extends TestCase
5452
*/
5553
protected $model;
5654

55+
/**
56+
* @var AmountRenderInterface
57+
*/
58+
protected $amountRender;
59+
5760
/**
5861
* Init mocks and model
5962
*/
@@ -350,4 +353,33 @@ public function testGetHtmlBoth()
350353

351354
$this->model->render($amountRender, $arguments);
352355
}
356+
357+
/**
358+
* test for method getDataPriceType
359+
* @dataProvider dataPriceTypeDataProvider
360+
*/
361+
public function testGetDataPriceType(?string $priceType, string $priceTypeValue): void
362+
{
363+
$amountRender = $this->getMockBuilder(Amount::class)
364+
->addMethods(['getPriceType'])
365+
->disableOriginalConstructor()
366+
->getMock();
367+
$amountRender->expects($this->atLeastOnce())
368+
->method('getPriceType')
369+
->willReturn($priceType);
370+
$this->model->render($amountRender, []);
371+
//no exception is thrown
372+
$this->assertEquals($priceTypeValue, $this->model->getDataPriceType());
373+
$this->assertIsString($this->model->getDataPriceType());
374+
}
375+
376+
/**
377+
* data provider for testGetDataPriceType
378+
*
379+
* @return array
380+
*/
381+
public function dataPriceTypeDataProvider(): array
382+
{
383+
return [['finalPrice', 'basePrice'], [null, '']];
384+
}
353385
}

0 commit comments

Comments
 (0)