From 2d9d7b3a4eed40078c9c97f5fc4be6e807166900 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Fri, 7 Jul 2023 09:05:55 +1000 Subject: [PATCH] [REF] dev/core#4418 Add in Unit test of submitting the form to ensure no double handling escaping Remove deprecation notice as per coleman Minor fixes to match the form better --- CRM/Financial/BAO/PaymentProcessor.php | 1 - .../CRM/Admin/Form/PaymentProcessorTest.php | 40 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 tests/phpunit/CRM/Admin/Form/PaymentProcessorTest.php diff --git a/CRM/Financial/BAO/PaymentProcessor.php b/CRM/Financial/BAO/PaymentProcessor.php index 4a316ef147..b46df53a76 100644 --- a/CRM/Financial/BAO/PaymentProcessor.php +++ b/CRM/Financial/BAO/PaymentProcessor.php @@ -79,7 +79,6 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces * @return self|null */ public static function retrieve($params, &$defaults) { - CRM_Core_Error::deprecatedFunctionWarning('API'); return self::commonRetrieve(self::class, $params, $defaults); } diff --git a/tests/phpunit/CRM/Admin/Form/PaymentProcessorTest.php b/tests/phpunit/CRM/Admin/Form/PaymentProcessorTest.php new file mode 100644 index 0000000000..b4e4c17180 --- /dev/null +++ b/tests/phpunit/CRM/Admin/Form/PaymentProcessorTest.php @@ -0,0 +1,40 @@ +createAuthorizeNetProcessor(); + $this->paymentProcessorAuthorizeNetCreate(); + $_REQUEST['id'] = $this->ids['PaymentProcessor']['anet']; + $form = new CRM_Admin_Form_PaymentProcessor(NULL, CRM_Core_Action::UPDATE); + $form->controller = new CRM_Core_Controller(); + $pageName = $form->getName(); + $form->controller->setStateMachine(new CRM_Core_StateMachine($form->controller)); + $form->preProcess(); + $paymentProcessor = $this->callAPISuccess('PaymentProcessor', 'getSingle', ['id' => $form->_id]); + $form->updatePaymentProcessor(array_merge($paymentProcessor, [ + 'accept_credit_cards' => [ + 'Visa' => 1, + 'MasterCard' => 1, + ], + 'financial_account_id' => CRM_Financial_BAO_PaymentProcessor::getDefaultFinancialAccountID(), + ]), 1, 0); + $this->assertEquals([ + 'Visa' => 'Visa', + 'MasterCard' => 'MasterCard', + ], PaymentProcessor::get()->addWhere('id', '=', $form->_id)->execute()->first()['accepted_credit_cards']); + } + +} -- 2.25.1