dev/core#4833 Add unit test for legacy invoice number format
authorSeamus Lee <seamuslee001@gmail.com>
Thu, 7 Dec 2023 23:11:52 +0000 (10:11 +1100)
committerSeamus Lee <seamuslee001@gmail.com>
Thu, 7 Dec 2023 23:20:29 +0000 (10:20 +1100)
tests/phpunit/CRM/Core/Payment/AuthorizeNetIPNTest.php

index a5b03da146510ce5bfa43ba5e0cf1f4bdc7a6060..c779cbe94201d8944931eb4ee9b5c9d7910ce1f7 100644 (file)
@@ -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.
    *