From 576c8a85880d6c19426be236466a21f6bb3f0f61 Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 9 Apr 2019 13:56:09 +1200 Subject: [PATCH] Improve flushing after creating a processor so it can be used for a recurring in the same run Mostly affects tests.... --- Civi/Payment/System.php | 2 ++ tests/phpunit/api/v3/PaymentProcessorTest.php | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/Civi/Payment/System.php b/Civi/Payment/System.php index 536ed52048..44047cdc41 100644 --- a/Civi/Payment/System.php +++ b/Civi/Payment/System.php @@ -137,6 +137,8 @@ class System { if (isset(\Civi::$statics['CRM_Contribute_BAO_ContributionRecur'])) { unset(\Civi::$statics['CRM_Contribute_BAO_ContributionRecur']); } + \CRM_Core_PseudoConstant::flush('paymentProcessor'); + civicrm_api3('PaymentProcessor', 'getfields', ['cache_clear' => 1]); \CRM_Financial_BAO_PaymentProcessor::getAllPaymentProcessors('all', TRUE); \CRM_Financial_BAO_PaymentProcessor::getAllPaymentProcessors('live', TRUE); \CRM_Financial_BAO_PaymentProcessor::getAllPaymentProcessors('test', TRUE); diff --git a/tests/phpunit/api/v3/PaymentProcessorTest.php b/tests/phpunit/api/v3/PaymentProcessorTest.php index 4faf20e9f7..c3e16b9a07 100644 --- a/tests/phpunit/api/v3/PaymentProcessorTest.php +++ b/tests/phpunit/api/v3/PaymentProcessorTest.php @@ -74,6 +74,15 @@ class api_v3_PaymentProcessorTest extends CiviUnitTestCase { $params = $this->_params; $result = $this->callAPIAndDocument('payment_processor', 'create', $params, __FUNCTION__, __FILE__); $this->callAPISuccessGetSingle('EntityFinancialAccount', ['entity_table' => 'civicrm_payment_processor', 'entity_id' => $result['id']]); + + // Test that the option values are flushed so ths can be used straight away. + $this->callAPISuccess('ContributionRecur', 'create', [ + 'contact_id' => $this->individualCreate(), + 'amount' => 5, + 'financial_type_id' => 'Donation', + 'payment_processor_id' => 'API Test PP', + 'frequency_interval' => 1, + ]); $this->getAndCheck($params, $result['id'], 'PaymentProcessor'); } -- 2.25.1