84 $this->saleableItemMock = $this->createPartialMock(
85 \
Magento\Catalog\Model\Product::class,
86 [
'getId',
'__wakeup',
'getPriceInfo',
'hasData',
'getData']
88 $this->dataTimeMock = $this->getMockForAbstractClass(
89 \
Magento\Framework\Stdlib\DateTime\TimezoneInterface::class,
98 $this->coreStoreMock = $this->createMock(\
Magento\Store\Model\Store::class);
99 $this->storeManagerMock = $this->createMock(\
Magento\Store\Model\StoreManager::class);
100 $this->storeManagerMock->expects($this->any())
102 ->will($this->returnValue($this->coreStoreMock));
104 $this->customerSessionMock = $this->createMock(\
Magento\Customer\Model\Session::class);
105 $this->priceInfoMock = $this->getMockBuilder(\
Magento\Framework\Pricing\PriceInfo::class)
106 ->setMethods([
'getAdjustments'])
107 ->disableOriginalConstructor()
109 $this->catalogRuleResourceFactoryMock = $this->createPartialMock(
113 $this->catalogRuleResourceMock = $this->createMock(\
Magento\CatalogRule\Model\
ResourceModel\Rule::class);
115 $this->coreWebsiteMock = $this->createMock(\
Magento\Store\Model\Website::class);
117 $this->priceInfoMock->expects($this->any())
118 ->method(
'getAdjustments')
119 ->will($this->returnValue([]));
120 $this->saleableItemMock->expects($this->any())
121 ->method(
'getPriceInfo')
122 ->will($this->returnValue($this->priceInfoMock));
124 $this->catalogRuleResourceFactoryMock->expects($this->any())
126 ->will($this->returnValue($this->catalogRuleResourceMock));
128 $this->calculator = $this->getMockBuilder(\
Magento\Framework\Pricing\Adjustment\Calculator::class)
129 ->disableOriginalConstructor()
133 $this->priceCurrencyMock = $this->createMock(\
Magento\Framework\Pricing\PriceCurrencyInterface::class);
136 $this->saleableItemMock,
139 $this->priceCurrencyMock,
141 $this->storeManagerMock,
142 $this->customerSessionMock,
143 $this->catalogRuleResourceFactoryMock
149 $this->catalogRuleResourceMock
161 $customerGroupId = 1;
164 $catalogRulePrice = 55.12;
165 $convertedPrice = 45.34;
167 $this->coreStoreMock->expects($this->once())
169 ->will($this->returnValue($coreStoreId));
170 $this->coreStoreMock->expects($this->once())
171 ->method(
'getWebsiteId')
172 ->will($this->returnValue($coreWebsiteId));
173 $this->dataTimeMock->expects($this->once())
174 ->method(
'scopeDate')
175 ->with($this->equalTo($coreStoreId))
177 $this->customerSessionMock->expects($this->once())
178 ->method(
'getCustomerGroupId')
179 ->will($this->returnValue($customerGroupId));
180 $this->catalogRuleResourceMock->expects($this->once())
181 ->method(
'getRulePrice')
182 ->will($this->returnValue($catalogRulePrice));
183 $this->saleableItemMock->expects($this->any())
186 $this->priceCurrencyMock->expects($this->any())
187 ->method(
'convertAndRound')
188 ->with($catalogRulePrice)
189 ->will($this->returnValue($convertedPrice));
191 $this->assertEquals($convertedPrice, $this->object->getValue());
196 $catalogRulePrice = 7.1;
197 $convertedPrice = 5.84;
199 $this->priceCurrencyMock->expects($this->any())
200 ->method(
'convertAndRound')
201 ->with($catalogRulePrice)
202 ->will($this->returnValue($convertedPrice));
204 $this->saleableItemMock->expects($this->once())->method(
'hasData')
205 ->with(
'catalog_rule_price')->willReturn(
true);
206 $this->saleableItemMock->expects($this->once())->method(
'getData')
207 ->with(
'catalog_rule_price')->willReturn($catalogRulePrice);
209 $this->assertEquals($convertedPrice, $this->object->getValue());
214 $this->catalogRuleResourceMock->expects($this->once())
215 ->method(
'getRulePrice')
216 ->will($this->returnValue(
false));
218 $result = $this->
object->getValue();
$catalogRuleResourceFactoryMock
testGetAmountNoBaseAmount()