30 $this->storeManager = $this->getMockBuilder(\
Magento\Store\Model\StoreManager::class)
31 ->disableOriginalConstructor()
34 $this->currencyFactory = $this->getMockBuilder(\
Magento\Directory\Model\CurrencyFactory::class)
35 ->disableOriginalConstructor()
36 ->setMethods([
'create'])
39 $this->logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)
42 $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
44 \
Magento\Directory\Model\PriceCurrency::class,
46 'storeManager' => $this->storeManager,
47 'currencyFactory' => $this->currencyFactory
55 $convertedAmount = 9.3;
61 $this->assertEquals($convertedAmount, $this->priceCurrency->convert(
$amount,
$store, $currency));
68 $convertedAmount = 9.3;
74 $this->storeManager->expects($this->once())
77 ->will($this->returnValue(
$store));
79 $this->assertEquals($convertedAmount, $this->priceCurrency->convert(
$amount,
$storeCode, $currency));
86 $convertedAmount = 9.3;
89 $currentCurrency->expects($this->once())
92 ->will($this->returnSelf());
94 $this->currencyFactory->expects($this->once())
96 ->will($this->returnValue($currentCurrency));
99 $baseCurrency->expects($this->once())
101 ->with($currentCurrency)
102 ->will($this->returnValue(1.2));
105 $this->assertEquals($convertedAmount, $this->priceCurrency->convert(
$amount,
$store, $currency));
112 $convertedAmount = 9.3;
117 $store->expects($this->atLeastOnce())
118 ->method(
'getCurrentCurrency')
119 ->will($this->returnValue($currentCurrency));
121 $this->assertEquals($convertedAmount, $this->priceCurrency->convert(
$amount,
$store, $currency));
128 $includeContainer =
false;
130 $formattedAmount =
'5.6 grn';
133 $currency->expects($this->once())
134 ->method(
'formatPrecision')
135 ->with(
$amount, $precision, [], $includeContainer)
136 ->will($this->returnValue($formattedAmount));
138 $this->assertEquals($formattedAmount, $this->priceCurrency->format(
151 $includeContainer =
false;
153 $convertedAmount = 9.3;
154 $formattedAmount =
'9.3 grn';
160 $currency->expects($this->once())
161 ->method(
'formatPrecision')
162 ->with($convertedAmount, $precision, [], $includeContainer)
163 ->will($this->returnValue($formattedAmount));
165 $this->assertEquals($formattedAmount, $this->priceCurrency->convertAndFormat(
180 $currencyMock->expects($this->once())
181 ->method(
'getCurrencySymbol')
191 $currency = $this->getMockBuilder(\
Magento\Directory\Model\Currency::class)
192 ->disableOriginalConstructor()
204 $store = $this->getMockBuilder(\
Magento\Store\Model\Store::class)
205 ->disableOriginalConstructor()
208 $store->expects($this->atLeastOnce())
209 ->method(
'getBaseCurrency')
210 ->will($this->returnValue($baseCurrency));
223 $baseCurrency = $this->getMockBuilder(\
Magento\Directory\Model\Currency::class)
224 ->disableOriginalConstructor()
227 $baseCurrency->expects($this->once())
230 ->will($this->returnValue($convertedAmount));
232 return $baseCurrency;
239 $convertedAmount = 9.326;
240 $roundedConvertedAmount = 9.33;
246 $this->storeManager->expects($this->once())
249 ->will($this->returnValue(
$store));
252 $roundedConvertedAmount,
testConvertWithStoreCurrency()
testConvertWithCurrencyString()
getStoreMock($baseCurrency)
testConvertWithStoreCode()
getBaseCurrencyMock($amount, $convertedAmount, $currency)