8 use \Magento\Framework\Pricing\Render\AbstractAdjustment;
32 $this->priceCurrency = $this->createMock(\
Magento\Framework\Pricing\PriceCurrencyInterface::class);
33 $this->data = [
'argument_one' => 1];
35 $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
39 'priceCurrency' => $this->priceCurrency,
43 $this->model = $this->getMockBuilder(\
Magento\Framework\Pricing\
Render\AbstractAdjustment::class)
44 ->setConstructorArgs($constructorArgs)
45 ->setMethods([
'getData',
'setData',
'apply'])
46 ->getMockForAbstractClass();
52 $includeContainer =
true;
57 $this->priceCurrency->expects($this->once())
58 ->method(
'convertAndFormat')
59 ->with(
$amount, $includeContainer, $precision)
60 ->will($this->returnValue(
$result));
62 $this->assertEquals(
$result, $this->model->convertAndFormatCurrency(
$amount, $includeContainer, $precision));
67 $amountRender = $this->createMock(\
Magento\Framework\Pricing\
Render\Amount::class);
69 $mergedArguments = [
'argument_one' => 1,
'argument_two' => 2];
70 $renderText =
'amount data';
72 $this->model->expects($this->at(0))
74 ->will($this->returnValue($this->data));
75 $this->model->expects($this->at(1))
77 ->with($mergedArguments);
78 $this->model->expects($this->at(2))
80 ->will($this->returnValue($renderText));
81 $this->model->expects($this->at(3))
86 $this->assertEquals($renderText,
$result);
91 $amountRender = $this->createMock(\
Magento\Framework\Pricing\
Render\Amount::class);
92 $this->model->expects($this->at(0))
94 ->will($this->returnValue($this->data));
95 $this->model->render($amountRender);
96 $this->assertEquals($amountRender, $this->model->getAmountRender());
101 $amountRender = $this->createMock(\
Magento\Framework\Pricing\
Render\Amount::class);
102 $price = $this->getMockForAbstractClass(\
Magento\Framework\Pricing\Price\PriceInterface::class);
103 $sealableItem = $this->getMockForAbstractClass(\
Magento\Framework\Pricing\SaleableInterface::class);
104 $priceInfo = $this->createMock(\
Magento\Framework\Pricing\PriceInfo\Base::class);
105 $priceCode =
'regular_price';
107 $amountRender->expects($this->once())
108 ->method(
'getSaleableItem')
109 ->will($this->returnValue($sealableItem));
110 $sealableItem->expects($this->once())
111 ->method(
'getPriceInfo')
112 ->will($this->returnValue($priceInfo));
113 $priceInfo->expects($this->once())
116 ->will($this->returnValue(
$price));
118 $this->model->expects($this->at(0))
120 ->will($this->returnValue($this->data));
121 $this->model->render($amountRender);
122 $this->assertEquals(
$price, $this->model->getPriceType($priceCode));
128 $amountRender = $this->createMock(\
Magento\Framework\Pricing\
Render\Amount::class);
129 $amountRender->expects($this->once())
132 ->will($this->returnValue(
$price));
134 $this->model->expects($this->at(0))
136 ->will($this->returnValue($this->data));
137 $this->model->render($amountRender);
138 $this->assertEquals(
$price, $this->model->getPrice());
143 $sealableItem = $this->getMockForAbstractClass(\
Magento\Framework\Pricing\SaleableInterface::class);
144 $amountRender = $this->createMock(\
Magento\Framework\Pricing\
Render\Amount::class);
145 $amountRender->expects($this->once())
146 ->method(
'getSaleableItem')
148 ->will($this->returnValue($sealableItem));
150 $this->model->expects($this->at(0))
152 ->will($this->returnValue($this->data));
153 $this->model->render($amountRender);
154 $this->assertEquals($sealableItem, $this->model->getSaleableItem());
159 $amountRender = $this->createMock(\
Magento\Framework\Pricing\
Render\Amount::class);
160 $adjustment = $this->getMockForAbstractClass(\
Magento\Framework\Pricing\Adjustment\AdjustmentInterface::class);
161 $sealableItem = $this->getMockForAbstractClass(\
Magento\Framework\Pricing\SaleableInterface::class);
162 $priceInfo = $this->createMock(\
Magento\Framework\Pricing\PriceInfo\Base::class);
163 $adjustmentCode =
'tax';
165 $amountRender->expects($this->once())
166 ->method(
'getSaleableItem')
167 ->will($this->returnValue($sealableItem));
168 $sealableItem->expects($this->once())
169 ->method(
'getPriceInfo')
170 ->will($this->returnValue($priceInfo));
171 $priceInfo->expects($this->once())
172 ->method(
'getAdjustment')
173 ->with($adjustmentCode)
174 ->will($this->returnValue($adjustment));
176 $this->model->expects($this->at(0))
178 ->will($this->returnValue($this->data));
179 $this->model->expects($this->once())
180 ->method(
'getAdjustmentCode')
181 ->will($this->returnValue($adjustmentCode));
182 $this->model->render($amountRender);
183 $this->assertEquals($adjustment, $this->model->getAdjustment());
189 $includeContainer =
false;
194 $this->priceCurrency->expects($this->once())
196 ->with(
$amount, $includeContainer, $precision)
197 ->will($this->returnValue($expected));
199 $result = $this->model->formatCurrency(
$amount, $includeContainer, $precision);
200 $this->assertEquals($expected,
$result,
'formatCurrent returned unexpected result');
testConvertAndFormatCurrency()