|
12 | 12 | use Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory;
|
13 | 13 | use Magento\Catalog\Model\Product;
|
14 | 14 | use Magento\Catalog\Model\Product\TierPrice;
|
| 15 | +use Magento\Catalog\Model\Product\Price\TierPriceBuilder; |
15 | 16 | use Magento\Catalog\Model\Product\Type\Price;
|
16 | 17 | use Magento\Customer\Api\GroupManagementInterface;
|
17 | 18 | use Magento\Customer\Model\Data\Group;
|
18 | 19 | use Magento\Customer\Model\GroupManagement;
|
19 | 20 | use Magento\Framework\App\Config\ScopeConfigInterface;
|
| 21 | +use Magento\Framework\Pricing\PriceCurrencyInterface; |
20 | 22 | use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
|
21 | 23 | use Magento\Store\Model\StoreManagerInterface;
|
22 | 24 | use Magento\Store\Model\Website;
|
@@ -69,6 +71,8 @@ class PriceTest extends TestCase
|
69 | 71 |
|
70 | 72 | private $tierPriceExtensionFactoryMock;
|
71 | 73 |
|
| 74 | + private $priceCurrencyMock; |
| 75 | + |
72 | 76 | protected function setUp(): void
|
73 | 77 | {
|
74 | 78 | $this->objectManagerHelper = new ObjectManagerHelper($this);
|
@@ -113,14 +117,27 @@ protected function setUp(): void
|
113 | 117 | ->setMethods(['create'])
|
114 | 118 | ->disableOriginalConstructor()
|
115 | 119 | ->getMock();
|
| 120 | + $this->priceCurrencyMock = $this->getMockBuilder(PriceCurrencyInterface::class) |
| 121 | + ->getMockForAbstractClass(); |
| 122 | + $tierPriceBuilder = $this->objectManagerHelper->getObject( |
| 123 | + TierPriceBuilder::class, |
| 124 | + [ |
| 125 | + 'tierPriceFactory' => $this->tpFactory, |
| 126 | + 'tierPriceExtensionFactory' => $this->tierPriceExtensionFactoryMock, |
| 127 | + 'config' => $this->scopeConfigMock, |
| 128 | + 'storeManager' => $storeMangerMock, |
| 129 | + 'priceCurrency' => $this->priceCurrencyMock, |
| 130 | + ] |
| 131 | + ); |
116 | 132 | $this->model = $this->objectManagerHelper->getObject(
|
117 | 133 | Price::class,
|
118 | 134 | [
|
119 | 135 | 'tierPriceFactory' => $this->tpFactory,
|
120 | 136 | 'config' => $this->scopeConfigMock,
|
121 | 137 | 'storeManager' => $storeMangerMock,
|
122 | 138 | 'groupManagement' => $this->groupManagementMock,
|
123 |
| - 'tierPriceExtensionFactory' => $this->tierPriceExtensionFactoryMock |
| 139 | + 'tierPriceExtensionFactory' => $this->tierPriceExtensionFactoryMock, |
| 140 | + 'tierPriceBuilder' => $tierPriceBuilder |
124 | 141 | ]
|
125 | 142 | );
|
126 | 143 | }
|
@@ -234,6 +251,10 @@ function () {
|
234 | 251 | $this->tierPriceExtensionFactoryMock->expects($this->any())
|
235 | 252 | ->method('create')
|
236 | 253 | ->willReturn($tierPriceExtensionMock);
|
| 254 | + $this->priceCurrencyMock->expects($this->any())->method('convertAndRound') |
| 255 | + ->will( |
| 256 | + $this->onConsecutiveCalls(10, 20) |
| 257 | + ); |
237 | 258 |
|
238 | 259 | // test with the data retrieved as a REST object
|
239 | 260 | $tpRests = $this->model->getTierPrices($this->product);
|
|
0 commit comments