Add unit test to ensure address custom data is imported
authoreileen <emcnaughton@wikimedia.org>
Fri, 12 Apr 2019 06:06:17 +0000 (16:06 +1000)
committereileen <emcnaughton@wikimedia.org>
Sun, 14 Apr 2019 23:59:38 +0000 (09:59 +1000)
tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php

index f6a4598d3205929f75972639dce82c7a0984f471..823b91aa2cd887b9592cac0e42cced350d65f839 100644 (file)
@@ -254,6 +254,21 @@ class CRM_Contact_Import_Parser_ContactTest extends CiviUnitTestCase {
     $this->callAPISuccess('Contact', 'delete', array('id' => $contact['id']));
   }
 
+  /**
+   * Test that address custom fields can be imported
+   */
+  public function testAddressWithCustomData() {
+    $ids = $this->entityCustomGroupWithSingleFieldCreate('Address', 'AddressTest.php');
+    list($contactValues) = $this->setUpBaseContact();
+    $contactValues['nick_name'] = 'Old Bill';
+    $contactValues['external_identifier'] = 'android';
+    $contactValues['street_address'] = 'Big Mansion';
+    $contactValues['custom_' . $ids['custom_field_id']] = 'Update';
+    $this->runImport($contactValues, CRM_Import_Parser::DUPLICATE_UPDATE, CRM_Import_Parser::VALID, array(0 => NULL, 1 => NULL, 2 => NULL, 3 => NULL, 4 => NULL, 5 => 'Primary', 6 => 'Primary'));
+    $address = $this->callAPISuccessGetSingle('Address', ['street_address' => 'Big Mansion', 'return' => 'custom_' . $ids['custom_field_id']]);
+    $this->assertEquals('Update', $address['custom_' . $ids['custom_field_id']]);
+  }
+
   /**
    * Test that the import parser adds the address to the primary location.
    *