23
23
use Magento \Store \Api \Data \StoreInterface ;
24
24
use Magento \Store \Api \Data \WebsiteInterface ;
25
25
use Magento \Store \Model \StoreManagerInterface ;
26
+ use Magento \Store \Model \Store ;
27
+ use Magento \Store \Model \ScopeInterface ;
26
28
use PHPUnit \Framework \MockObject \MockObject ;
27
29
use PHPUnit \Framework \TestCase ;
28
30
@@ -181,6 +183,7 @@ protected function setUp(): void
181
183
* @param string $storeCurrencyCode
182
184
* @param string $adminOrderAmount
183
185
* @param string $convertedAmount
186
+ * @param bool $needToGetRateFromModel
184
187
* @throws LocalizedException
185
188
* @throws NoSuchEntityException
186
189
* @throws CurrencyException
@@ -195,7 +198,8 @@ public function testRender(
195
198
string $ adminCurrencyCode ,
196
199
string $ storeCurrencyCode ,
197
200
string $ adminOrderAmount ,
198
- string $ convertedAmount
201
+ string $ convertedAmount ,
202
+ bool $ needToGetRateFromModel
199
203
): void {
200
204
$ this ->row = new DataObject (
201
205
[
@@ -252,6 +256,14 @@ public function testRender(
252
256
->willReturn ($ currLocaleMock );
253
257
$ this ->gridColumnMock ->method ('getCurrency ' )->willReturn ('USD ' );
254
258
$ this ->gridColumnMock ->method ('getRateField ' )->willReturn ('test_rate_field ' );
259
+
260
+ if ($ needToGetRateFromModel ) {
261
+ $ this ->currencyMock ->expects ($ this ->once ())
262
+ ->method ('getRate ' )
263
+ ->with ($ adminCurrencyCode )
264
+ ->willReturn ($ rate );
265
+ }
266
+
255
267
$ actualAmount = $ this ->model ->render ($ this ->row );
256
268
$ this ->assertEquals ($ convertedAmount , $ actualAmount );
257
269
}
@@ -272,7 +284,8 @@ public function getCurrencyDataProvider(): array
272
284
'adminCurrencyCode ' => 'EUR ' ,
273
285
'storeCurrencyCode ' => 'EUR ' ,
274
286
'adminOrderAmount ' => '105.00 ' ,
275
- 'convertedAmount ' => '105.00 '
287
+ 'convertedAmount ' => '105.00 ' ,
288
+ 'needToGetRateFromModel ' => false
276
289
],
277
290
'rate conversion with different admin and storefront rate ' => [
278
291
'rate ' => 1.4150 ,
@@ -282,8 +295,20 @@ public function getCurrencyDataProvider(): array
282
295
'adminCurrencyCode ' => 'USD ' ,
283
296
'storeCurrencyCode ' => 'EUR ' ,
284
297
'adminOrderAmount ' => '105.00 ' ,
285
- 'convertedAmount ' => '148.575 '
286
- ]
298
+ 'convertedAmount ' => '148.575 ' ,
299
+ 'needToGetRateFromModel ' => true
300
+ ],
301
+ 'rate conversation with same rate for different currencies ' => [
302
+ 'rate ' => 1.00 ,
303
+ 'columnIndex ' => 'total_income_amount ' ,
304
+ 'catalogPriceScope ' => 1 ,
305
+ 'adminWebsiteId ' => 1 ,
306
+ 'adminCurrencyCode ' => 'USD ' ,
307
+ 'storeCurrencyCode ' => 'THB ' ,
308
+ 'adminOrderAmount ' => '100.00 ' ,
309
+ 'convertedAmount ' => '100.00 ' ,
310
+ 'needToGetRateFromModel ' => true
311
+ ],
287
312
];
288
313
}
289
314
0 commit comments