[Test] Extend custom field test trait & some related tests
authoreileen <emcnaughton@wikimedia.org>
Thu, 9 Apr 2020 05:57:51 +0000 (17:57 +1200)
committereileen <emcnaughton@wikimedia.org>
Fri, 10 Apr 2020 04:09:17 +0000 (16:09 +1200)
tests/phpunit/CRM/Contact/Import/Form/MapFieldTest.php
tests/phpunit/CRM/Core/BAO/CustomFieldTest.php
tests/phpunit/CRM/Core/BAO/CustomQueryTest.php
tests/phpunit/CRMTraits/Custom/CustomDataTrait.php
tests/phpunit/api/v3/ContactTest.php

index 308f6c58cc731089de024103800743b9d6934686..85e4d96b2b60b8fdc173eb0bdb52f89c9e0cb730 100644 (file)
@@ -171,8 +171,10 @@ class CRM_Contact_Import_Form_MapFieldTest extends CiviUnitTestCase {
    * In conjunction with testing our existing  function this  tests the methods we want to migrate to
    * to  clean it up.
    *
+   * @throws \API_Exception
    * @throws \CRM_Core_Exception
    * @throws \CiviCRM_API3_Exception
+   * @throws \Civi\API\Exception\UnauthorizedException
    */
   public function testLoadSavedMappingDirect() {
     $this->entity = 'Contact';
index 0ed1ff2a1700c2231441a09975df81349760e3e2..a92ae46126d5349027e76d9acdc4f3515454fb63 100644 (file)
@@ -463,8 +463,46 @@ class CRM_Core_BAO_CustomFieldTest extends CiviUnitTestCase {
         'time_format' => NULL,
         'is_required' => 0,
         'table_name' => 'civicrm_value_custom_group_' . $customGroupID,
-        'column_name' => 'country_' . $this->getCustomFieldID('country'),
-        'where' => 'civicrm_value_custom_group_' . $customGroupID . '.country_' . $this->getCustomFieldID('country'),
+        'column_name' => $this->getCustomFieldColumnName('country'),
+        'where' => 'civicrm_value_custom_group_' . $customGroupID . '.' . $this->getCustomFieldColumnName('country'),
+        'extends_table' => 'civicrm_contact',
+        'search_table' => 'contact_a',
+        'pseudoconstant' => [
+          'table' => 'civicrm_country',
+          'keyColumn' => 'id',
+          'labelColumn' => 'name',
+          'nameColumn' => 'iso_code',
+        ],
+      ],
+      $this->getCustomFieldName('multi_country') => [
+        'name' => $this->getCustomFieldName('multi_country'),
+        'type' => 1,
+        'title' => 'Country-multi',
+        'headerPattern' => '//',
+        'import' => 1,
+        'custom_field_id' => $this->getCustomFieldID('multi_country'),
+        'options_per_line' => NULL,
+        'text_length' => NULL,
+        'data_type' => 'Country',
+        'html_type' => 'Multi-Select Country',
+        'is_search_range' => '0',
+        'id' => $this->getCustomFieldID('multi_country'),
+        'label' => 'Country-multi',
+        'groupTitle' => 'Custom Group',
+        'default_value' => NULL,
+        'custom_group_id' => $customGroupID,
+        'extends' => 'Contact',
+        'extends_entity_column_value' => NULL,
+        'extends_entity_column_id' => NULL,
+        'is_view' => '0',
+        'is_multiple' => '0',
+        'option_group_id' => NULL,
+        'date_format' => NULL,
+        'time_format' => NULL,
+        'is_required' => 0,
+        'table_name' => 'civicrm_value_custom_group_' . $customGroupID,
+        'column_name' => $this->getCustomFieldColumnName('multi_country'),
+        'where' => 'civicrm_value_custom_group_' . $customGroupID . '.' . $this->getCustomFieldColumnName('multi_country'),
         'extends_table' => 'civicrm_contact',
         'search_table' => 'contact_a',
         'pseudoconstant' => [
@@ -703,6 +741,115 @@ class CRM_Core_BAO_CustomFieldTest extends CiviUnitTestCase {
         'extends_table' => 'civicrm_contact',
         'search_table' => 'contact_a',
       ],
+      $this->getCustomFieldName('state') => [
+        'name' => $this->getCustomFieldName('state'),
+        'id' => $this->getCustomFieldID('state'),
+        'label' => 'State',
+        'headerPattern' => '//',
+        'title' => 'State',
+        'custom_field_id' => $this->getCustomFieldID('state'),
+        'groupTitle' => 'Custom Group',
+        'default_value' => NULL,
+        'custom_group_id' => $customGroupID,
+        'extends' => 'Contact',
+        'extends_entity_column_value' => NULL,
+        'extends_entity_column_id' => NULL,
+        'is_view' => '0',
+        'is_multiple' => '0',
+        'option_group_id' => NULL,
+        'date_format' => NULL,
+        'time_format' => NULL,
+        'is_required' => 0,
+        'table_name' => 'civicrm_value_custom_group_' . $customGroupID,
+        'column_name' => $this->getCustomFieldColumnName('state'),
+        'where' => 'civicrm_value_custom_group_' . $customGroupID . '.' . $this->getCustomFieldColumnName('state'),
+        'extends_table' => 'civicrm_contact',
+        'search_table' => 'contact_a',
+        'pseudoconstant' => [
+          'table' => 'civicrm_state_province',
+          'keyColumn' => 'id',
+          'labelColumn' => 'name',
+        ],
+        'import' => 1,
+        'data_type' => 'StateProvince',
+        'type' => 1,
+        'html_type' => 'Select State/Province',
+        'text_length' => NULL,
+        'options_per_line' => NULL,
+        'is_search_range' => '0',
+      ],
+      $this->getCustomFieldName('multi_state') => [
+        'id' => $this->getCustomFieldID('multi_state'),
+        'label' => 'State-multi',
+        'headerPattern' => '//',
+        'title' => 'State-multi',
+        'custom_field_id' => $this->getCustomFieldID('multi_state'),
+        'groupTitle' => 'Custom Group',
+        'default_value' => NULL,
+        'custom_group_id' => $customGroupID,
+        'extends' => 'Contact',
+        'extends_entity_column_value' => NULL,
+        'extends_entity_column_id' => NULL,
+        'is_view' => '0',
+        'is_multiple' => '0',
+        'option_group_id' => NULL,
+        'date_format' => NULL,
+        'time_format' => NULL,
+        'is_required' => 0,
+        'table_name' => 'civicrm_value_custom_group_' . $customGroupID,
+        'column_name' => $this->getCustomFieldColumnName('multi_state'),
+        'where' => 'civicrm_value_custom_group_' . $customGroupID . '.' . $this->getCustomFieldColumnName('multi_state'),
+        'extends_table' => 'civicrm_contact',
+        'search_table' => 'contact_a',
+        'pseudoconstant' => [
+          'table' => 'civicrm_state_province',
+          'keyColumn' => 'id',
+          'labelColumn' => 'name',
+        ],
+        'import' => 1,
+        'data_type' => 'StateProvince',
+        'name' => $this->getCustomFieldName('multi_state'),
+        'type' => 1,
+        'html_type' => 'Multi-Select State/Province',
+        'text_length' => NULL,
+        'options_per_line' => NULL,
+        'is_search_range' => '0',
+      ],
+      $this->getCustomFieldName('boolean') => [
+        'id' => $this->getCustomFieldID('boolean'),
+        'label' => 'Yes No',
+        'headerPattern' => '//',
+        'title' => 'Yes No',
+        'custom_field_id' => $this->getCustomFieldID('boolean'),
+        'groupTitle' => 'Custom Group',
+        'default_value' => NULL,
+        'custom_group_id' => $customGroupID,
+        'extends' => 'Contact',
+        'extends_entity_column_value' => NULL,
+        'extends_entity_column_id' => NULL,
+        'is_view' => '0',
+        'is_multiple' => '0',
+        'option_group_id' => NULL,
+        'date_format' => NULL,
+        'time_format' => NULL,
+        'is_required' => 0,
+        'table_name' => 'civicrm_value_custom_group_' . $customGroupID,
+        'column_name' => $this->getCustomFieldColumnName('boolean'),
+        'where' => 'civicrm_value_custom_group_' . $customGroupID . '.' . $this->getCustomFieldColumnName('boolean'),
+        'extends_table' => 'civicrm_contact',
+        'search_table' => 'contact_a',
+        'import' => 1,
+        'data_type' => 'Boolean',
+        'name' => $this->getCustomFieldName('boolean'),
+        'type' => 16,
+        'html_type' => 'Radio',
+        'text_length' => NULL,
+        'options_per_line' => NULL,
+        'is_search_range' => '0',
+        'pseudoconstant' => [
+          'callback' => 'CRM_Core_SelectValues::boolean',
+        ],
+      ],
     ];
     $this->assertEquals($expected, CRM_Core_BAO_CustomField::getFieldsForImport());
   }
index 32e62037e4c119793a907b3de3226ce752acd90d..b803394c2e1fcc8333933f8e0ff996dcfb72222f 100644 (file)
@@ -95,7 +95,9 @@ class CRM_Core_BAO_CustomQueryTest extends CiviUnitTestCase {
    * The conversion to date picker will result int these fields
    * being renamed _high & _low and needing to return correctly.
    *
+   * @throws \API_Exception
    * @throws \CRM_Core_Exception
+   * @throws \Civi\API\Exception\UnauthorizedException
    */
   public function testSearchCustomDataDateHighLow() {
     $this->createCustomGroupWithFieldOfType([], 'date');
@@ -127,7 +129,9 @@ class CRM_Core_BAO_CustomQueryTest extends CiviUnitTestCase {
    * The conversion to date picker will result int these fields
    * being renamed _high & _low and needing to return correctly.
    *
+   * @throws \API_Exception
    * @throws \CRM_Core_Exception
+   * @throws \Civi\API\Exception\UnauthorizedException
    */
   public function testSearchCustomDataDateLowWithPermsInPlay() {
     $this->createLoggedInUser();
@@ -329,7 +333,7 @@ LEFT JOIN ' . $this->getCustomGroupTable() . ' ON ' . $this->getCustomGroupTable
       'default_value' => NULL,
     ]);
     $dateCustomFieldName = 'custom_' . $dateCustomField['id'];
-    $this->individualCreate([$dateCustomFieldName => "2015-01-01"]);
+    $this->individualCreate([$dateCustomFieldName => '2015-01-01']);
     // Assigning the relevant form value to be within a custom key is normally done in
     // build field params. It would be better if it were all done in convertFormValues
     // but for now we just imitate it.
@@ -348,7 +352,9 @@ LEFT JOIN ' . $this->getCustomGroupTable() . ' ON ' . $this->getCustomGroupTable
   /**
    * Test search builder style query including custom address fields.
    *
+   * @throws \API_Exception
    * @throws \CRM_Core_Exception
+   * @throws \Civi\API\Exception\UnauthorizedException
    */
   public function testAddressCustomFields() {
     $this->createCustomGroupWithFieldOfType(['extends' => 'Address'], 'int');
index dc10dfcff8de84133fe496e726fc7ae380f8b483..23f26fa62cd12e90fe28dd81148c978595f0d618 100644 (file)
@@ -81,6 +81,7 @@ trait CRMTraits_Custom_CustomDataTrait {
    * Create a custom group with a single field.
    *
    * @param array $groupParams
+   *   Params for the group to be created.
    * @param string $customFieldType
    *
    * @param string $identifier
@@ -90,31 +91,36 @@ trait CRMTraits_Custom_CustomDataTrait {
    * @throws \Civi\API\Exception\UnauthorizedException
    */
   public function createCustomGroupWithFieldOfType($groupParams = [], $customFieldType = 'text', $identifier = NULL) {
-    $supported = ['text', 'select', 'date', 'int'];
+    $supported = ['text', 'select', 'date', 'int', 'contact_reference'];
     if (!in_array($customFieldType, $supported, TRUE)) {
       throw new CRM_Core_Exception('we have not yet extracted other custom field types from createCustomFieldsOfAllTypes, Use consistent syntax when you do');
     }
     $groupParams['title'] = empty($groupParams['title']) ? $identifier . 'Group with field ' . $customFieldType : $groupParams['title'];
     $groupParams['name'] = $identifier ?? 'Custom Group';
     $this->createCustomGroup($groupParams);
+    $reference = &$this->ids['CustomField'][$identifier . $customFieldType];
+    $fieldParams = ['custom_group_id' => $this->ids['CustomGroup'][$groupParams['name']]];
     switch ($customFieldType) {
       case 'text':
-        $customField = $this->createTextCustomField(['custom_group_id' => $this->ids['CustomGroup'][$groupParams['name']]]);
-        break;
+        $reference = $this->createTextCustomField($fieldParams)['id'];
+        return;
 
       case 'select':
-        $customField = $this->createSelectCustomField(['custom_group_id' => $this->ids['CustomGroup'][$groupParams['name']]]);
-        break;
+        $reference = $this->createSelectCustomField($fieldParams)['id'];
+        return;
 
       case 'int':
-        $customField = $this->createIntCustomField(['custom_group_id' => $this->ids['CustomGroup'][$groupParams['name']]]);
-        break;
+        $reference = $this->createIntCustomField($fieldParams)['id'];
+        return;
 
       case 'date':
-        $customField = $this->createDateCustomField(['custom_group_id' => $this->ids['CustomGroup'][$groupParams['name']]]);
-        break;
+        $reference = $this->createDateCustomField($fieldParams)['id'];
+        return;
+
+      case 'contact_reference':
+        $reference = $this->createContactReferenceCustomField($fieldParams)['id'];
+        return;
     }
-    $this->ids['CustomField'][$identifier . $customFieldType] = $customField['id'];
   }
 
   /**
@@ -130,7 +136,11 @@ trait CRMTraits_Custom_CustomDataTrait {
     $ids['link'] = (int) $this->createLinkCustomField(['custom_group_id' => $customGroupID])['id'];
     $ids['file'] = (int) $this->createFileCustomField(['custom_group_id' => $customGroupID])['id'];
     $ids['country'] = (int) $this->createCountryCustomField(['custom_group_id' => $customGroupID])['id'];
+    $ids['multi_country'] = (int) $this->createMultiCountryCustomField(['custom_group_id' => $customGroupID])['id'];
     $ids['contact_reference'] = $this->createContactReferenceCustomField(['custom_group_id' => $customGroupID])['id'];
+    $ids['state'] = (int) $this->createStateCustomField(['custom_group_id' => $customGroupID])['id'];
+    $ids['multi_state'] = (int) $this->createMultiStateCustomField(['custom_group_id' => $customGroupID])['id'];
+    $ids['boolean'] = (int) $this->createBooleanCustomField(['custom_group_id' => $customGroupID])['id'];
     return $ids;
   }
 
@@ -177,6 +187,19 @@ trait CRMTraits_Custom_CustomDataTrait {
     return $this->callAPISuccess('CustomField', 'create', $params)['values'][0];
   }
 
+  /**
+   * Create a custom text fields.
+   *
+   * @param array $params
+   *   Parameter overrides, must include custom_group_id.
+   *
+   * @return array
+   */
+  protected function createBooleanCustomField($params = []) {
+    $params = array_merge($this->getFieldsValuesByType('Boolean'), $params);
+    return $this->callAPISuccess('CustomField', 'create', $params)['values'][0];
+  }
+
   /**
    * Create a custom text fields.
    *
@@ -217,7 +240,7 @@ trait CRMTraits_Custom_CustomDataTrait {
   }
 
   /**
-   * Create a custom text fields.
+   * Create a custom country fields.
    *
    * @param array $params
    *   Parameter overrides, must include custom_group_id.
@@ -229,6 +252,45 @@ trait CRMTraits_Custom_CustomDataTrait {
     return $this->callAPISuccess('custom_field', 'create', $params)['values'][0];
   }
 
+  /**
+   * Create a custom multi select country fields.
+   *
+   * @param array $params
+   *   Parameter overrides, must include custom_group_id.
+   *
+   * @return array
+   */
+  protected function createMultiCountryCustomField($params = []) {
+    $params = array_merge($this->getFieldsValuesByType('Country', 'Multi-Select Country'), $params);
+    return $this->callAPISuccess('custom_field', 'create', $params)['values'][0];
+  }
+
+  /**
+   * Create a custom state fields.
+   *
+   * @param array $params
+   *   Parameter overrides, must include custom_group_id.
+   *
+   * @return array
+   */
+  protected function createStateCustomField($params = []) {
+    $params = array_merge($this->getFieldsValuesByType('StateProvince'), $params);
+    return $this->callAPISuccess('custom_field', 'create', $params)['values'][0];
+  }
+
+  /**
+   * Create a custom multi select state fields.
+   *
+   * @param array $params
+   *   Parameter overrides, must include custom_group_id.
+   *
+   * @return array
+   */
+  protected function createMultiStateCustomField($params = []) {
+    $params = array_merge($this->getFieldsValuesByType('StateProvince', 'Multi-Select State/Province'), $params);
+    return $this->callAPISuccess('custom_field', 'create', $params)['values'][0];
+  }
+
   /**
    * Create a custom text fields.
    *
@@ -333,6 +395,114 @@ trait CRMTraits_Custom_CustomDataTrait {
             ],
           ],
         ],
+        'Radio' => [
+          'label' => 'Pick Color',
+          'html_type' => 'Radio',
+          'data_type' => 'String',
+          'text_length' => '',
+          'default_value' => '',
+          'option_values' => [
+            [
+              'label' => 'Red',
+              'value' => 'R',
+              'weight' => 1,
+              'is_active' => 1,
+            ],
+            [
+              'label' => 'Yellow',
+              'value' => 'Y',
+              'weight' => 2,
+              'is_active' => 1,
+            ],
+            [
+              'label' => 'Green',
+              'value' => 'G',
+              'weight' => 3,
+              'is_active' => 1,
+            ],
+          ],
+        ],
+        'CheckBox' => [
+          'label' => 'Pick Color',
+          'html_type' => 'Checkbox',
+          'data_type' => 'String',
+          'text_length' => '',
+          'default_value' => '',
+          'option_values' => [
+            [
+              'label' => 'Red',
+              'value' => 'R',
+              'weight' => 1,
+              'is_active' => 1,
+            ],
+            [
+              'label' => 'Yellow',
+              'value' => 'Y',
+              'weight' => 2,
+              'is_active' => 1,
+            ],
+            [
+              'label' => 'Green',
+              'value' => 'G',
+              'weight' => 3,
+              'is_active' => 1,
+            ],
+          ],
+        ],
+        'Multi-Select' => [
+          'label' => 'Pick Color',
+          'html_type' => 'Multi-Select',
+          'data_type' => 'String',
+          'text_length' => '',
+          'default_value' => '',
+          'option_values' => [
+            [
+              'label' => 'Red',
+              'value' => 'R',
+              'weight' => 1,
+              'is_active' => 1,
+            ],
+            [
+              'label' => 'Yellow',
+              'value' => 'Y',
+              'weight' => 2,
+              'is_active' => 1,
+            ],
+            [
+              'label' => 'Green',
+              'value' => 'G',
+              'weight' => 3,
+              'is_active' => 1,
+            ],
+          ],
+        ],
+        'Autocomplete-Select' => [
+          'label' => 'Pick Color',
+          'html_type' => 'Autocomplete-Select',
+          'data_type' => 'String',
+          'text_length' => '',
+          'default_value' => '',
+          'option_values' => [
+            [
+              'label' => 'Red',
+              'value' => 'R',
+              'weight' => 1,
+              'is_active' => 1,
+            ],
+            [
+              'label' => 'Yellow',
+              'value' => 'Y',
+              'weight' => 2,
+              'is_active' => 1,
+            ],
+            [
+              'label' => 'Green',
+              'value' => 'G',
+              'weight' => 3,
+              'is_active' => 1,
+            ],
+          ],
+        ],
       ],
       'Int' => [
         'default' => [
@@ -342,6 +512,42 @@ trait CRMTraits_Custom_CustomDataTrait {
           'default_value' => '4',
           'is_search_range' => 1,
         ],
+        'Select' => [
+          'label' => 'Integer select',
+          'html_type' => 'Select',
+          'option_values' => [
+            [
+              'label' => '50',
+              'value' => 3,
+              'weight' => 1,
+              'is_active' => 1,
+            ],
+            [
+              'label' => '100',
+              'value' => 4,
+              'weight' => 2,
+              'is_active' => 1,
+            ],
+          ],
+        ],
+        'Radio' => [
+          'label' => 'Integer radio',
+          'html_type' => 'Radio',
+          'option_values' => [
+            [
+              'label' => '50',
+              'value' => 3,
+              'weight' => 1,
+              'is_active' => 1,
+            ],
+            [
+              'label' => '100',
+              'value' => 4,
+              'weight' => 2,
+              'is_active' => 1,
+            ],
+          ],
+        ],
       ],
       'Date' => [
         'default' => [
@@ -355,6 +561,123 @@ trait CRMTraits_Custom_CustomDataTrait {
           'time_format' => 1,
         ],
       ],
+      'Float' => [
+        'default' => [
+          'label' => 'Number',
+          'html_type' => 'Text',
+          'data_type' => 'Float',
+        ],
+        'Select' => [
+          'label' => 'Number select',
+          'html_type' => 'Select',
+          'option_values' => [
+            [
+              'label' => '50',
+              'value' => 3,
+              'weight' => 1,
+              'is_active' => 1,
+            ],
+            [
+              'label' => '100',
+              'value' => 4,
+              'weight' => 2,
+              'is_active' => 1,
+            ],
+          ],
+        ],
+        'Radio' => [
+          'label' => 'Number radio',
+          'html_type' => 'Radio',
+          'option_values' => [
+            [
+              'label' => '50',
+              'value' => 3,
+              'weight' => 1,
+              'is_active' => 1,
+            ],
+            [
+              'label' => '100',
+              'value' => 4,
+              'weight' => 2,
+              'is_active' => 1,
+            ],
+          ],
+        ],
+      ],
+      'Money' => [
+        'default' => [
+          'label' => 'Money',
+          'html_type' => 'Text',
+          'data_type' => 'Money',
+        ],
+        'Select' => [
+          'label' => 'Money select',
+          'html_type' => 'Select',
+          'option_values' => [
+            [
+              'label' => '50',
+              'value' => 3,
+              'weight' => 1,
+              'is_active' => 1,
+            ],
+            [
+              'label' => '100',
+              'value' => 4,
+              'weight' => 2,
+              'is_active' => 1,
+            ],
+          ],
+        ],
+        'Radio' => [
+          'label' => 'Money radio',
+          'html_type' => 'Radio',
+          'option_values' => [
+            [
+              'label' => '50',
+              'value' => 3,
+              'weight' => 1,
+              'is_active' => 1,
+            ],
+            [
+              'label' => '100',
+              'value' => 4,
+              'weight' => 2,
+              'is_active' => 1,
+            ],
+          ],
+        ],
+      ],
+      'Memo' => [
+        'default' => [
+          'label' => 'Memo',
+          'html_type' => 'TextArea',
+          'data_type' => 'Memo',
+          'attributes' => 'rows=4, cols=60',
+        ],
+        'RichTextEditor' => [
+          'label' => 'Memo Rich Text Editor',
+          'html_type' => 'Memo',
+        ],
+      ],
+      'Boolean' => [
+        'default' => [
+          'data_type' => 'Boolean',
+          'html_type' => 'Radio',
+          'label' => 'Yes No',
+        ],
+      ],
+      'StateProvince' => [
+        'default' => [
+          'data_type' => 'StateProvince',
+          'html_type' => 'Select State/Province',
+          'label' => 'State',
+          'option_type' => 0,
+        ],
+        'Multi-Select State/Province' => [
+          'html_type' => 'Multi-Select State/Province',
+          'label' => 'State-multi',
+        ],
+      ],
       'Country' => [
         'default' => [
           'data_type' => 'Country',
@@ -362,6 +685,11 @@ trait CRMTraits_Custom_CustomDataTrait {
           'label' => 'Country',
           'option_type' => 0,
         ],
+        'Multi-Select Country' => [
+          'html_type' => 'Multi-Select Country',
+          'label' => 'Country-multi',
+          'option_type' => 0,
+        ],
       ],
       'File' => [
         'default' => [
index d6fa72b76dd88420618c6bee685a9de02b978d58..ddaefd9f32667a2e578d33bfe5d9ed507ccf1aae 100644 (file)
@@ -3917,17 +3917,25 @@ class api_v3_ContactTest extends CiviUnitTestCase {
     $dateField = $this->getCustomFieldName('select_date');
     $selectField = $this->getCustomFieldName('select_string');
     $countryField = $this->getCustomFieldName('country');
+    $multiCountryField = $this->getCustomFieldName('multi_country');
     $referenceField = $this->getCustomFieldName('contact_reference');
+    $stateField = $this->getCustomFieldName('state');
+    $multiStateField = $this->getCustomFieldName('multi_state');
+    $booleanStateField = $this->getCustomFieldName('boolean');
 
     $countriesByName = array_flip(CRM_Core_PseudoConstant::country(FALSE, FALSE));
+    $statesByName = array_flip(CRM_Core_PseudoConstant::stateProvince(FALSE, FALSE));
     $customFieldValues = [
-      // @todo fix the fatal bug on this & uncomment - see dev/core#723
       $fileField => $file['id'],
       $linkField => 'http://example.org',
       $dateField => '2018-01-01 17:10:56',
       $selectField => 'G',
       $countryField => $countriesByName['New Zealand'],
+      $multiCountryField => [$countriesByName['New Zealand'], $countriesByName['Australia']],
       $referenceField => $this->householdCreate(),
+      $stateField => $statesByName['Victoria'],
+      $multiStateField => [$statesByName['Victoria'], $statesByName['Tasmania']],
+      $booleanStateField => 1,
     ];
     $this->callAPISuccess('Contact', 'create', array_merge([
       'id' => $contact1,
@@ -3946,6 +3954,50 @@ class api_v3_ContactTest extends CiviUnitTestCase {
     }
   }
 
+  /**
+   * Test merging a contact that is the target of a contact reference field on another contact.
+   *
+   * @throws \API_Exception
+   * @throws \CRM_Core_Exception
+   * @throws \Civi\API\Exception\UnauthorizedException
+   */
+  public function testMergeContactReferenceCustomFieldTarget() {
+    $this->createCustomGroupWithFieldOfType([], 'contact_reference');
+    $contact1 = $this->individualCreate();
+    $contact2 = $this->individualCreate();
+    $contact3 = $this->individualCreate([$this->getCustomFieldName('contact_reference') => $contact2]);
+    $this->callAPISuccess('contact', 'merge', [
+      'to_keep_id' => $contact1,
+      'to_remove_id' => $contact2,
+      'auto_flip' => FALSE,
+    ]);
+    $this->assertEquals($contact1, $this->callAPISuccessGetValue('Contact', ['id' => $contact3, 'return' => $this->getCustomFieldName('contact_reference')]));
+  }
+
+  /**
+   * Test merging when a multiple record set is in use.
+   *
+   * @throws \API_Exception
+   * @throws \CRM_Core_Exception
+   * @throws \Civi\API\Exception\UnauthorizedException
+   */
+  public function testMergeMultipleCustomValues() {
+    $customGroupID = $this->createCustomGroup(['is_multiple' => TRUE]);
+    $this->ids['CustomField']['text'] = (int) $this->createTextCustomField(['custom_group_id' => $customGroupID])['id'];
+    $contact1 = $this->individualCreate([$this->getCustomFieldName('text') => 'blah']);
+    $contact2 = $this->individualCreate([$this->getCustomFieldName('text') => 'de blah']);
+    $this->callAPISuccess('contact', 'merge', [
+      'to_keep_id' => $contact1,
+      'to_remove_id' => $contact2,
+      'auto_flip' => FALSE,
+    ]);
+    $column = $this->getCustomFieldColumnName('text');
+    $table = $this->getCustomGroupTable();
+    $this->assertEquals('blah,de blah', CRM_Core_DAO::singleValueQuery(
+      "SELECT GROUP_CONCAT({$column}) FROM $table WHERE entity_id = $contact1"
+    ));
+  }
+
   /**
    * Test retrieving merged contacts.
    *
@@ -4005,6 +4057,8 @@ class api_v3_ContactTest extends CiviUnitTestCase {
    * Ensure format with return=group shows comma-separated group IDs.
    *
    * CRM-19426
+   *
+   * @throws \CRM_Core_Exception
    */
   public function testContactGetReturnGroup() {
     // Set up a contact, asser that they were created.