dev/core#2749 remove exception when no payment processor configuredhen no payment...
authorEileen McNaughton <emcnaughton@wikimedia.org>
Wed, 11 Aug 2021 22:43:52 +0000 (10:43 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 12 Aug 2021 00:38:15 +0000 (12:38 +1200)
This is an attempt to fix a regression https://lab.civicrm.org/dev/core/-/issues/2749
when there are legitimately no payment processors assigned to a page.

I feel like the configuration screens are adequate to enforce this & having an exception like
this in the assign function is the wrong place.

The original issue is that the is_monetary box was not checked & hence the
processor wasn't assigned. This felt like asking users to understand that
a payment method when money options are configured

CRM/Core/Form.php
tests/phpunit/CRM/Contribute/Form/ContributionTest.php

index 32f9ec17fcc585626c8e4283da59d17952fa7614..0f07bdd1496c995d7e380f214a6f447f1ed0010b 100644 (file)
@@ -848,9 +848,6 @@ class CRM_Core_Form extends HTML_QuickForm_Page {
       // It's not clear why we set this on the form.
       $this->set('paymentProcessors', $this->_paymentProcessors);
     }
-    else {
-      throw new CRM_Core_Exception(ts('A payment processor configured for this page might be disabled (contact the site administrator for assistance).'));
-    }
   }
 
   /**
index 5983e3cdb62968391c773469aef63bb6d5c3a204..07e205dc64da27f9ae43dafbb091d15b9283149b 100644 (file)
@@ -1371,10 +1371,10 @@ Price Field - Price Field 1        1   $ 100.00      $ 100.00
    * @throws \CRM_Core_Exception
    * @throws \CRM_Contribute_Exception_InactiveContributionPageException
    */
-  public function testContributionBasePreProcess() {
+  public function testContributionBasePreProcess(): void {
     //Create contribution page with only pay later enabled.
     $params = [
-      'title' => "Test Contribution Page",
+      'title' => 'Test Contribution Page',
       'financial_type_id' => 1,
       'currency' => 'NZD',
       'goal_amount' => 100,
@@ -1387,7 +1387,7 @@ Price Field - Price Field 1        1   $ 100.00      $ 100.00
       'receipt_from_name' => 'Ego Freud',
     ];
 
-    $page1 = $this->callAPISuccess("contribution_page", 'create', $params);
+    $page1 = $this->callAPISuccess('ContributionPage', 'create', $params);
 
     //Execute CRM_Contribute_Form_ContributionBase preProcess
     //and check the assignment of payment processors
@@ -1397,25 +1397,18 @@ Price Field - Price Field 1        1   $ 100.00      $ 100.00
     $_REQUEST['id'] = $page1['id'];
 
     $form->preProcess();
-    $this->assertEquals($form->_paymentProcessor['name'], 'pay_later');
+    $this->assertEquals('pay_later', $form->_paymentProcessor['name']);
 
     //Disable all the payment processor for the contribution page.
     $params['is_pay_later'] = 0;
-    $page2 = $this->callAPISuccess("contribution_page", 'create', $params);
+    $page2 = $this->callAPISuccess('ContributionPage', 'create', $params);
 
     //Assert an exception is thrown on loading the contribution page.
     $form = new CRM_Contribute_Form_ContributionBase();
     $form->controller = new CRM_Core_Controller();
     $_REQUEST['id'] = $page2['id'];
     $form->set('id', $page2['id']);
-    try {
-      $form->preProcess();
-    }
-    catch (CRM_Core_Exception $e) {
-      $this->assertStringContainsString("A payment processor configured for this page might be disabled (contact the site administrator for assistance).", $e->getMessage());
-      return;
-    }
-    $this->fail('Exception was expected');
+    $form->preProcess();
   }
 
   /**