@@ -181,6 +181,7 @@ protected function setUp(): void
181181 * @param string $storeCurrencyCode
182182 * @param string $adminOrderAmount
183183 * @param string $convertedAmount
184+ * @param bool $needToGetRateFromModel
184185 * @throws LocalizedException
185186 * @throws NoSuchEntityException
186187 * @throws CurrencyException
@@ -195,7 +196,8 @@ public function testRender(
195196 string $ adminCurrencyCode ,
196197 string $ storeCurrencyCode ,
197198 string $ adminOrderAmount ,
198- string $ convertedAmount
199+ string $ convertedAmount ,
200+ bool $ needToGetRateFromModel
199201 ): void {
200202 $ this ->row = new DataObject (
201203 [
@@ -252,6 +254,14 @@ public function testRender(
252254 ->willReturn ($ currLocaleMock );
253255 $ this ->gridColumnMock ->method ('getCurrency ' )->willReturn ('USD ' );
254256 $ 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+
255265 $ actualAmount = $ this ->model ->render ($ this ->row );
256266 $ this ->assertEquals ($ convertedAmount , $ actualAmount );
257267 }
@@ -272,7 +282,8 @@ public function getCurrencyDataProvider(): array
272282 'adminCurrencyCode ' => 'EUR ' ,
273283 'storeCurrencyCode ' => 'EUR ' ,
274284 'adminOrderAmount ' => '105.00 ' ,
275- 'convertedAmount ' => '105.00 '
285+ 'convertedAmount ' => '105.00 ' ,
286+ 'needToGetRateFromModel ' => false
276287 ],
277288 'rate conversion with different admin and storefront rate ' => [
278289 'rate ' => 1.4150 ,
@@ -282,8 +293,20 @@ public function getCurrencyDataProvider(): array
282293 'adminCurrencyCode ' => 'USD ' ,
283294 'storeCurrencyCode ' => 'EUR ' ,
284295 '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+ ],
287310 ];
288311 }
289312
0 commit comments