Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional test #23562

Merged
merged 1 commit into from
May 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1602,6 +1602,60 @@ public function testMapFields(): void {
], $params);
}

/**
* Test that import parser will not match the imported primary to
* an existing contact via the related contacts fields.
*
* Currently fails because CRM_Dedupe_Finder::formatParams($input, $contactType);
* called in getDuplicateContacts flattens the contact array adding the
* related contacts values to the primary contact.
*
* https://github.com/civicrm/civicrm-core/blob/ca13ec46eae2042604e4e106c6cb3dc0439db3e2/CRM/Dedupe/Finder.php#L238
*
* @throws \API_Exception
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
public function testImportParserDoesNotMatchPrimaryToRelated(): void {
$this->individualCreate([
'first_name' => 'Bob',
'last_name' => 'Dobbs',
'email' => '[email protected]',
]);

$contactImportValues = [
'first_name' => 'Alok',
'last_name' => 'Patel',
'Employee of' => 'email',
];

$mapper = [
['first_name'],
['last_name'],
['5_a_b', 'email'],
];
$fields = array_keys($contactImportValues);
$values = array_values($contactImportValues);
$values[] = '[email protected]';

$userJobID = $this->getUserJobID([
'mapper' => $mapper,
'onDuplicate' => CRM_Import_Parser::DUPLICATE_UPDATE,
]);

$parser = new CRM_Contact_Import_Parser_Contact($fields);
$parser->setUserJobID($userJobID);
$parser->init();

$this->assertEquals(CRM_Import_Parser::ERROR, $parser->import(CRM_Import_Parser::DUPLICATE_UPDATE, $values), 'Return code from parser import was not as expected');
$this->callAPISuccessGetSingle('Contact', [
'first_name' => 'Bob',
'last_name' => 'Dobbs',
'email' => '[email protected]',
]);
}

/**
* Set up the underlying contact.
*
Expand Down