[REF] Add in Unit test to demonstrate error when trying to import a campaign id int...
authorSeamus Lee <seamuslee001@gmail.com>
Tue, 25 Oct 2022 21:29:55 +0000 (08:29 +1100)
committerSeamus Lee <seamuslee001@gmail.com>
Tue, 25 Oct 2022 21:41:19 +0000 (08:41 +1100)
tests/phpunit/CRM/Contribute/Import/Parser/ContributionTest.php
tests/phpunit/CRM/Contribute/Import/Parser/data/contributions.csv

index 032aeb0cea46c198823abae3c5f919f75f74946e..78203e35faa296e06ffbfa8c51dfefcf616b3c1e 100644 (file)
@@ -530,6 +530,8 @@ class CRM_Contribute_Import_Parser_ContributionTest extends CiviUnitTestCase {
    */
   public function testImportFieldsNotRequiredWithTrxnID(): void {
     $this->individualCreate(['email' => 'mum@example.com']);
+    $this->campaignCreate();
+    $this->callAPISuccess('System', 'flush', []);
     $fieldMappings = [
       ['name' => 'first_name'],
       ['name' => ''],
@@ -539,6 +541,7 @@ class CRM_Contribute_Import_Parser_ContributionTest extends CiviUnitTestCase {
       ['name' => ''],
       ['name' => ''],
       ['name' => 'trxn_id'],
+      ['name' => 'contribution_campaign_id'],
     ];
     // First we try to create without total_amount mapped.
     // It will fail in create mode as total_amount is required for create.
@@ -558,7 +561,7 @@ class CRM_Contribute_Import_Parser_ContributionTest extends CiviUnitTestCase {
     $this->importCSV('contributions.csv', $fieldMappings, ['onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP]);
 
     $row = $this->getDataSource()->getRows()[0];
-    $this->assertEquals('IMPORTED', $row[9]);
+    $this->assertEquals('IMPORTED', $row[10]);
     $contribution = Contribution::get()->addSelect('source', 'id')->execute()->first();
     $this->assertEmpty($contribution['source']);
 
@@ -572,11 +575,12 @@ class CRM_Contribute_Import_Parser_ContributionTest extends CiviUnitTestCase {
       ['name' => ''],
       ['name' => 'contribution_source'],
       ['name' => 'trxn_id'],
+      ['name' => 'contribution_campaign_id'],
     ];
     $this->importCSV('contributions.csv', $fieldMappings, ['onDuplicate' => CRM_Import_Parser::DUPLICATE_UPDATE]);
 
     $row = $this->getDataSource()->getRows()[0];
-    $this->assertEquals('IMPORTED', $row[9]);
+    $this->assertEquals('IMPORTED', $row[10]);
     $contribution = Contribution::get()->addSelect('source', 'id')->execute()->first();
     $this->assertEquals('Call him back', $contribution['source']);
   }
index 46f34410b9e9b46c5a8b9b14498c0d3241177b1a..a16d213fb7ac66fcdecdcc67776dd0efbf624cf2 100644 (file)
@@ -1,2 +1,2 @@
-External Identifier,Total Amount,Receive Date,Financial Type,Soft Credit to,Source,Note,Transaction ID
-bob,65,2008-09-20,Donation,mum@example.com,Word of mouth,Call him back,999
+External Identifier,Total Amount,Receive Date,Financial Type,Soft Credit to,Source,Note,Transaction ID,Campaign ID
+bob,65,2008-09-20,Donation,mum@example.com,Word of mouth,Call him back,999,1