diff --git a/CRM/Core/Smarty/plugins/modifier.crmMoney.php b/CRM/Core/Smarty/plugins/modifier.crmMoney.php index c2ec12cadf70..cc403067890f 100644 --- a/CRM/Core/Smarty/plugins/modifier.crmMoney.php +++ b/CRM/Core/Smarty/plugins/modifier.crmMoney.php @@ -20,7 +20,7 @@ * * @param float $amount * The monetary amount up for display. - * @param string $currency + * @param string|null $currency * The (optional) currency. * * @return string @@ -28,6 +28,6 @@ * * @throws \CRM_Core_Exception */ -function smarty_modifier_crmMoney($amount, $currency = NULL) { - return CRM_Utils_Money::format($amount, $currency); +function smarty_modifier_crmMoney($amount, ?string $currency = NULL): string { + return Civi::format()->money($amount, $currency); } diff --git a/tests/phpunit/CRM/Contact/Page/View/UserDashBoardTest.php b/tests/phpunit/CRM/Contact/Page/View/UserDashBoardTest.php index 7ba28448b5c9..f85200729e6f 100644 --- a/tests/phpunit/CRM/Contact/Page/View/UserDashBoardTest.php +++ b/tests/phpunit/CRM/Contact/Page/View/UserDashBoardTest.php @@ -137,10 +137,9 @@ public function testDashboardContentContributionsWithInvoicingEnabled(): void { /** * Test the content of the dashboard. * - * @throws \CRM_Core_Exception * @throws \CiviCRM_API3_Exception */ - public function testDashboardContentContributions() { + public function testDashboardContentContributions(): void { $this->contributionCreate(['contact_id' => $this->contactID]); $this->contributions[] = civicrm_api3('Contribution', 'get', [ 'contact_id' => $this->contactID, @@ -151,7 +150,7 @@ public function testDashboardContentContributions() { $expectedStrings = [ 'Your Contribution(s)', '', - '', + '', '', ]; $this->assertPageContains($expectedStrings); @@ -183,8 +182,8 @@ public function testDashboardPartialPayments() { $expectedStrings = [ 'Your Contribution(s)', '
Total AmountFinancial TypeReceived dateReceipt SentBalanceStatus$ 100.00 Donation$100.00 DonationCompleted
', - '', - '', + '', + '', 'Pay Now', ]; $this->assertPageContains($expectedStrings); diff --git a/tests/phpunit/CRM/Contribute/Form/AdditionalPaymentTest.php b/tests/phpunit/CRM/Contribute/Form/AdditionalPaymentTest.php index 72a8b8af456f..b93b6daaff5f 100644 --- a/tests/phpunit/CRM/Contribute/Form/AdditionalPaymentTest.php +++ b/tests/phpunit/CRM/Contribute/Form/AdditionalPaymentTest.php @@ -146,9 +146,9 @@ public function testAddPaymentUsingCreditCardForPartiallyPaidContribution() { 'From: site@something.com', 'Dear Anthony,', 'Payment Details', - 'Total Fee: $ 100.00', - 'This Payment Amount: $ 70.00', - 'Balance Owed: $ 0.00 ', + 'Total Fee: $100.00', + 'This Payment Amount: $70.00', + 'Balance Owed: $0.00 ', 'Billing Name and Address', 'Vancouver, AE 1321312', 'Visa', @@ -180,7 +180,7 @@ public function testAddPaymentForPartiallyPaidContribution() { * @throws \CRM_Core_Exception * @throws \CiviCRM_API3_Exception */ - public function testMultiplePaymentForPartiallyPaidContribution() { + public function testMultiplePaymentForPartiallyPaidContribution(): void { $this->createPartiallyPaidOrder(); // pay additional amount @@ -236,9 +236,9 @@ public function testMultiplePaymentForPartiallyPaidContributionWithOneCreditCard $mut->checkMailLog([ 'Dear Anthony,', 'Below you will find a receipt for this payment.', - 'Total Fee: $ 100.00', - 'This Payment Amount: $ 50.00', - 'Balance Owed: $ 20.00 ', + 'Total Fee: $100.00', + 'This Payment Amount: $50.00', + 'Balance Owed: $20.00 ', 'Paid By: Check', 'Check Number: check-12345', ], @@ -266,9 +266,9 @@ public function testAddPaymentUsingCreditCardForPendingPayLaterContribution() { $mut->checkMailLog([ 'Below you will find a receipt for this payment.', - 'Total Fee: $ 100.00', - 'This Payment Amount: $ 100.00', - 'Balance Owed: $ 0.00 ', + 'Total Fee: $100.00', + 'This Payment Amount: $100.00', + 'Balance Owed: $0.00 ', 'Paid By: Credit Card', '***********1111', 'Billing Name and Address', diff --git a/tests/phpunit/CRM/Contribute/Form/Task/InvoiceTest.php b/tests/phpunit/CRM/Contribute/Form/Task/InvoiceTest.php index 50bd78df9a9e..fda6462b287a 100644 --- a/tests/phpunit/CRM/Contribute/Form/Task/InvoiceTest.php +++ b/tests/phpunit/CRM/Contribute/Form/Task/InvoiceTest.php @@ -77,7 +77,7 @@ public function testInvoiceForDueDate() { $this->assertStringContainsString('PAYMENT ADVICE', $invoiceHTML[$contribution['id']]); $this->assertStringContainsString('AMOUNT DUE: - ', $invoiceHTML[$contribution3['id']]); + ', $invoiceHTML[$contribution3['id']]); } /** @@ -86,7 +86,7 @@ public function testInvoiceForDueDate() { * * @throws \CRM_Core_Exception */ - public function testInvoiceForLineItems() { + public function testInvoiceForLineItems(): void { $this->enableTaxAndInvoicing(); @@ -154,12 +154,12 @@ public function testInvoiceForLineItems() { $lineItems = $this->callAPISuccess('LineItem', 'get', ['contribution_id' => $order['id']]); foreach ($lineItems['values'] as $lineItem) { - $this->assertStringContainsString("$ {$lineItem['line_total']}", $invoiceHTML); + $this->assertStringContainsString("$" . $lineItem['line_total'] . '', $invoiceHTML); } $totalAmount = $this->formatMoneyInput($order['values'][$order['id']]['total_amount']); $this->assertStringContainsString("TOTAL USD - - + diff --git a/tests/phpunit/CRM/Core/Payment/AuthorizeNetIPNTest.php b/tests/phpunit/CRM/Core/Payment/AuthorizeNetIPNTest.php index c8aa73955bed..a3a63e583906 100644 --- a/tests/phpunit/CRM/Core/Payment/AuthorizeNetIPNTest.php +++ b/tests/phpunit/CRM/Core/Payment/AuthorizeNetIPNTest.php @@ -297,7 +297,7 @@ public function testIPNPaymentMembershipRecurSuccessNoLeakage(): void { $mut->checkAllMailLog([ 'Membership Type: General', 'Mr. Anthony Anderson II" ', - 'Amount: $ 200.00', + 'Amount: $200.00', 'Membership Start Date:', 'Supporter Profile', 'First Name: Anthony', @@ -323,7 +323,7 @@ public function testIPNPaymentMembershipRecurSuccessNoLeakage(): void { 'Membership Type: General', 'Mrs. Antonia Anderson II', 'antonia_anderson@civicrm.org', - 'Amount: $ 200.00', + 'Amount: $200.00', 'Membership Start Date:', 'Transaction #: hers', 'Supporter Profile', @@ -363,7 +363,7 @@ public function testIPNPaymentMembershipRecurSuccessNoLeakageOnlineThenOffline() $mut->checkAllMailLog([ 'Membership Type: General', 'Mr. Anthony Anderson II" ', - 'Amount: $ 200.00', + 'Amount: $200.00', 'Membership Start Date:', 'Supporter Profile', 'First Name: Anthony', @@ -387,7 +387,7 @@ public function testIPNPaymentMembershipRecurSuccessNoLeakageOnlineThenOffline() 'Membership Type: General', 'Mrs. Antonia Anderson II', 'antonia_anderson@civicrm.org', - 'Amount: $ 200.00', + 'Amount: $200.00', 'Membership Start Date:', 'Transaction #: hers', 'This membership will be automatically renewed every', diff --git a/tests/phpunit/CRM/Member/Form/MembershipTest.php b/tests/phpunit/CRM/Member/Form/MembershipTest.php index 9fac1535b262..fa7c3a144c37 100644 --- a/tests/phpunit/CRM/Member/Form/MembershipTest.php +++ b/tests/phpunit/CRM/Member/Form/MembershipTest.php @@ -80,9 +80,6 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { * * Connect to the database, truncate the tables that will be used * and redirect stdin to a temporary file. - * - * @throws \CRM_Core_Exception - * @throws \CiviCRM_API3_Exception */ public function setUp(): void { $this->_apiversion = 3; @@ -567,7 +564,7 @@ public function testSubmit(string $thousandSeparator): void { ]), ], 'online'); $this->mut->checkMailLog([ - CRM_Utils_Money::format('1234.56'), + Civi::format()->money('1234.56'), 'Receipt text', ]); $this->mut->stop(); @@ -1269,11 +1266,13 @@ public function buildAmountMembershipDiscount($pageType, &$form, &$amount) { * * @return \CRM_Member_Form_Membership * @throws \CRM_Core_Exception + * @throws \CiviCRM_API3_Exception */ - protected function getForm($formValues = []) { + protected function getForm($formValues = []): CRM_Member_Form_Membership { if (isset($_REQUEST['cid'])) { unset($_REQUEST['cid']); } + /* @var CRM_Member_Form_Membership $form*/ $form = $this->getFormObject('CRM_Member_Form_Membership', $formValues); $form->preProcess(); return $form; diff --git a/tests/phpunit/api/v3/ContributionPageTest.php b/tests/phpunit/api/v3/ContributionPageTest.php index f4425dc0ff26..6f1241a8171d 100644 --- a/tests/phpunit/api/v3/ContributionPageTest.php +++ b/tests/phpunit/api/v3/ContributionPageTest.php @@ -476,7 +476,7 @@ public function testSubmitMembershipBlockIsSeparatePaymentPayLaterWithEmail(): v $this->assertCount(2, $contributions); $this->callAPISuccess('membership_payment', 'getsingle', ['contribution_id' => ['IN' => array_keys($contributions)]]); $mut->checkMailLog([ - 'Membership Amount -... $ 2.00', + 'Membership Amount -... $2.00', ]); $mut->stop(); $mut->clearMessages(); @@ -555,8 +555,8 @@ public function testSubmitMembershipBlockIsSeparatePaymentWithEmail(): void { // line and no total line. $mut->checkAllMailLog( [ - 'Amount: $ 2.00', - 'Amount: $ 88.00', + 'Amount: $2.00', + 'Amount: $88.00', 'Membership Fee', ], [ @@ -591,7 +591,7 @@ public function testSubmitMembershipBlockIsSeparatePaymentZeroDollarsPayLaterWit $this->assertEquals($membership['contact_id'], $contributions[$membershipPayment['contribution_id']]['contact_id']); $mut->checkMailLog([ 'Gruff', - 'General Membership: $ 0.00', + 'General Membership: $0.00', 'Membership Fee', ]); $mut->stop(); @@ -662,7 +662,7 @@ public function testSubmitMembershipBlockIsSeparatePaymentPaymentProcessorNow(): } // The total string is currently absent & it seems worse with - although at some point // it may have been intended - $mut->checkAllMailLog(['$ 2.00', 'Contribution Amount', '$ 88.00'], ['Total:']); + $mut->checkAllMailLog(['$2.00', 'Contribution Amount', '$88.00'], ['Total:']); $mut->stop(); $mut->clearMessages(); } diff --git a/tests/phpunit/api/v3/ContributionTest.php b/tests/phpunit/api/v3/ContributionTest.php index 0fc48fdca917..1bc6d985deea 100644 --- a/tests/phpunit/api/v3/ContributionTest.php +++ b/tests/phpunit/api/v3/ContributionTest.php @@ -3652,7 +3652,7 @@ public function testSendMail(): void { 'receipt_from_email' => 'api@civicrm.org', ]); $mut->checkMailLog([ - '$ 100.00', + '$100.00', 'Contribution Information', ], [ 'Event', diff --git a/tests/phpunit/api/v3/PaymentTest.php b/tests/phpunit/api/v3/PaymentTest.php index 8638b5175d71..fa0de30c329e 100644 --- a/tests/phpunit/api/v3/PaymentTest.php +++ b/tests/phpunit/api/v3/PaymentTest.php @@ -219,7 +219,7 @@ public function testPaymentSendContributionReceipt(): void { $contribution = $this->callAPISuccessGetSingle('Contribution', ['id' => $contribution['id']]); $this->assertNotEmpty($contribution['receipt_date']); $mut->checkMailLog([ - 'Price Field - Price Field 1 1 $ 100.00 $ 100.00', + 'Price Field - Price Field 1 1 $100.00 $100.00', 'event place', 'streety street', ]); @@ -293,10 +293,10 @@ public function testPaymentEmailReceipt(): void { $mut->checkMailLog([ 'From: "FIXME" ', 'Dear Anthony,', - 'Total Fee: $ 300.00', - 'This Payment Amount: $ 50.00', + 'Total Fee: $300.00', + 'This Payment Amount: $50.00', //150 was paid in the 1st payment. - 'Balance Owed: $ 100.00', + 'Balance Owed: $100.00', 'Event Information and Location', 'Paid By: Check', 'Check Number: 345', @@ -331,9 +331,9 @@ public function testPaymentEmailReceiptFullyPaid(): void { 'From: "FIXME" ', 'Dear Anthony,', 'Below you will find a receipt for this payment.', - 'Total Fee: $ 300.00', - 'This Payment Amount: $ 150.00', - 'Balance Owed: $ 0.00', + 'Total Fee: $300.00', + 'This Payment Amount: $150.00', + 'Balance Owed: $0.00', 'Thank you for completing this payment.', ]); } @@ -382,12 +382,12 @@ public function testRefundEmailReceipt(string $thousandSeparator): void { $mut->checkMailLog([ 'Dear Anthony,', 'A refund has been issued based on changes in your registration selections.', - 'Total Fee: $ 300' . $decimalSeparator . '00', - 'Refund Amount: $ -30' . $decimalSeparator . '00', + 'Total Fee: $300' . $decimalSeparator . '00', + 'Refund Amount: -$30' . $decimalSeparator . '00', 'Event Information and Location', 'Paid By: Check', 'Transaction Date: November 13th, 2018 12:01 PM', - 'Total Paid: $ 170' . $decimalSeparator . '00', + 'Total Paid: $170' . $decimalSeparator . '00', ]); }
Total AmountFinancial TypeReceived dateReceipt SentBalanceStatus$ 25.00 Donation$ 14.00Partially paid$25.00 Donation$14.00Partially paid$ 92.00$92.00$ $totalAmount", $invoiceHTML); + $" . $totalAmount . '', $invoiceHTML); } @@ -167,10 +167,8 @@ public function testInvoiceForLineItems() { * Test invoices if payment is made with different currency. * * https://lab.civicrm.org/dev/core/issues/2269 - * - * @throws \CRM_Core_Exception */ - public function testThatInvoiceShowTheActuallContributionCurrencyInsteadOfTheDefaultOne() { + public function testThatInvoiceShowsTheActualContributionCurrencyInsteadOfTheDefaultOne(): void { $this->setDefaultCurrency('USD'); $this->_individualId = $this->individualCreate(); @@ -187,8 +185,8 @@ public function testThatInvoiceShowTheActuallContributionCurrencyInsteadOfTheDef $this->assertStringNotContainsString('$', $invoiceHTML); $this->assertStringNotContainsString('Amount USD', $invoiceHTML); $this->assertStringNotContainsString('TOTAL USD', $invoiceHTML); - $this->assertStringContainsString('£ 0.00', $invoiceHTML); - $this->assertStringContainsString('£ 100.00', $invoiceHTML); + $this->assertStringContainsString('£0.00', $invoiceHTML); + $this->assertStringContainsString('£100.00', $invoiceHTML); $this->assertStringContainsString('Amount GBP', $invoiceHTML); $this->assertStringContainsString('TOTAL GBP', $invoiceHTML); diff --git a/tests/phpunit/CRM/Contribute/Form/Task/PDFLetterCommonTest.php b/tests/phpunit/CRM/Contribute/Form/Task/PDFLetterCommonTest.php index b9da6917b9b3..392f7db96715 100644 --- a/tests/phpunit/CRM/Contribute/Form/Task/PDFLetterCommonTest.php +++ b/tests/phpunit/CRM/Contribute/Form/Task/PDFLetterCommonTest.php @@ -449,7 +449,7 @@ public function testPostProcessGroupByContact(): void { -->
25 December 2016$ 100.00$100.00 Donation