From 6d7bea88ae6892db3edbae6b5be459bf58aa199a Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Fri, 8 Dec 2023 10:11:52 +1100 Subject: [PATCH] dev/core#4833 Add unit test for legacy invoice number format --- .../CRM/Core/Payment/AuthorizeNetIPNTest.php | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/phpunit/CRM/Core/Payment/AuthorizeNetIPNTest.php b/tests/phpunit/CRM/Core/Payment/AuthorizeNetIPNTest.php index a5b03da146..c779cbe942 100644 --- a/tests/phpunit/CRM/Core/Payment/AuthorizeNetIPNTest.php +++ b/tests/phpunit/CRM/Core/Payment/AuthorizeNetIPNTest.php @@ -431,6 +431,40 @@ class CRM_Core_Payment_AuthorizeNetIPNTest extends CiviUnitTestCase { $mut->clearMessages(); } + /** + * Test Legacy ARB Invoice Num format + * dev/core#4833 + */ + public function testLegacyInvoiceNum(): void { + CRM_Core_BAO_ConfigSetting::enableComponent('CiviCampaign'); + $this->setupRecurringPaymentProcessorTransaction([ + 'installments' => 3, + ], []); + $this->assertRecurStatus('Pending'); + + $IPN = new CRM_Core_Payment_AuthorizeNetIPN($this->getRecurTransaction()); + $IPN->main(); + $this->assertRecurStatus('In Progress'); + $contribution = $this->callAPISuccess('Contribution', 'getsingle', ['id' => $this->ids['Contribution']['default']]); + $this->assertEquals(1, $contribution['contribution_status_id']); + $this->assertEquals('6511143069', $contribution['trxn_id']); + // source gets set by processor + $this->assertSame(strpos($contribution['contribution_source'], 'Online Contribution:'), 0); + $this->callAPISuccess('Contribution', 'create', [ + 'id' => $this->ids['Contribution']['default'], + 'trxn_id' => '512def29489e1bdc8856,6511143069', + ]); + + $this->assertRecurStatus('In Progress'); + $IPN = new CRM_Core_Payment_AuthorizeNetIPN(array_merge(['receive_date' => '2010-07-01'], $this->getRecurSubsequentTransaction(['x_invoice_num' => '512def29489e1bdc8856']))); + $IPN->main(); + $contribution = $this->callAPISuccess('contribution', 'get', [ + 'contribution_recur_id' => $this->_contributionRecurID, + 'sequential' => 1, + ]); + $this->assertEquals(2, $contribution['count']); + } + /** * Get detail for recurring transaction. * -- 2.25.1