44 $this->productMock = $this->createMock(\
Magento\Catalog\Model\Product::class);
45 $this->priceInfoMock = $this->createPartialMock(
46 \
Magento\Framework\Pricing\PriceInfo\Base::class,
47 [
'getPrice',
'getPrices']
49 $this->finalPriceMock = $this->createMock(\
Magento\Catalog\Pricing\
Price\FinalPrice::class);
50 $this->priceMock = $this->getMockForAbstractClass(
51 \
Magento\Bundle\Pricing\
Price\DiscountProviderInterface::class
53 $this->calculator = new \Magento\Bundle\Pricing\Price\DiscountCalculator();
65 $price->expects($this->exactly(3))
66 ->method(
'getDiscountPercent')
67 ->will($this->returnValue(
$value));
76 $this->productMock->expects($this->exactly(2))
77 ->method(
'getPriceInfo')
78 ->will($this->returnValue($this->priceInfoMock));
79 $this->priceInfoMock->expects($this->once())
82 ->will($this->returnValue($this->finalPriceMock));
83 $this->finalPriceMock->expects($this->once())
85 ->will($this->returnValue(100));
86 $this->priceInfoMock->expects($this->once())
97 $this->assertEquals(20, $this->calculator->calculateDiscount($this->productMock));
105 $this->productMock->expects($this->once())
106 ->method(
'getPriceInfo')
107 ->will($this->returnValue($this->priceInfoMock));
108 $this->priceInfoMock->expects($this->once())
109 ->method(
'getPrices')
119 $this->assertEquals(10, $this->calculator->calculateDiscount($this->productMock, 50));
testCalculateDiscountWithCustomAmount()
testCalculateDiscountWithDefaultAmount()