mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
MDL-73278 phpunit: Add missing payment subsystem and fix dataprovider
While testing the changed unit tests one by one, the payment/tests/helper_test.php was failing because of a mismatch between the dataProvider data and the param type. That made me think why that error was not popping in complete runs and the answer is that the new (3.10) subsystem is not in the phpunit.xml.dist file. Hence, adding it and fixing the dataProvider mismatch. Finally, it has been detected that some old ICU versions (< 62) have an incorrect behaviour, not adding the required non-breaking white-space between the currency abbreviation and the value. So we are skipping some payment tests if that's found.
This commit is contained in:
parent
3a08925b79
commit
935742572d
2 changed files with 18 additions and 1 deletions
|
@ -169,7 +169,7 @@ class helper_test extends advanced_testcase {
|
||||||
* @param float $surcharge
|
* @param float $surcharge
|
||||||
* @param string $expected
|
* @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));
|
$this->assertEquals($expected, helper::get_rounded_cost($amount, $currency, $surcharge));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,6 +183,20 @@ class helper_test extends advanced_testcase {
|
||||||
* @param string $expected
|
* @param string $expected
|
||||||
*/
|
*/
|
||||||
public function test_get_cost_as_string(float $amount, string $currency, float $surcharge, 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));
|
$this->assertEquals($expected, helper::get_cost_as_string($amount, $currency, $surcharge));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,6 +202,9 @@
|
||||||
<testsuite name="core_contentbank_testsuite">
|
<testsuite name="core_contentbank_testsuite">
|
||||||
<directory suffix="_test.php">contentbank/tests</directory>
|
<directory suffix="_test.php">contentbank/tests</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
|
<testsuite name="core_payment_testsuite">
|
||||||
|
<directory suffix="_test.php">payment/tests</directory>
|
||||||
|
</testsuite>
|
||||||
|
|
||||||
<!--Plugin suites: use admin/tool/phpunit/cli/util.php to build phpunit.xml from
|
<!--Plugin suites: use admin/tool/phpunit/cli/util.php to build phpunit.xml from
|
||||||
phpunit.xml.dist with up-to-date list of plugins in current install-->
|
phpunit.xml.dist with up-to-date list of plugins in current install-->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue