From 44f39c51044e3dee1b6c6c760e03d352cf72bfbe Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 7 Apr 2023 12:07:19 +1200 Subject: [PATCH] Fix tests for re-ordering --- tests/phpunit/CRM/Contact/SelectorTest.php | 12 ++-- tests/phpunit/CRM/Export/BAO/ExportTest.php | 72 +++++++++++---------- 2 files changed, 44 insertions(+), 40 deletions(-) diff --git a/tests/phpunit/CRM/Contact/SelectorTest.php b/tests/phpunit/CRM/Contact/SelectorTest.php index f1b5423e8e..afec67da80 100644 --- a/tests/phpunit/CRM/Contact/SelectorTest.php +++ b/tests/phpunit/CRM/Contact/SelectorTest.php @@ -472,7 +472,7 @@ class CRM_Contact_SelectorTest extends CiviUnitTestCase { 'includeContactIds' => NULL, 'searchDescendentGroups' => FALSE, 'expected_query' => [ - 0 => 'SELECT contact_a.id as contact_id, contact_a.contact_type as `contact_type`, contact_a.contact_sub_type as `contact_sub_type`, contact_a.sort_name as `sort_name`, contact_a.display_name as `display_name`, contact_a.do_not_email as `do_not_email`, contact_a.do_not_phone as `do_not_phone`, contact_a.do_not_mail as `do_not_mail`, contact_a.do_not_sms as `do_not_sms`, contact_a.do_not_trade as `do_not_trade`, contact_a.is_opt_out as `is_opt_out`, contact_a.legal_identifier as `legal_identifier`, contact_a.external_identifier as `external_identifier`, contact_a.nick_name as `nick_name`, contact_a.legal_name as `legal_name`, contact_a.image_URL as `image_URL`, contact_a.preferred_communication_method as `preferred_communication_method`, contact_a.preferred_language as `preferred_language`, contact_a.first_name as `first_name`, contact_a.middle_name as `middle_name`, contact_a.last_name as `last_name`, contact_a.prefix_id as `prefix_id`, contact_a.suffix_id as `suffix_id`, contact_a.formal_title as `formal_title`, contact_a.communication_style_id as `communication_style_id`, contact_a.job_title as `job_title`, contact_a.gender_id as `gender_id`, contact_a.birth_date as `birth_date`, contact_a.is_deceased as `is_deceased`, contact_a.deceased_date as `deceased_date`, contact_a.household_name as `household_name`, IF ( contact_a.contact_type = \'Individual\', NULL, contact_a.organization_name ) as organization_name, contact_a.sic_code as `sic_code`, contact_a.is_deleted as `contact_is_deleted`, IF ( contact_a.contact_type = \'Individual\', contact_a.organization_name, NULL ) as current_employer, civicrm_address.id as address_id, civicrm_address.street_address as `street_address`, civicrm_address.supplemental_address_1 as `supplemental_address_1`, civicrm_address.supplemental_address_2 as `supplemental_address_2`, civicrm_address.supplemental_address_3 as `supplemental_address_3`, civicrm_address.city as `city`, civicrm_address.postal_code_suffix as `postal_code_suffix`, civicrm_address.postal_code as `postal_code`, civicrm_address.geo_code_1 as `geo_code_1`, civicrm_address.geo_code_2 as `geo_code_2`, civicrm_address.state_province_id as state_province_id, civicrm_address.country_id as country_id, civicrm_phone.id as phone_id, civicrm_phone.phone_type_id as phone_type_id, civicrm_phone.phone as `phone`, civicrm_email.id as email_id, civicrm_email.email as `email`, civicrm_email.on_hold as `on_hold`, civicrm_im.id as im_id, civicrm_im.provider_id as provider_id, civicrm_im.name as `im`, civicrm_worldregion.id as worldregion_id, civicrm_worldregion.name as `world_region`', + 0 => 'SELECT contact_a.id as contact_id, contact_a.contact_type as `contact_type`, contact_a.contact_sub_type as `contact_sub_type`, contact_a.sort_name as `sort_name`, contact_a.display_name as `display_name`, contact_a.external_identifier as `external_identifier`, IF ( contact_a.contact_type = \'Individual\', NULL, contact_a.organization_name ) as organization_name, contact_a.first_name as `first_name`, contact_a.middle_name as `middle_name`, contact_a.last_name as `last_name`, contact_a.do_not_email as `do_not_email`, contact_a.do_not_phone as `do_not_phone`, contact_a.do_not_mail as `do_not_mail`, contact_a.do_not_sms as `do_not_sms`, contact_a.do_not_trade as `do_not_trade`, contact_a.is_opt_out as `is_opt_out`, contact_a.legal_identifier as `legal_identifier`, contact_a.nick_name as `nick_name`, contact_a.legal_name as `legal_name`, contact_a.image_URL as `image_URL`, contact_a.preferred_communication_method as `preferred_communication_method`, contact_a.preferred_language as `preferred_language`, contact_a.prefix_id as `prefix_id`, contact_a.suffix_id as `suffix_id`, contact_a.formal_title as `formal_title`, contact_a.communication_style_id as `communication_style_id`, contact_a.job_title as `job_title`, contact_a.gender_id as `gender_id`, contact_a.birth_date as `birth_date`, contact_a.is_deceased as `is_deceased`, contact_a.deceased_date as `deceased_date`, contact_a.household_name as `household_name`, contact_a.sic_code as `sic_code`, contact_a.is_deleted as `contact_is_deleted`, IF ( contact_a.contact_type = \'Individual\', contact_a.organization_name, NULL ) as current_employer, civicrm_address.id as address_id, civicrm_address.street_address as `street_address`, civicrm_address.supplemental_address_1 as `supplemental_address_1`, civicrm_address.supplemental_address_2 as `supplemental_address_2`, civicrm_address.supplemental_address_3 as `supplemental_address_3`, civicrm_address.city as `city`, civicrm_address.postal_code_suffix as `postal_code_suffix`, civicrm_address.postal_code as `postal_code`, civicrm_address.geo_code_1 as `geo_code_1`, civicrm_address.geo_code_2 as `geo_code_2`, civicrm_address.state_province_id as state_province_id, civicrm_address.country_id as country_id, civicrm_phone.id as phone_id, civicrm_phone.phone_type_id as phone_type_id, civicrm_phone.phone as `phone`, civicrm_email.id as email_id, civicrm_email.email as `email`, civicrm_email.on_hold as `on_hold`, civicrm_im.id as im_id, civicrm_im.provider_id as provider_id, civicrm_im.name as `im`, civicrm_worldregion.id as worldregion_id, civicrm_worldregion.name as `world_region`', 2 => 'WHERE displayRelType.relationship_type_id = 1 AND displayRelType.is_active = 1 AND ( 1 ) AND (contact_a.is_deleted = 0)', @@ -733,15 +733,17 @@ AND ( 1 ) AND (contact_a.is_deleted = 0)', */ public static function getDefaultSelectString(): string { return 'SELECT contact_a.id as contact_id, contact_a.contact_type as `contact_type`, contact_a.contact_sub_type as `contact_sub_type`, contact_a.sort_name as `sort_name`,' - . ' contact_a.display_name as `display_name`, contact_a.do_not_email as `do_not_email`, contact_a.do_not_phone as `do_not_phone`, contact_a.do_not_mail as `do_not_mail`,' + . ' contact_a.display_name as `display_name`, contact_a.external_identifier as `external_identifier`,' + . ' IF ( contact_a.contact_type = \'Individual\', NULL, contact_a.organization_name ) as organization_name,' + . ' contact_a.first_name as `first_name`, contact_a.middle_name as `middle_name`, contact_a.last_name as `last_name`,' + . ' contact_a.do_not_email as `do_not_email`, contact_a.do_not_phone as `do_not_phone`, contact_a.do_not_mail as `do_not_mail`,' . ' contact_a.do_not_sms as `do_not_sms`, contact_a.do_not_trade as `do_not_trade`, contact_a.is_opt_out as `is_opt_out`, contact_a.legal_identifier as `legal_identifier`,' - . ' contact_a.external_identifier as `external_identifier`, contact_a.nick_name as `nick_name`, contact_a.legal_name as `legal_name`, contact_a.image_URL as `image_URL`,' + . ' contact_a.nick_name as `nick_name`, contact_a.legal_name as `legal_name`, contact_a.image_URL as `image_URL`,' . ' contact_a.preferred_communication_method as `preferred_communication_method`, contact_a.preferred_language as `preferred_language`,' - . ' contact_a.first_name as `first_name`, contact_a.middle_name as `middle_name`, contact_a.last_name as `last_name`,' . ' contact_a.prefix_id as `prefix_id`, contact_a.suffix_id as `suffix_id`, contact_a.formal_title as `formal_title`, contact_a.communication_style_id as `communication_style_id`,' . ' contact_a.job_title as `job_title`, contact_a.gender_id as `gender_id`, contact_a.birth_date as `birth_date`, contact_a.is_deceased as `is_deceased`,' . ' contact_a.deceased_date as `deceased_date`, contact_a.household_name as `household_name`,' - . ' IF ( contact_a.contact_type = \'Individual\', NULL, contact_a.organization_name ) as organization_name, contact_a.sic_code as `sic_code`, contact_a.is_deleted as `contact_is_deleted`,' + . ' contact_a.sic_code as `sic_code`, contact_a.is_deleted as `contact_is_deleted`,' . ' IF ( contact_a.contact_type = \'Individual\', contact_a.organization_name, NULL ) as current_employer, civicrm_address.id as address_id,' . ' civicrm_address.street_address as `street_address`, civicrm_address.supplemental_address_1 as `supplemental_address_1`, ' . 'civicrm_address.supplemental_address_2 as `supplemental_address_2`, civicrm_address.supplemental_address_3 as `supplemental_address_3`, civicrm_address.city as `city`, civicrm_address.postal_code_suffix as `postal_code_suffix`, ' diff --git a/tests/phpunit/CRM/Export/BAO/ExportTest.php b/tests/phpunit/CRM/Export/BAO/ExportTest.php index cd2015fc1f..dcbdd770de 100644 --- a/tests/phpunit/CRM/Export/BAO/ExportTest.php +++ b/tests/phpunit/CRM/Export/BAO/ExportTest.php @@ -147,6 +147,8 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase { /** * Implements hook_civicrm_export(). + * + * @throws \Civi\Core\Exception\DBQueryException */ public function confirmHookWasCalled($exportTempTable, &$headerRows, &$sqlColumns, $exportMode, $componentTable, $ids): void { $sqlColumns['display'] = 'display varchar(255)'; @@ -2219,41 +2221,41 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase { $headers = [ 0 => 'Contact ID', 1 => 'Contact Type', - 2 => 'Contact Subtype', - 3 => 'Do Not Email', - 4 => 'Do Not Phone', - 5 => 'Do Not Mail', - 6 => 'Do Not Sms', - 7 => 'Do Not Trade', - 8 => 'No Bulk Emails (User Opt Out)', - 9 => 'Legal Identifier', - 10 => 'External Identifier', - 11 => 'Sort Name', - 12 => 'Display Name', - 13 => 'Nickname', - 14 => 'Legal Name', - 15 => 'Image Url', - 16 => 'Preferred Communication Method', - 17 => 'Preferred Language', - 18 => 'Contact Hash', - 19 => 'Contact Source', - 20 => 'First Name', - 21 => 'Middle Name', - 22 => 'Last Name', - 23 => 'Individual Prefix', - 24 => 'Individual Suffix', - 25 => 'Formal Title', - 26 => 'Communication Style', - 27 => 'Email Greeting ID', - 28 => 'Postal Greeting ID', - 29 => 'Addressee ID', - 30 => 'Job Title', - 31 => 'Gender', - 32 => 'Birth Date', - 33 => 'Deceased', - 34 => 'Deceased Date', - 35 => 'Household Name', - 36 => 'Organization Name', + 2 => 'External Identifier', + 3 => 'Display Name', + 4 => 'Organization Name', + 5 => 'Contact Subtype', + 6 => 'First Name', + 7 => 'Middle Name', + 8 => 'Last Name', + 9 => 'Do Not Email', + 10 => 'Do Not Phone', + 11 => 'Do Not Mail', + 12 => 'Do Not Sms', + 13 => 'Do Not Trade', + 14 => 'No Bulk Emails (User Opt Out)', + 15 => 'Legal Identifier', + 16 => 'Sort Name', + 17 => 'Nickname', + 18 => 'Legal Name', + 19 => 'Image Url', + 20 => 'Preferred Communication Method', + 21 => 'Preferred Language', + 22 => 'Contact Hash', + 23 => 'Contact Source', + 24 => 'Individual Prefix', + 25 => 'Individual Suffix', + 26 => 'Formal Title', + 27 => 'Communication Style', + 28 => 'Email Greeting ID', + 29 => 'Postal Greeting ID', + 30 => 'Addressee ID', + 31 => 'Job Title', + 32 => 'Gender', + 33 => 'Birth Date', + 34 => 'Deceased', + 35 => 'Deceased Date', + 36 => 'Household Name', 37 => 'Sic Code', 38 => 'Unique ID (OpenID)', 39 => 'Current Employer ID', -- 2.25.1