48 $this->saleableInterfaceMock = $this->getMockBuilder(\
Magento\Catalog\Model\Product::class)
49 ->disableOriginalConstructor()
50 ->setMethods([
'getPriceInfo',
'getPriceType',
'getPrice'])
52 $this->bundleCalculatorMock = $this->createMock(
53 \
Magento\Bundle\Pricing\Adjustment\BundleCalculatorInterface::class
56 $this->priceInfoMock = $this->createMock(\
Magento\Framework\Pricing\PriceInfo\Base::class);
58 $this->customOptionPriceMock = $this->getMockBuilder(\
Magento\Catalog\Pricing\
Price\CustomOptionPrice::class)
59 ->disableOriginalConstructor()
62 $this->saleableInterfaceMock->expects($this->once())
63 ->method(
'getPriceInfo')
64 ->will($this->returnValue($this->priceInfoMock));
66 $this->priceCurrencyMock = $this->createMock(\
Magento\Framework\Pricing\PriceCurrencyInterface::class);
68 $this->objectManagerHelper =
new ObjectManagerHelper($this);
69 $this->regularPrice = new \Magento\Bundle\Pricing\Price\BundleRegularPrice(
70 $this->saleableInterfaceMock,
72 $this->bundleCalculatorMock,
73 $this->priceCurrencyMock
81 $this->saleableInterfaceMock->expects($this->once())
83 ->will($this->returnValue($expectedResult));
85 $this->bundleCalculatorMock->expects($this->once())
86 ->method(
'getMinRegularAmount')
87 ->with($expectedResult, $this->saleableInterfaceMock)
88 ->will($this->returnValue($expectedResult));
90 $this->priceCurrencyMock->expects($this->once())
91 ->method(
'convertAndRound')
92 ->will($this->returnArgument(0));
94 $result = $this->regularPrice->getAmount();
95 $this->assertEquals($expectedResult,
$result,
'Incorrect amount');
98 $result = $this->regularPrice->getAmount();
99 $this->assertEquals($expectedResult,
$result,
'Incorrect amount');
106 $this->saleableInterfaceMock->expects($this->once())
108 ->will($this->returnValue($expectedResult));
110 $this->bundleCalculatorMock->expects($this->once())
111 ->method(
'getMaxRegularAmount')
112 ->with($expectedResult, $this->saleableInterfaceMock)
113 ->will($this->returnValue($expectedResult));
115 $this->priceCurrencyMock->expects($this->once())
116 ->method(
'convertAndRound')
117 ->will($this->returnArgument(0));
119 $result = $this->regularPrice->getMaximalPrice();
120 $this->assertEquals($expectedResult,
$result,
'Incorrect amount');
123 $result = $this->regularPrice->getMaximalPrice();
124 $this->assertEquals($expectedResult,
$result,
'Incorrect amount the second time');
132 $expectedPrice =
$price + $maxOptionPrice;
134 $this->priceInfoMock->expects($this->atLeastOnce())
137 ->willReturn($this->customOptionPriceMock);
139 $this->customOptionPriceMock->expects($this->once())
140 ->method(
'getCustomOptionRange')
142 ->willReturn($maxOptionPrice);
144 $this->saleableInterfaceMock->expects($this->once())
145 ->method(
'getPriceType')
148 $this->saleableInterfaceMock->expects($this->once())
150 ->will($this->returnValue(
$price));
152 $this->bundleCalculatorMock->expects($this->once())
153 ->method(
'getMaxRegularAmount')
154 ->with($expectedPrice, $this->saleableInterfaceMock)
155 ->will($this->returnValue($expectedPrice));
157 $this->priceCurrencyMock->expects($this->once())
158 ->method(
'convertAndRound')
159 ->will($this->returnArgument(0));
161 $result = $this->regularPrice->getMaximalPrice();
162 $this->assertEquals($expectedPrice,
$result,
'Incorrect amount');
165 $result = $this->regularPrice->getMaximalPrice();
166 $this->assertEquals($expectedPrice,
$result,
'Incorrect amount the second time');
173 $this->saleableInterfaceMock->expects($this->once())
175 ->will($this->returnValue($expectedResult));
177 $this->priceCurrencyMock->expects($this->once())
178 ->method(
'convertAndRound')
179 ->will($this->returnArgument(0));
181 $this->bundleCalculatorMock->expects($this->once())
182 ->method(
'getMinRegularAmount')
183 ->with($expectedResult, $this->saleableInterfaceMock)
184 ->will($this->returnValue($expectedResult));
186 $result = $this->regularPrice->getMinimalPrice();
187 $this->assertEquals($expectedResult,
$result,
'Incorrect amount');
190 $result = $this->regularPrice->getMinimalPrice();
191 $this->assertEquals($expectedResult,
$result,
'Incorrect amount the second time');
198 $expectedValue =
$price + $minOptionPrice;
200 $this->saleableInterfaceMock->expects($this->once())
202 ->will($this->returnValue(
$price));
204 $this->saleableInterfaceMock->expects($this->once())
205 ->method(
'getPriceType')
208 $this->priceInfoMock->expects($this->atLeastOnce())
211 ->willReturn($this->customOptionPriceMock);
213 $this->customOptionPriceMock->expects($this->once())
214 ->method(
'getCustomOptionRange')
216 ->willReturn($minOptionPrice);
218 $this->priceCurrencyMock->expects($this->once())
219 ->method(
'convertAndRound')
220 ->will($this->returnArgument(0));
222 $this->bundleCalculatorMock->expects($this->once())
223 ->method(
'getMinRegularAmount')
224 ->with($expectedValue, $this->saleableInterfaceMock)
225 ->will($this->returnValue($expectedValue));
227 $result = $this->regularPrice->getMinimalPrice();
228 $this->assertEquals($expectedValue,
$result,
'Incorrect amount');
231 $result = $this->regularPrice->getMinimalPrice();
232 $this->assertEquals($expectedValue,
$result,
'Incorrect amount the second time');
testGetMinimalPriceForFixedPricedBundleWithOptions()
testGetMaximalPriceForFixedPriceBundleWithOption()