diff --git a/payment/tests/helper_test.php b/payment/tests/helper_test.php
index f0700fe9ca1..80b3c547c8a 100644
--- a/payment/tests/helper_test.php
+++ b/payment/tests/helper_test.php
@@ -169,7 +169,7 @@ class helper_test extends advanced_testcase {
* @param float $surcharge
* @param string $expected
*/
- public function test_get_rounded_cost(float $amount, string $currency, float $surcharge, string $expected) {
+ public function test_get_rounded_cost(float $amount, string $currency, float $surcharge, float $expected) {
$this->assertEquals($expected, helper::get_rounded_cost($amount, $currency, $surcharge));
}
@@ -183,6 +183,20 @@ class helper_test extends advanced_testcase {
* @param string $expected
*/
public function test_get_cost_as_string(float $amount, string $currency, float $surcharge, string $expected) {
+ // Some old ICU versions have a bug, where they don't follow the CLDR and they are
+ // missing the non-breaking-space between the currency abbreviation and the value.
+ // i.e. it returns AUD50 instead of AU\xc2\xa050). See the following issues @ ICU:
+ // - https://unicode-org.atlassian.net/browse/ICU-6560
+ // - https://unicode-org.atlassian.net/browse/ICU-8853
+ // - https://unicode-org.atlassian.net/browse/ICU-8840
+ // It has been detected that versions prior to ICU-61.1 / ICU-62.1 come with this
+ // problem. Noticeably Travis images (as of December 2021) use buggy ICU-60.1.
+ // So, here, we are going to dynamically verify the behaviour and skip the
+ // test when buggy one is found. No need to apply this to code as dar as the real
+ // formatting is not critical for the functionality (just small glitch).
+ if ('IRR5' === (new \NumberFormatter('en-AU', \NumberFormatter::CURRENCY))->formatCurrency(5, 'IRR')) {
+ $this->markTestSkipped('Old ICU libraries behavior (ICU < 62), skipping this tests');
+ }
$this->assertEquals($expected, helper::get_cost_as_string($amount, $currency, $surcharge));
}
}
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 0a152257a9d..8b06d4059a1 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -202,6 +202,9 @@
contentbank/tests
+
+ payment/tests
+