$this->assertEquals($cards, $expectedCards, 'Verify correct credit card types are returned');
}
+ /**
+ * Test the processor retrieval function.
+ *
+ * @throws \CiviCRM_API3_Exception
+ */
+ public function testGetProcessors() {
+ $testProcessor = $this->dummyProcessorCreate();
+ $testProcessorID = $testProcessor->getID();
+ $liveProcessorID = $testProcessorID + 1;
+
+ $processors = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors(['BackOffice', 'TestMode']);
+ $this->assertEquals([$testProcessorID, 0], array_keys($processors), 'Only the test processor and the manual processor should be returned');
+
+ $processors = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors(['BackOffice', 'TestMode'], [$liveProcessorID]);
+ $this->assertEquals([$testProcessorID], array_keys($processors), 'Only the test processor should be returned');
+
+ $processors = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors(['BackOffice', 'TestMode'], [$testProcessorID]);
+ $this->assertEquals([$testProcessorID], array_keys($processors), 'Only the test processor should be returned');
+
+ $processors = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors(['BackOffice', 'LiveMode']);
+ $this->assertEquals([$liveProcessorID, 0], array_keys($processors), 'Only the Live processor and the manual processor should be returned');
+
+ $processors = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors(['BackOffice', 'LiveMode'], [$liveProcessorID]);
+ $this->assertEquals([$liveProcessorID], array_keys($processors), 'Only the Live processor should be returned');
+
+ }
+
}
*
* @return \CRM_Core_Payment_Dummy
* Instance of Dummy Payment Processor
+ *
+ * @throws \CiviCRM_API3_Exception
*/
- public function dummyProcessorCreate($processorParams = array()) {
+ public function dummyProcessorCreate($processorParams = []) {
$paymentProcessorID = $this->processorCreate($processorParams);
+ // For the tests we don't need a live processor, but as core ALWAYS creates a processor in live mode and one in test mode we do need to create both
+ // Otherwise we are testing a scenario that only exists in tests (and some tests fail because the live processor has not been defined).
+ $processorParams['is_test'] = FALSE;
+ $this->processorCreate($processorParams);
return System::singleton()->getById($paymentProcessorID);
}