Skip to content

Commit

Permalink
Add test for updating email via import & ensuring it is primary
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed May 11, 2019
1 parent 683b43c commit 373c66c
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,10 @@ public function testImportParserWithUpdateWithExternalIdentifier() {
* @throws \Exception
*/
public function testImportParserWithUpdateWithExternalIdentifierButNoPrimaryMatch() {
list($originalValues, $result) = $this->setUpBaseContact(array(
list($originalValues, $result) = $this->setUpBaseContact([
'external_identifier' => 'windows',
'email' => NULL,
));
]);

$this->assertEquals('windows', $result['external_identifier']);

Expand All @@ -177,6 +177,28 @@ public function testImportParserWithUpdateWithExternalIdentifierButNoPrimaryMatc
$this->callAPISuccessGetSingle('Contact', $originalValues);
}

/**
* Test import parser will fallback to external identifier.
*
* In this case no primary match exists (e.g the details are not supplied) so it falls back on external identifier.
*
* CRM-17275
*
* @throws \Exception
*/
public function testImportParserWithUpdateWithContactID() {
list($originalValues, $result) = $this->setUpBaseContact(array(
'external_identifier' => '',
'email' => NULL,
));
$updateValues = ['id' => $result['id'], 'email' => 'bill@example.com'];

$this->runImport($updateValues, CRM_Import_Parser::DUPLICATE_UPDATE, CRM_Import_Parser::VALID, [NULL, 1]);
$originalValues['id'] = $result['id'];
$this->callAPISuccessGetSingle('Email', ['contact_id' => $originalValues['id'], 'is_primary' => 1]);
$this->callAPISuccessGetSingle('Contact', $originalValues);
}

/**
* Test that the import parser adds the external identifier where none is set.
*
Expand Down

0 comments on commit 373c66c

Please sign in to comment.