From 0be69b5c0681e8b7b046e851ee75277e897d9022 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Mon, 2 Aug 2021 12:33:29 +1200 Subject: [PATCH] dev/core#2719 [REF] Remove a couple more (tested) references to legacy contribution_invoice_settings --- CRM/Contribute/BAO/Contribution.php | 11 ++++------- CRM/Event/Form/Participant.php | 2 +- tests/phpunit/CRM/Core/Payment/PayPalIPNTest.php | 2 +- tests/phpunit/CiviTest/CiviUnitTestCase.php | 16 ++++++++-------- tests/phpunit/api/v3/ContributionPageTest.php | 9 +++------ 5 files changed, 17 insertions(+), 23 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 0018c801ba..d4a199ebad 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -5164,14 +5164,11 @@ LIMIT 1;"; * * @param int $contributionID * - * @return string + * @return string|null */ - public static function getInvoiceNumber($contributionID) { - if ($invoicePrefix = self::checkContributeSettings('invoice_prefix')) { - return $invoicePrefix . $contributionID; - } - - return NULL; + public static function getInvoiceNumber(int $contributionID): ?string { + $invoicePrefix = Civi::settings()->get('invoice_prefix'); + return $invoicePrefix ? $invoicePrefix . $contributionID : NULL; } /** diff --git a/CRM/Event/Form/Participant.php b/CRM/Event/Form/Participant.php index 6430268729..65982e3cdb 100644 --- a/CRM/Event/Form/Participant.php +++ b/CRM/Event/Form/Participant.php @@ -1546,7 +1546,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment ); $prefixValue = Civi::settings()->get('contribution_invoice_settings'); $invoicing = $prefixValue['invoicing'] ?? NULL; - if (!empty($taxAmt) && (isset($invoicing) && isset($prefixValue['is_email_pdf']))) { + if (!empty($taxAmt) && (isset($invoicing) && Civi::settings()->get('invoice_is_email_pdf'))) { $sendTemplateParams['isEmailPdf'] = TRUE; $sendTemplateParams['contributionId'] = $contributionId; } diff --git a/tests/phpunit/CRM/Core/Payment/PayPalIPNTest.php b/tests/phpunit/CRM/Core/Payment/PayPalIPNTest.php index e38822626e..e54eef3fd5 100644 --- a/tests/phpunit/CRM/Core/Payment/PayPalIPNTest.php +++ b/tests/phpunit/CRM/Core/Payment/PayPalIPNTest.php @@ -65,7 +65,7 @@ class CRM_Core_Payment_PayPalIPNTest extends CiviUnitTestCase { * * @throws \CRM_Core_Exception */ - public function testInvoiceSentOnIPNPaymentSuccess() { + public function testInvoiceSentOnIPNPaymentSuccess(): void { $this->enableTaxAndInvoicing(); $pendingStatusID = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending'); diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index e9146279d4..d3dfb75fa5 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -3073,24 +3073,24 @@ VALUES * Enable Tax and Invoicing * * @param array $params - * - * @return \Civi\Core\SettingsBag */ - protected function enableTaxAndInvoicing($params = []) { + protected function enableTaxAndInvoicing(array $params = []): void { // Enable component contribute setting $contributeSetting = array_merge($params, [ 'invoicing' => 1, 'invoice_prefix' => 'INV_', - 'due_date' => 10, - 'due_date_period' => 'days', - 'notes' => '', - 'is_email_pdf' => 1, + 'invoice_due_date' => 10, + 'invoice_due_date_period' => 'days', + 'invoice_notes' => '', + 'invoice_is_email_pdf' => 1, 'tax_term' => 'Sales Tax', 'tax_display_settings' => 'Inclusive', ] ); - return Civi::settings()->set('contribution_invoice_settings', $contributeSetting); + foreach ($contributeSetting as $setting => $value) { + Civi::settings()->set($setting, $value); + } } /** diff --git a/tests/phpunit/api/v3/ContributionPageTest.php b/tests/phpunit/api/v3/ContributionPageTest.php index f4f7a66abc..596354fc4b 100644 --- a/tests/phpunit/api/v3/ContributionPageTest.php +++ b/tests/phpunit/api/v3/ContributionPageTest.php @@ -52,8 +52,6 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { /** * Setup for test. - * - * @throws \CiviCRM_API3_Exception */ public function setUp(): void { parent::setUp(); @@ -113,7 +111,6 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { * @param int $version * * @dataProvider versionThreeAndFour - * @throws \CRM_Core_Exception */ public function testGetBasicContributionPage(int $version): void { $this->_apiversion = $version; @@ -129,8 +126,6 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { /** * Test get with amount as a parameter. - * - * @throws \CRM_Core_Exception */ public function testGetContributionPageByAmount(): void { $createResult = $this->callAPISuccess($this->_entity, 'create', $this->params); @@ -1702,11 +1697,13 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { * Contribution total = 3723.05 * made up of tax 337.55 * non tax 3385.5 + * * @param string $thousandSeparator * punctuation used to refer to thousands. * - * @dataProvider getThousandSeparators + * @throws \API_Exception * @throws \CRM_Core_Exception + * @dataProvider getThousandSeparators */ public function testSubmitContributionPageWithPriceSetQuantity(string $thousandSeparator): void { $this->setCurrencySeparators($thousandSeparator); -- 2.25.1