[REF] dev/core#4418 Add in Unit test of submitting the form to ensure no double handl...
authorSeamus Lee <seamuslee001@gmail.com>
Thu, 6 Jul 2023 23:05:55 +0000 (09:05 +1000)
committerSeamus Lee <seamuslee001@gmail.com>
Fri, 7 Jul 2023 00:31:07 +0000 (10:31 +1000)
Remove deprecation notice as per coleman

Minor fixes to match the form better

CRM/Financial/BAO/PaymentProcessor.php
tests/phpunit/CRM/Admin/Form/PaymentProcessorTest.php [new file with mode: 0644]

index 4a316ef1478ec2ab5e5375914a952ac620798533..b46df53a76dbda1dd464adfa9b086da3d1a56e46 100644 (file)
@@ -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 (file)
index 0000000..b4e4c17
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+
+use Civi\APi4\PaymentProcessor;
+
+/**
+ * @group headless
+ */
+class CRM_Admin_Form_PaymentProcessorTest extends CiviUnitTestCase {
+
+  use CRM_Core_Payment_AuthorizeNetTrait;
+
+  /**
+   * Test that saving accept credit card field doesn't double json encode.
+   *
+   * @throws \CRM_Core_Exception
+   */
+  public function testUpdateAcceptCreditCard(): void {
+    $this->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']);
+  }
+
+}