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