From: Eileen McNaughton Date: Fri, 1 Dec 2023 03:37:12 +0000 (+1300) Subject: Add suffix to sort name X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=d21e8d5597b60318a848776a8019f294d8d3a31e;p=civicrm-core.git Add suffix to sort name Revives https://github.com/civicrm/civicrm-core/pull/27114 --- diff --git a/ext/legacycustomsearches/tests/phpunit/Civi/Searches/GroupTest.php b/ext/legacycustomsearches/tests/phpunit/Civi/Searches/GroupTest.php index 7bff678351..ed40a2dfe8 100644 --- a/ext/legacycustomsearches/tests/phpunit/Civi/Searches/GroupTest.php +++ b/ext/legacycustomsearches/tests/phpunit/Civi/Searches/GroupTest.php @@ -300,7 +300,7 @@ class GroupTest extends TestCase implements HeadlessInterface, HookInterface, Tr $full[] = [ 'contact_id' => $this->ids['Contact'][$id], 'contact_type' => 'Individual', - 'sort_name' => 'Contact ' . $id . ', Test', + 'sort_name' => 'Contact ' . $id . ', Test II', ]; } } diff --git a/settings/Core.setting.php b/settings/Core.setting.php index 2864da74d7..9f2177c621 100644 --- a/settings/Core.setting.php +++ b/settings/Core.setting.php @@ -155,7 +155,7 @@ return [ 'name' => 'sort_name_format', 'type' => 'String', 'html_type' => 'textarea', - 'default' => '{contact.last_name}{, }{contact.first_name}', + 'default' => '{contact.last_name}{, }{contact.first_name}{ }{contact.suffix_id:label}', 'add' => '4.1', 'title' => ts('Individual Sort Name Format'), 'is_domain' => 1, diff --git a/tests/phpunit/CRM/Activity/BAO/ActivityTest.php b/tests/phpunit/CRM/Activity/BAO/ActivityTest.php index 47e51e0385..8e48f5ac6c 100644 --- a/tests/phpunit/CRM/Activity/BAO/ActivityTest.php +++ b/tests/phpunit/CRM/Activity/BAO/ActivityTest.php @@ -217,7 +217,7 @@ class CRM_Activity_BAO_ActivityTest extends CiviUnitTestCase { $activityGetParams += ['contact_id' => $contactId]; $activities = CRM_Activity_BAO_Activity::getContactActivitySelector($activityGetParams); // Assert that we have sensible data to display in the contact tab - $this->assertEquals('Anderson, Anthony', $activities['data'][0]['source_contact_name']); + $this->assertEquals('Anderson, Anthony II', $activities['data'][0]['source_contact_name']); // Note that because there is a target contact but it is not accessible the output is an empty string not n/a $this->assertEquals('', $activities['data'][0]['target_contact_name']); // verify that doing the underlying query shows we get a target contact_id @@ -709,9 +709,9 @@ class CRM_Activity_BAO_ActivityTest extends CiviUnitTestCase { $activities = CRM_Activity_BAO_Activity::getActivities($params); //verify target count $this->assertEquals($targetCount, $activities[1]['target_contact_count']); - $this->assertEquals([$targetContactIDs[0] => 'Anderson, Anthony'], $activities[1]['target_contact_name']); - $this->assertEquals('Anderson, Anthony', $activities[1]['source_contact_name']); - $this->assertEquals('Anderson, Anthony', $activities[1]['assignee_contact_name'][4]); + $this->assertEquals([$targetContactIDs[0] => 'Anderson, Anthony II'], $activities[1]['target_contact_name']); + $this->assertEquals('Anderson, Anthony II', $activities[1]['source_contact_name']); + $this->assertEquals('Anderson, Anthony II', $activities[1]['assignee_contact_name'][4]); } /** diff --git a/tests/phpunit/CRM/Activity/Form/ActivityViewTest.php b/tests/phpunit/CRM/Activity/Form/ActivityViewTest.php index ec5eef08e8..5ee3fec3f5 100644 --- a/tests/phpunit/CRM/Activity/Form/ActivityViewTest.php +++ b/tests/phpunit/CRM/Activity/Form/ActivityViewTest.php @@ -86,9 +86,9 @@ class CRM_Activity_Form_ActivityViewTest extends CiviUnitTestCase { $expected = [ 'assignee_contact' => [0 => $activity['target_contact_id']], // it's always Julia - 'assignee_contact_value' => 'Anderson, Julia', + 'assignee_contact_value' => 'Anderson, Julia II', 'target_contact' => [0 => $activity['target_contact_id']], - 'target_contact_value' => 'Anderson, Julia', + 'target_contact_value' => 'Anderson, Julia II', 'source_contact' => $activityMoreInfo['source_contact_sort_name'], 'case_subject' => NULL, 'id' => $activity['id'], diff --git a/tests/phpunit/CRM/Activity/Form/SearchTest.php b/tests/phpunit/CRM/Activity/Form/SearchTest.php index 696068edd8..4b9d7fb96a 100644 --- a/tests/phpunit/CRM/Activity/Form/SearchTest.php +++ b/tests/phpunit/CRM/Activity/Form/SearchTest.php @@ -47,7 +47,7 @@ class CRM_Activity_Form_SearchTest extends CiviUnitTestCase { [ 'contact_id' => '3', 'contact_type' => '', - 'sort_name' => 'Anderson, Anthony', + 'sort_name' => 'Anderson, Anthony II', 'display_name' => 'Mr. Anthony Anderson II', 'activity_id' => '1', 'activity_date_time' => '2017-01-30 00:00:00', @@ -61,7 +61,7 @@ class CRM_Activity_Form_SearchTest extends CiviUnitTestCase { 'target_contact_name' => [], 'assignee_contact_name' => [], 'source_contact_id' => '3', - 'source_contact_name' => 'Anderson, Anthony', + 'source_contact_name' => 'Anderson, Anthony II', 'checkbox' => 'mark_x_1', 'mailingId' => '', 'action' => 'View', diff --git a/tests/phpunit/CRM/Contact/BAO/ContactTest.php b/tests/phpunit/CRM/Contact/BAO/ContactTest.php index a30e4365a5..4883d23662 100644 --- a/tests/phpunit/CRM/Contact/BAO/ContactTest.php +++ b/tests/phpunit/CRM/Contact/BAO/ContactTest.php @@ -91,7 +91,7 @@ class CRM_Contact_BAO_ContactTest extends CiviUnitTestCase { $this->assertEquals('1', $contact->do_not_trade, 'Check for do_not_trade creation.'); $this->assertEquals('1', $contact->is_opt_out, 'Check for is_opt_out creation.'); $this->assertEquals($params['external_identifier'], $contact->external_identifier, 'Check for external_identifier creation.'); - $this->assertEquals($params['last_name'] . ', ' . $params['first_name'], $contact->sort_name, 'Check for sort_name creation.'); + $this->assertEquals($params['last_name'] . ', ' . $params['first_name'] . ' Sr.', $contact->sort_name, 'Check for sort_name creation.'); $this->assertEquals($params['contact_source'], $contact->source, 'Check for contact_source creation.'); $this->assertEquals($params['prefix_id'], $contact->prefix_id, 'Check for prefix_id creation.'); diff --git a/tests/phpunit/CRM/Contact/BAO/IndividualTest.php b/tests/phpunit/CRM/Contact/BAO/IndividualTest.php index 0928bfda59..8027aee25d 100644 --- a/tests/phpunit/CRM/Contact/BAO/IndividualTest.php +++ b/tests/phpunit/CRM/Contact/BAO/IndividualTest.php @@ -45,14 +45,14 @@ class CRM_Contact_BAO_IndividualTest extends CiviUnitTestCase { $contact = new CRM_Contact_DAO_Contact(); CRM_Contact_BAO_Individual::format($params, $contact); $this->assertEquals('Mr. Ben Lee Jr.', $contact->display_name); - $this->assertEquals('Lee, Ben', $contact->sort_name); + $this->assertEquals('Lee, Ben Jr.', $contact->sort_name); // Check with legacy tokens too. \Civi::settings()->set('display_name_format', '{contact.individual_prefix}{ }{contact.first_name}{ }{contact.last_name}{ }{contact.individual_suffix}'); $contact = new CRM_Contact_DAO_Contact(); CRM_Contact_BAO_Individual::format($params, $contact); $this->assertEquals('Mr. Ben Lee Jr.', $contact->display_name); - $this->assertEquals('Lee, Ben', $contact->sort_name); + $this->assertEquals('Lee, Ben Jr.', $contact->sort_name); } /** diff --git a/tests/phpunit/CRM/Contact/BAO/QueryTest.php b/tests/phpunit/CRM/Contact/BAO/QueryTest.php index a7c3835394..e5a868fbac 100644 --- a/tests/phpunit/CRM/Contact/BAO/QueryTest.php +++ b/tests/phpunit/CRM/Contact/BAO/QueryTest.php @@ -561,7 +561,7 @@ class CRM_Contact_BAO_QueryTest extends CiviUnitTestCase { [$select, $from, $where, $having] = $queryObj->query(); $dao = CRM_Core_DAO::executeQuery("$select $from $where $having"); $dao->fetch(); - $this->assertEquals('Anderson, Anthony', $dao->sort_name); + $this->assertEquals('Anderson, Anthony II', $dao->sort_name); } catch (PEAR_Exception $e) { $err = $e->getCause(); diff --git a/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php b/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php index 664d0855b3..9036857b4a 100644 --- a/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php +++ b/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php @@ -331,7 +331,7 @@ class CRM_Contribute_BAO_ContributionTest extends CiviUnitTestCase { $contributionID = $this->callAPISuccess('Contribution', 'create', $param)['id']; // Display sort name during Update multiple contributions. - $this->assertEquals('Watson, Shane', CRM_Contribute_BAO_Contribution::sortName($contributionID)); + $this->assertEquals('Watson, Shane II', CRM_Contribute_BAO_Contribution::sortName($contributionID)); } /** diff --git a/tests/phpunit/CRM/Core/BAO/MessageTemplateTest.php b/tests/phpunit/CRM/Core/BAO/MessageTemplateTest.php index 8b51e6f0eb..88ad55b1d5 100644 --- a/tests/phpunit/CRM/Core/BAO/MessageTemplateTest.php +++ b/tests/phpunit/CRM/Core/BAO/MessageTemplateTest.php @@ -879,7 +879,7 @@ emo 'do_not_trade' => 1, 'is_opt_out' => 1, 'external_identifier' => 'blah', - 'sort_name' => 'Smith, Robert', + 'sort_name' => 'Smith, Robert II', 'display_name' => 'Robert Smith', 'nick_name' => 'Bob', 'image_URL' => 'https://example.com', @@ -1071,7 +1071,7 @@ do_not_sms:1 do_not_trade:1 is_opt_out:1 external_identifier:blah -sort_name:Smith, Robert +sort_name:Smith, Robert II display_name:Mr. Robert Smith II nick_name:Bob image_URL:https://example.com @@ -1170,7 +1170,7 @@ do_not_sms:label |Yes do_not_trade:label |Yes is_opt_out:label |Yes external_identifier |blah -sort_name |Smith, Robert +sort_name |Smith, Robert II display_name |Mr. Robert Smith II nick_name |Bob image_URL |https://example.com diff --git a/tests/phpunit/CRM/Event/BAO/ParticipantTest.php b/tests/phpunit/CRM/Event/BAO/ParticipantTest.php index b2d6a98ea6..685fe9efb1 100644 --- a/tests/phpunit/CRM/Event/BAO/ParticipantTest.php +++ b/tests/phpunit/CRM/Event/BAO/ParticipantTest.php @@ -166,7 +166,7 @@ class CRM_Event_BAO_ParticipantTest extends CiviUnitTestCase { */ public function testParticipantDetails(): void { $participant = $this->callAPISuccess('Participant', 'create', ['contact_id' => $this->ids['Contact']['individual_0'], 'event_id' => $this->getEventID()]); - $params = ['name' => 'Anderson, Anthony', 'title' => 'Annual CiviCRM meet']; + $params = ['name' => 'Anderson, Anthony II', 'title' => 'Annual CiviCRM meet']; $participantDetails = CRM_Event_BAO_Participant::participantDetails($participant['id']); diff --git a/tests/phpunit/CRM/Export/BAO/ExportTest.php b/tests/phpunit/CRM/Export/BAO/ExportTest.php index ab50d16714..c5deaaedd0 100644 --- a/tests/phpunit/CRM/Export/BAO/ExportTest.php +++ b/tests/phpunit/CRM/Export/BAO/ExportTest.php @@ -192,7 +192,7 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase { $row = $this->csv->fetchOne(1); $this->assertEquals(95, $row['Net Amount']); $this->assertEquals(5, $row['Soft Credit Amount']); - $this->assertEquals('Anderson, Anthony', $row['Soft Credit For']); + $this->assertEquals('Anderson, Anthony II', $row['Soft Credit For']); $this->assertEquals($this->contributionIDs[0], $row['Soft Credit For Contribution ID']); // Ideally we would use a randomised temp table name & use generic temp cleanup for cleanup - but @@ -230,7 +230,7 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase { 'No Bulk Emails (User Opt Out)' => '', 'Legal Identifier' => '', 'External Identifier' => '', - 'Sort Name' => 'Anderson, Anthony', + 'Sort Name' => 'Anderson, Anthony II', 'Display Name' => 'Mr. Anthony Anderson II', 'Nickname' => '', 'Legal Name' => '', @@ -1082,7 +1082,7 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase { 'No Bulk Emails (User Opt Out)' => '', 'Legal Identifier' => '', 'External Identifier' => '', - 'Sort Name' => 'Anderson, Anthony', + 'Sort Name' => 'Anderson, Anthony II', 'Display Name' => 'Mr. Anthony Anderson II', 'Nickname' => '', 'Legal Name' => '', diff --git a/tests/phpunit/CRM/Financial/Page/AjaxTest.php b/tests/phpunit/CRM/Financial/Page/AjaxTest.php index b3d1801496..2cf77684a7 100644 --- a/tests/phpunit/CRM/Financial/Page/AjaxTest.php +++ b/tests/phpunit/CRM/Financial/Page/AjaxTest.php @@ -43,7 +43,7 @@ class CRM_Financial_Page_AjaxTest extends CiviUnitTestCase { $json = CRM_Financial_Page_AJAX::getFinancialTransactionsList(); $json = str_replace(rtrim(CIVICRM_UF_BASEURL, '/'), 'http://FIX ME', $json); $this->assertEquals('{"sEcho": 1, "iTotalRecords": 1, "iTotalDisplayRecords": 1, "aaData": [ ["","' - . '","Anderson, Anthony","$100.00","12345","' . CRM_Utils_Date::customFormat(date('Ymd')) . ' 12:00 AM","' . CRM_Utils_Date::customFormat(date('Ymd')) . ' 12:00 AM",' + . '","Anderson, Anthony II","$100.00","12345","' . CRM_Utils_Date::customFormat(date('Ymd')) . ' 12:00 AM","' . CRM_Utils_Date::customFormat(date('Ymd')) . ' 12:00 AM",' . '"Credit Card","Completed","Donation","View"]] }', $json); } @@ -67,7 +67,7 @@ class CRM_Financial_Page_AjaxTest extends CiviUnitTestCase { $json = CRM_Financial_Page_AJAX::getFinancialTransactionsList(); $json = str_replace(rtrim(CIVICRM_UF_BASEURL, '/'), 'http://FIX ME', $json); $this->assertEquals('{"sEcho": 1, "iTotalRecords": 1, "iTotalDisplayRecords": 1, "aaData": [ ["","' - . '","Anderson, Anthony","$5.00","12345","' . CRM_Utils_Date::customFormat(date('Ymd')) . ' 12:00 AM","' . CRM_Utils_Date::customFormat(date('Ymd')) . ' 12:00 AM",' + . '","Anderson, Anthony II","$5.00","12345","' . CRM_Utils_Date::customFormat(date('Ymd')) . ' 12:00 AM","' . CRM_Utils_Date::customFormat(date('Ymd')) . ' 12:00 AM",' . '"Credit Card","Completed","Donation","ViewAssign"]] }', $json); } diff --git a/tests/phpunit/CRM/Member/BAO/MembershipTest.php b/tests/phpunit/CRM/Member/BAO/MembershipTest.php index 67cfe4388f..353c5d7a67 100644 --- a/tests/phpunit/CRM/Member/BAO/MembershipTest.php +++ b/tests/phpunit/CRM/Member/BAO/MembershipTest.php @@ -443,7 +443,7 @@ class CRM_Member_BAO_MembershipTest extends CiviUnitTestCase { $membership = $this->callAPISuccess('Membership', 'create', $params); - $this->assertEquals('Anderson, Anthony', CRM_Member_BAO_Membership::sortName($membership['id'])); + $this->assertEquals('Anderson, Anthony II', CRM_Member_BAO_Membership::sortName($membership['id'])); $this->membershipDelete($membership['id']); $this->contactDelete($contactId); diff --git a/tests/phpunit/CRM/Member/Selector/SearchTest.php b/tests/phpunit/CRM/Member/Selector/SearchTest.php index b53381b218..31117da0aa 100644 --- a/tests/phpunit/CRM/Member/Selector/SearchTest.php +++ b/tests/phpunit/CRM/Member/Selector/SearchTest.php @@ -32,7 +32,7 @@ class CRM_Member_Selector_SearchTest extends CiviUnitTestCase { 'contact_id' => $contactID, 'membership_id' => $membershipID, 'contact_type' => '', - 'sort_name' => 'Anderson, Anthony', + 'sort_name' => 'Anderson, Anthony II', 'membership_type' => 'General', 'membership_join_date' => date('Y-m-d'), 'membership_start_date' => date('Y-m-d'), diff --git a/tests/phpunit/CRM/Pledge/Form/SearchTest.php b/tests/phpunit/CRM/Pledge/Form/SearchTest.php index 614860e56f..ff5e0bea73 100644 --- a/tests/phpunit/CRM/Pledge/Form/SearchTest.php +++ b/tests/phpunit/CRM/Pledge/Form/SearchTest.php @@ -35,7 +35,7 @@ class CRM_Pledge_Form_SearchTest extends CiviUnitTestCase { $rows = $form->controller->get('rows'); $this->assertEquals([ 'contact_id' => '3', - 'sort_name' => 'Anderson, Anthony', + 'sort_name' => 'Anderson, Anthony II', 'display_name' => 'Mr. Anthony Anderson II', 'pledge_id' => '1', 'pledge_amount' => 100.00, diff --git a/tests/phpunit/api/v3/ActivityTest.php b/tests/phpunit/api/v3/ActivityTest.php index 3de379cc7b..9c977dd715 100644 --- a/tests/phpunit/api/v3/ActivityTest.php +++ b/tests/phpunit/api/v3/ActivityTest.php @@ -517,10 +517,10 @@ class api_v3_ActivityTest extends CiviUnitTestCase { 'id' => $result['id'], ]); - $this->assertEquals('Anderson, Anthony', $result['values'][$result['id']]['custom_' . $customField['id']]); - $this->assertEquals($this->_contactID, $result['values'][$result['id']]['custom_' . $customField['id'] . "_id"], ' in line ' . __LINE__); - $this->assertEquals('Anderson, Anthony', $result['values'][$result['id']]['custom_' . $customField['id'] . '_1'], ' in line ' . __LINE__); - $this->assertEquals($this->_contactID, $result['values'][$result['id']]['custom_' . $customField['id'] . "_1_id"], ' in line ' . __LINE__); + $this->assertEquals('Anderson, Anthony II', $result['values'][$result['id']]['custom_' . $customField['id']]); + $this->assertEquals($this->_contactID, $result['values'][$result['id']]['custom_' . $customField['id'] . '_id']); + $this->assertEquals('Anderson, Anthony II', $result['values'][$result['id']]['custom_' . $customField['id'] . '_1']); + $this->assertEquals($this->_contactID, $result['values'][$result['id']]['custom_' . $customField['id'] . '_1_id']); $this->customFieldDelete($ids['custom_field_id']); $this->customGroupDelete($ids['custom_group_id']); } diff --git a/tests/phpunit/api/v3/LoggingTest.php b/tests/phpunit/api/v3/LoggingTest.php index 6dfadcfbd1..d96cef7c70 100644 --- a/tests/phpunit/api/v3/LoggingTest.php +++ b/tests/phpunit/api/v3/LoggingTest.php @@ -401,6 +401,8 @@ class api_v3_LoggingTest extends CiviUnitTestCase { /** * Test changes can be retrieved. + * + * @throws \CRM_Core_Exception */ public function testGet(): void { $contactId = $this->individualCreate(); @@ -417,13 +419,15 @@ class api_v3_LoggingTest extends CiviUnitTestCase { ]); $this->callAPISuccessGetSingle('email', ['email' => 'dopey@mail.com']); $diffs = $this->callAPISuccess('Logging', 'get', ['log_conn_id' => 'wooty woot', 'log_date' => $timeStamp], __FUNCTION__, __FILE__); - $this->assertLoggingIncludes($diffs['values'], ['to' => 'Dwarf, Dopey']); + $this->assertLoggingIncludes($diffs['values'], ['to' => 'Dwarf, Dopey II']); $this->assertLoggingIncludes($diffs['values'], ['to' => 'Mr. Dopey Dwarf II', 'table' => 'civicrm_contact', 'action' => 'Update', 'field' => 'display_name']); $this->assertLoggingIncludes($diffs['values'], ['to' => 'dopey@mail.com', 'table' => 'civicrm_email', 'action' => 'Insert', 'field' => 'email']); } /** * Test changes can be retrieved without log_date being required. + * + * @throws \CRM_Core_Exception */ public function testGetNoDate(): void { $contactId = $this->individualCreate(); @@ -440,7 +444,7 @@ class api_v3_LoggingTest extends CiviUnitTestCase { ]); $this->callAPISuccessGetSingle('email', ['email' => 'dopey@mail.com']); $diffs = $this->callAPISuccess('Logging', 'get', ['log_conn_id' => 'wooty wop wop']); - $this->assertLoggingIncludes($diffs['values'], ['to' => 'Dwarf, Dopey']); + $this->assertLoggingIncludes($diffs['values'], ['to' => 'Dwarf, Dopey II']); $this->assertLoggingIncludes($diffs['values'], ['to' => 'Mr. Dopey Dwarf II', 'table' => 'civicrm_contact', 'action' => 'Update', 'field' => 'display_name']); $this->assertLoggingIncludes($diffs['values'], ['to' => 'dopey@mail.com', 'table' => 'civicrm_email', 'action' => 'Insert', 'field' => 'email']); } diff --git a/tests/phpunit/api/v3/ReportTemplateTest.php b/tests/phpunit/api/v3/ReportTemplateTest.php index de4bf35df6..487380e8c8 100644 --- a/tests/phpunit/api/v3/ReportTemplateTest.php +++ b/tests/phpunit/api/v3/ReportTemplateTest.php @@ -602,7 +602,7 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase { 'options' => ['metadata' => ['sql']], ]); $this->assertEquals( - "Anderson, Anthony $ 5.00", + "Anderson, Anthony II $ 5.00", $rows['values'][0]['civicrm_contribution_soft_credits'] ); } @@ -1209,9 +1209,9 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase { $rows = $this->callAPISuccess('report_template', 'getrows', $params)['values']; $expected = [ - 'civicrm_contact_contact_source' => 'Łąchowski-Roberts, Anthony', - 'civicrm_contact_contact_assignee' => 'Łąchowski-Roberts, Anthony', - 'civicrm_contact_contact_target' => 'Brzęczysław, Anthony; Łąchowski-Roberts, Anthony', + 'civicrm_contact_contact_source' => 'Łąchowski-Roberts, Anthony II', + 'civicrm_contact_contact_assignee' => 'Łąchowski-Roberts, Anthony II', + 'civicrm_contact_contact_target' => 'Brzęczysław, Anthony II; Łąchowski-Roberts, Anthony II', 'civicrm_contact_contact_source_id' => $this->contactIDs[2], 'civicrm_contact_contact_assignee_id' => $this->contactIDs[1], 'civicrm_contact_contact_target_id' => $this->contactIDs[0] . ';' . $this->contactIDs[1],