+--------------------------------------------------------------------+
*/
+use Civi\Api4\PaymentProcessor;
/**
* Class CRM_Financial_BAO_PaymentProcessorTypeTest
* @group headless
/**
* Test the processor retrieval function.
*
+ * @throws \API_Exception
* @throws \CiviCRM_API3_Exception
+ * @throws \Civi\API\Exception\UnauthorizedException
*/
public function testGetProcessors() {
$testProcessor = $this->dummyProcessorCreate();
$processors = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors(['BackOffice', 'LiveMode'], [$liveProcessorID]);
$this->assertEquals([$liveProcessorID], array_keys($processors), 'Only the Live processor should be returned');
+
+ PaymentProcessor::update()->addWhere('id', 'IS NOT NULL')->setValues(['domain_id' => 2])->execute();
+ $processors = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors(['BackOffice', 'LiveMode'], [$liveProcessorID]);
+ $this->assertEquals([$liveProcessorID], array_keys($processors), 'Live processor should still be returned even though it is on a different domain');
+
+ // The api won't permit disabling only live mode due to lack of integrity so use direct SQL
+ CRM_Core_DAO::executeQuery('UPDATE civicrm_payment_processor SET is_active = 0 WHERE is_test = 0');
+ Civi\Payment\System::singleton()->flushProcessors();
+ $processors = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors(['BackOffice', 'LiveMode'], [$liveProcessorID]);
+ $this->assertEquals([], array_keys($processors), 'Live processor should not be returned as it is inactive');
+
+ CRM_Core_DAO::executeQuery('UPDATE civicrm_payment_processor SET is_active = 0 WHERE is_test = 0');
+ $processors = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors(['BackOffice', 'TestMode'], [$testProcessorID]);
+ $this->assertEquals([$testProcessorID], array_keys($processors), 'The test processor should still be returned');
+
}
/**
$processors = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors(['NoEmailProvided']);
$found = FALSE;
foreach ($processors as $processor) {
- if ($processor['class_name'] == 'Payment_Manual') {
+ if ($processor['class_name'] === 'Payment_Manual') {
$found = TRUE;
continue;
}