60 $this->saleableItemMock = $this->createMock(\
Magento\Catalog\Model\Product::class);
61 $this->priceInfoMock = $this->createMock(\
Magento\Framework\Pricing\PriceInfo\Base::class);
62 $this->regularPriceMock = $this->createMock(\
Magento\Catalog\Pricing\Price\RegularPrice::class);
63 $this->tearPriceMock = $this->createMock(\
Magento\Catalog\Pricing\Price\TierPrice::class);
64 $this->specialPriceMock = $this->createMock(\
Magento\Catalog\Pricing\Price\SpecialPrice::class);
65 $this->calculatorMock = $this->createMock(\
Magento\Framework\Pricing\Adjustment\Calculator::class);
67 $this->saleableItemMock->expects($this->once())
68 ->method(
'getPriceInfo')
69 ->will($this->returnValue($this->priceInfoMock));
76 $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
77 $this->basePrice =
$helper->getObject(
78 \
Magento\Catalog\Pricing\Price\BasePrice::class,
80 'saleableItem' => $this->saleableItemMock,
82 'calculator' => $this->calculatorMock
94 $this->priceInfoMock->expects($this->once())
96 ->will($this->returnValue($this->prices));
97 $this->regularPriceMock->expects($this->exactly(3))
99 ->will($this->returnValue(100));
100 $this->tearPriceMock->expects($this->exactly(2))
102 ->will($this->returnValue(99));
103 $this->specialPriceMock->expects($this->any())
105 ->will($this->returnValue($specialPriceValue));
106 $this->assertSame($expectedResult, $this->basePrice->getValue());
114 return [[77, 77], [0, 0], [
false, 99]];
121 $priceMock = $this->getMockBuilder(\
Magento\Framework\Pricing\Price\PriceInterface::class)
122 ->getMockForAbstractClass();
124 $this->priceInfoMock->expects($this->once())
125 ->method(
'getPrices')
126 ->willReturn([$priceMock]);
128 $this->calculatorMock->expects($this->once())
129 ->method(
'getAmount')
130 ->with(
false, $this->saleableItemMock)
133 $this->assertEquals(
$amount, $this->basePrice->getAmount());
testGetValue($specialPriceValue, $expectedResult)