Skip to content

Commit

Permalink
Issue 1522: style formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jaapjansma committed Jan 30, 2020
1 parent a897892 commit 80da79b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 23 deletions.
30 changes: 20 additions & 10 deletions tests/phpunit/CRM/Utils/RuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,30 +115,38 @@ public function moneyDataProvider() {
['$1,234,567.89', '.', ',', 'USD', TRUE],
['-$1,234,567.89', '.', ',', 'USD', TRUE],
['$-1,234,567.89', '.', ',', 'USD', TRUE],
['1234567.89', '.', ',', 'USD', TRUE], // This is the float format. Encapsulated in strings
[1234567.89, '.', ',', 'USD', TRUE], // This is the float format.
// This is the float format. Encapsulated in strings
['1234567.89', '.', ',', 'USD', TRUE],
// This is the float format.
[1234567.89, '.', ',', 'USD', TRUE],
// Test EURO currency
['€1,234,567.89', '.', ',', 'EUR', TRUE],
['-€1,234,567.89', '.', ',', 'EUR', TRUE],
['€-1,234,567.89', '.', ',', 'EUR', TRUE],
['1234567.89', '.', ',', 'EUR', TRUE], // This is the float format. Encapsulated in strings
[1234567.89, '.', ',', 'EUR', TRUE], // This is the float format.
// This is the float format. Encapsulated in strings
['1234567.89', '.', ',', 'EUR', TRUE],
// This is the float format.
[1234567.89, '.', ',', 'EUR', TRUE],
// Test Norwegian KR currency
['kr1,234,567.89', '.', ',', 'NOK', TRUE],
['kr 1,234,567.89', '.', ',', 'NOK', TRUE],
['-kr1,234,567.89', '.', ',', 'NOK', TRUE],
['-kr 1,234,567.89', '.', ',', 'NOK', TRUE],
['kr-1,234,567.89', '.', ',', 'NOK', TRUE],
['kr -1,234,567.89', '.', ',', 'NOK', TRUE],
['1234567.89', '.', ',', 'NOK', TRUE], // This is the float format. Encapsulated in strings
[1234567.89, '.', ',', 'NOK', TRUE], // This is the float format.
// This is the float format. Encapsulated in strings
['1234567.89', '.', ',', 'NOK', TRUE],
// This is the float format.
[1234567.89, '.', ',', 'NOK', TRUE],
// Test different localization options: , as decimal separator and dot as thousand separator
['$1.234.567,89', ',', '.', 'USD', TRUE],
['-$1.234.567,89', ',', '.', 'USD', TRUE],
['$-1.234.567,89', ',', '.', 'USD', TRUE],
['1.234.567,89', ',', '.', 'USD', TRUE],
['1234567.89', ',', '.', 'USD', TRUE], // This is the float format. Encapsulated in strings
[1234567.89, ',', '.', 'USD', TRUE], // This is the float format.
// This is the float format. Encapsulated in strings
['1234567.89', ',', '.', 'USD', TRUE],
// This is the float format.
[1234567.89, ',', '.', 'USD', TRUE],
['$1,234,567.89', ',', '.', 'USD', FALSE],
['-$1,234,567.89', ',', '.', 'USD', FALSE],
['$-1,234,567.89', ',', '.', 'USD', FALSE],
Expand All @@ -147,8 +155,10 @@ public function moneyDataProvider() {
['-$1 234 567,89', ',', ' ', 'USD', TRUE],
['$-1 234 567,89', ',', ' ', 'USD', TRUE],
['1 234 567,89', ',', ' ', 'USD', TRUE],
['1234567.89', ',', ' ', 'USD', TRUE], // This is the float format. Encapsulated in strings
[1234567.89, ',', ' ', 'USD', TRUE], // This is the float format.
// This is the float format. Encapsulated in strings
['1234567.89', ',', ' ', 'USD', TRUE],
// This is the float format.
[1234567.89, ',', ' ', 'USD', TRUE],
];
}

Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/CiviTest/CiviUnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3278,7 +3278,7 @@ protected function setMonetaryThousandSeparator($thousandSeparator) {
*
* If you use this function also set the thousand separator setMonetaryDecimalPoint
*
* @param $thousandSeparator
* @param $decimalPoint
*/
protected function setMonetaryDecimalPoint($decimalPoint) {
Civi::settings()->set('monetaryDecimalPoint', $decimalPoint);
Expand Down
35 changes: 23 additions & 12 deletions tests/phpunit/api/v3/ContributionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ public function testGetContributionByTotalAmount() {

/**
* @dataProvider createLocalizedContributionDataProvider
* @param $inputData
* @param $totalAmount
* @param $decimalPoint
* @param $thousandSeparator
* @param $currency
Expand All @@ -729,7 +729,8 @@ public function testCreateLocalizedContribution($totalAmount, $decimalPoint, $th

if ($expectedResult) {
$this->callAPISuccess('Contribution', 'create', $_params);
} else {
}
else {
$this->callAPIFailure('Contribution', 'create', $_params);
}
}
Expand All @@ -755,30 +756,38 @@ public function createLocalizedContributionDataProvider() {
['$1,234,567.89', '.', ',', 'USD', TRUE],
['-$1,234,567.89', '.', ',', 'USD', TRUE],
['$-1,234,567.89', '.', ',', 'USD', TRUE],
['1234567.89', '.', ',', 'USD', TRUE], // This is the float format. Encapsulated in strings
[1234567.89, '.', ',', 'USD', TRUE], // This is the float format.
// This is the float format. Encapsulated in strings
['1234567.89', '.', ',', 'USD', TRUE],
// This is the float format.
[1234567.89, '.', ',', 'USD', TRUE],
// Test EURO currency
['€1,234,567.89', '.', ',', 'EUR', TRUE],
['-€1,234,567.89', '.', ',', 'EUR', TRUE],
['€-1,234,567.89', '.', ',', 'EUR', TRUE],
['1234567.89', '.', ',', 'EUR', TRUE], // This is the float format. Encapsulated in strings
[1234567.89, '.', ',', 'EUR', TRUE], // This is the float format.
// This is the float format. Encapsulated in strings
['1234567.89', '.', ',', 'EUR', TRUE],
// This is the float format.
[1234567.89, '.', ',', 'EUR', TRUE],
// Test Norwegian KR currency
['kr1,234,567.89', '.', ',', 'NOK', TRUE],
['kr 1,234,567.89', '.', ',', 'NOK', TRUE],
['-kr1,234,567.89', '.', ',', 'NOK', TRUE],
['-kr 1,234,567.89', '.', ',', 'NOK', TRUE],
['kr-1,234,567.89', '.', ',', 'NOK', TRUE],
['kr -1,234,567.89', '.', ',', 'NOK', TRUE],
['1234567.89', '.', ',', 'NOK', TRUE], // This is the float format. Encapsulated in strings
[1234567.89, '.', ',', 'NOK', TRUE], // This is the float format.
// This is the float format. Encapsulated in strings
['1234567.89', '.', ',', 'NOK', TRUE],
// This is the float format.
[1234567.89, '.', ',', 'NOK', TRUE],
// Test different localization options: , as decimal separator and dot as thousand separator
['$1.234.567,89', ',', '.', 'USD', TRUE],
['-$1.234.567,89', ',', '.', 'USD', TRUE],
['$-1.234.567,89', ',', '.', 'USD', TRUE],
['1.234.567,89', ',', '.', 'USD', TRUE],
['1234567.89', ',', '.', 'USD', TRUE], // This is the float format. Encapsulated in strings
[1234567.89, ',', '.', 'USD', TRUE], // This is the float format.
// This is the float format. Encapsulated in strings
['1234567.89', ',', '.', 'USD', TRUE],
// This is the float format.
[1234567.89, ',', '.', 'USD', TRUE],
['$1,234,567.89', ',', '.', 'USD', FALSE],
['-$1,234,567.89', ',', '.', 'USD', FALSE],
['$-1,234,567.89', ',', '.', 'USD', FALSE],
Expand All @@ -787,8 +796,10 @@ public function createLocalizedContributionDataProvider() {
['-$1 234 567,89', ',', ' ', 'USD', TRUE],
['$-1 234 567,89', ',', ' ', 'USD', TRUE],
['1 234 567,89', ',', ' ', 'USD', TRUE],
['1234567.89', ',', ' ', 'USD', TRUE], // This is the float format. Encapsulated in strings
[1234567.89, ',', ' ', 'USD', TRUE], // This is the float format.
// This is the float format. Encapsulated in strings
['1234567.89', ',', ' ', 'USD', TRUE],
// This is the float format.
[1234567.89, ',', ' ', 'USD', TRUE],
];
}

Expand Down

0 comments on commit 80da79b

Please sign in to comment.