-
-
Notifications
You must be signed in to change notification settings - Fork 825
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix contribution/membership/participant import matching on external i…
…d or contact id
- Loading branch information
1 parent
89fa7d7
commit a2f1966
Showing
5 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -277,6 +277,49 @@ public function testImport() :void { | |
$this->assertEquals('No matching Contact found for ([email protected] )', $row['_status_message']); | ||
} | ||
|
||
public function testImportWithMatchByExternalIdentifier() :void { | ||
CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_contact AUTO_INCREMENT = 1000000"); | ||
|
||
$contactRubyParams = [ | ||
'first_name' => 'Ruby', | ||
'external_identifier' => 'ruby', | ||
'contact_type' => 'Individual', | ||
]; | ||
$contactSapphireParams = [ | ||
'first_name' => 'Sapphire', | ||
'external_identifier' => 'sapphire', | ||
'contact_type' => 'Individual', | ||
]; | ||
$contactRubyId = $this->individualCreate($contactRubyParams); | ||
$contactSapphireId = $this->individualCreate($contactSapphireParams); | ||
|
||
// make sure we're testing dev/core#3784 | ||
self::assertEquals(1, substr($contactRubyId, 0, 1)); | ||
self::assertEquals(1, substr($contactSapphireId, 0, 1)); | ||
|
||
$mapping = [ | ||
['name' => 'external_identifier'], | ||
['name' => 'total_amount'], | ||
['name' => 'receive_date'], | ||
['name' => 'financial_type_id'], | ||
]; | ||
$this->importCSV('contributions_match_external_id.csv', $mapping); | ||
|
||
$contributionsOfRuby = Contribution::get() | ||
->addWhere('contact_id', '=', $contactRubyId)->execute(); | ||
$contributionsOfSapphire = Contribution::get() | ||
->addWhere('contact_id', '=', $contactSapphireId)->execute(); | ||
|
||
$this->assertCount(1, $contributionsOfRuby, 'Wrong number of contributions imported'); | ||
$this->assertCount(1, $contributionsOfSapphire, 'Wrong number of contributions imported'); | ||
$this->assertEquals(22222, $contributionsOfRuby->first()['total_amount']); | ||
$this->assertEquals(5, $contributionsOfSapphire->first()['total_amount']); | ||
|
||
$dataSource = new CRM_Import_DataSource_CSV($this->userJobID); | ||
$this->assertEquals(0, $dataSource->getRowCount([CRM_Import_Parser::ERROR])); | ||
$this->assertEquals(2, $dataSource->getRowCount([CRM_Import_Parser::VALID])); | ||
} | ||
|
||
/** | ||
* Run the import parser. | ||
* | ||
|
3 changes: 3 additions & 0 deletions
3
tests/phpunit/CRM/Contribute/Import/Parser/data/contributions_match_external_id.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
External Identifier,Total Amount,Receive Date,Financial Type | ||
sapphire,5,2005-05-05,Donation | ||
ruby,22222,2022-02-22,Donation |