12 class DataTest extends \PHPUnit\Framework\TestCase
31 $this->priceCurrencyMock = $this->createMock(\
Magento\Framework\Pricing\PriceCurrencyInterface::class);
32 $this->productMock = $this->getMockBuilder(\
Magento\Catalog\Model\Product::class)
33 ->disableOriginalConstructor()
34 ->setMethods([
'getMsrp',
'getPriceInfo',
'__wakeup'])
37 $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
40 \
Magento\Msrp\Helper\Data::class,
42 'priceCurrency' => $this->priceCurrencyMock,
50 $convertedFinalPrice = 200;
51 $this->priceCurrencyMock->expects($this->any())
52 ->method(
'convertAndRound')
54 $this->returnCallback(
56 return round(2 * $arg, 2);
61 $finalPriceMock = $this->getMockBuilder(\
Magento\Catalog\Pricing\Price\FinalPrice::class)
62 ->disableOriginalConstructor()
64 $finalPriceMock->expects($this->any())
66 ->will($this->returnValue($convertedFinalPrice));
68 $priceInfoMock = $this->getMockBuilder(\
Magento\Framework\Pricing\PriceInfo\Base::class)
69 ->disableOriginalConstructor()
71 $priceInfoMock->expects($this->once())
73 ->with(\
Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE)
74 ->will($this->returnValue($finalPriceMock));
76 $this->productMock->expects($this->any())
78 ->will($this->returnValue($msrp));
79 $this->productMock->expects($this->any())
80 ->method(
'getPriceInfo')
81 ->will($this->returnValue($priceInfoMock));
83 $result = $this->helper->isMinimalPriceLessMsrp($this->productMock);
84 $this->assertTrue(
$result,
"isMinimalPriceLessMsrp returned incorrect value");
testIsMinimalPriceLessMsrp()