From c26679b76114b4348db92952e3f313b89b947754 Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 1 May 2020 13:14:16 +1200 Subject: [PATCH] [NFC][Test] Preliminary cleanup Margin cleanup - declare exceptions, use right quotes, remove unused params --- tests/phpunit/CRM/Contact/BAO/QueryTest.php | 65 ++++++++++------ tests/phpunit/api/v3/ContactTest.php | 86 +++++++++++++++------ 2 files changed, 104 insertions(+), 47 deletions(-) diff --git a/tests/phpunit/CRM/Contact/BAO/QueryTest.php b/tests/phpunit/CRM/Contact/BAO/QueryTest.php index a4b89a0fa719..270e083a57e0 100644 --- a/tests/phpunit/CRM/Contact/BAO/QueryTest.php +++ b/tests/phpunit/CRM/Contact/BAO/QueryTest.php @@ -200,7 +200,7 @@ public function testSearch($fv, $count, $ids) { */ public function testSearchProfileHomeCityCRM14263() { $contactID = $this->individualCreate(); - CRM_Core_Config::singleton()->defaultSearchProfileID = 1; + Civi::settings()->set('defaultSearchProfileID', 1); $this->callAPISuccess('address', 'create', [ 'contact_id' => $contactID, 'city' => 'Cool City', @@ -228,7 +228,7 @@ public function testSearchProfileHomeCityCRM14263() { } catch (PEAR_Exception $e) { $err = $e->getCause(); - $this->fail('invalid SQL created' . $e->getMessage() . " " . $err->userinfo); + $this->fail('invalid SQL created' . $e->getMessage() . ' ' . $err->userinfo); } } @@ -241,7 +241,7 @@ public function testSearchProfileHomeCityCRM14263() { */ public function testSearchProfileHomeCityNoResultsCRM14263() { $contactID = $this->individualCreate(); - CRM_Core_Config::singleton()->defaultSearchProfileID = 1; + Civi::settings()->set('defaultSearchProfileID', 1); $this->callAPISuccess('address', 'create', [ 'contact_id' => $contactID, 'city' => 'Cool City', @@ -269,7 +269,7 @@ public function testSearchProfileHomeCityNoResultsCRM14263() { } catch (PEAR_Exception $e) { $err = $e->getCause(); - $this->fail('invalid SQL created' . $e->getMessage() . " " . $err->userinfo); + $this->fail('invalid SQL created' . $e->getMessage() . ' ' . $err->userinfo); } } @@ -388,7 +388,7 @@ public function testSearchOtherLocationUpperLower() { */ public function testSearchProfilePrimaryCityCRM14263($params, $selectClause, $whereClause) { $contactID = $this->individualCreate(); - CRM_Core_Config::singleton()->defaultSearchProfileID = 1; + Civi::settings()->set('defaultSearchProfileID', 1); $this->callAPISuccess('address', 'create', [ 'contact_id' => $contactID, 'city' => 'Cool CITY', @@ -400,7 +400,7 @@ public function testSearchProfilePrimaryCityCRM14263($params, $selectClause, $wh 'contact_sub_type' => 1, 'sort_name' => 1, ]; - $expectedSQL = "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`, civicrm_address.id as address_id, " . $selectClause . " FROM civicrm_contact contact_a LEFT JOIN civicrm_address ON ( contact_a.id = civicrm_address.contact_id AND civicrm_address.is_primary = 1 ) WHERE ( ( " . $whereClause . " ) ) AND (contact_a.is_deleted = 0) ORDER BY `contact_a`.`sort_name` ASC, `contact_a`.`id` "; + $expectedSQL = '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`, civicrm_address.id as address_id, ' . $selectClause . " FROM civicrm_contact contact_a LEFT JOIN civicrm_address ON ( contact_a.id = civicrm_address.contact_id AND civicrm_address.is_primary = 1 ) WHERE ( ( " . $whereClause . " ) ) AND (contact_a.is_deleted = 0) ORDER BY `contact_a`.`sort_name` ASC, `contact_a`.`id` "; $queryObj = new CRM_Contact_BAO_Query($params, $returnProperties); try { $this->assertLike($expectedSQL, $queryObj->getSearchSQL()); @@ -411,7 +411,7 @@ public function testSearchProfilePrimaryCityCRM14263($params, $selectClause, $wh } catch (PEAR_Exception $e) { $err = $e->getCause(); - $this->fail('invalid SQL created' . $e->getMessage() . " " . $err->userinfo); + $this->fail('invalid SQL created' . $e->getMessage() . ' ' . $err->userinfo); } } @@ -423,7 +423,7 @@ public function getSearchProfileData() { return [ [ [['city', '=', 'Cool City', 1, 0]], - "civicrm_address.city as `city`", + 'civicrm_address.city as `city`', "civicrm_address.city = 'Cool City'", ], [ @@ -431,7 +431,7 @@ public function getSearchProfileData() { // it doesn't work on some charsets. However, the the lcasing affects more vars & we are looking to stagger removal of lcasing 'in case' // (although we have been removing without blowback since 2017) [['street_address', '=', 'Long Street', 1, 0]], - "civicrm_address.street_address as `street_address`", + 'civicrm_address.street_address as `street_address`', "civicrm_address.street_address LIKE '%Long Street%'", ], ]; @@ -454,7 +454,7 @@ public function testGroupContactCacheAddSearch() { TRUE, FALSE ); - list($select) = $query->query(FALSE); + list($select) = $query->query(); $this->assertEquals('SELECT contact_a.id as contact_id', $select); } @@ -486,7 +486,7 @@ public function testNumericPostal() { TRUE, FALSE ); - $sql = $query->query(FALSE); + $sql = $query->query(); $result = CRM_Core_DAO::executeQuery(implode(' ', $sql)); $this->assertEquals(2, $result->N); @@ -653,13 +653,15 @@ public function testNonReciprocalRelationshipTargetGroupIsCorrectResults() { $query = new CRM_Contact_BAO_Query($params); $dao = $query->searchQuery(); - $this->assertEquals('1', $dao->N, "Search query returns exactly 1 result?"); - $this->assertTrue($dao->fetch(), "Search query returns success?"); - $this->assertEquals($contactID_b, $dao->contact_id, "Search query returns parent of contact A?"); + $this->assertEquals('1', $dao->N, 'Search query returns exactly 1 result?'); + $this->assertTrue($dao->fetch(), 'Search query returns success?'); + $this->assertEquals($contactID_b, $dao->contact_id, 'Search query returns parent of contact A?'); } /** * Relationship search with custom fields. + * + * @throws \CRM_Core_Exception */ public function testReciprocalRelationshipWithCustomFields() { $params = [ @@ -751,11 +753,16 @@ public function testReciprocalRelationshipTargetGroupIsCorrectResults() { $query = new CRM_Contact_BAO_Query($params); $dao = $query->searchQuery(); - $this->assertEquals('1', $dao->N, "Search query returns exactly 1 result?"); - $this->assertTrue($dao->fetch(), "Search query returns success?"); - $this->assertEquals($contactID_b, $dao->contact_id, "Search query returns spouse of contact A?"); + $this->assertEquals('1', $dao->N, 'Search query returns exactly 1 result?'); + $this->assertTrue($dao->fetch(), 'Search query returns success?'); + $this->assertEquals($contactID_b, $dao->contact_id, 'Search query returns spouse of contact A?'); } + /** + * Test correct temporary table in reciprocal relationship search. + * + * @throws \CRM_Core_Exception + */ public function testReciprocalRelationshipTargetGroupUsesTempTable() { $groupID = $this->groupCreate(); $params = [ @@ -781,7 +788,7 @@ public function testReciprocalRelationshipTargetGroupUsesTempTable() { ], ]; $sql = CRM_Contact_BAO_Query::getQuery($params); - $this->assertContains('INNER JOIN civicrm_tmp_e', $sql, "Query appears to use temporary table of compiled relationships?", TRUE); + $this->assertContains('INNER JOIN civicrm_tmp_e', $sql, 'Query appears to use temporary table of compiled relationships?', TRUE); } /** @@ -802,8 +809,8 @@ public function testRelationshipPermissionClause() { */ public function testRelationshipClause() { $today = date('Ymd'); - $from1 = " FROM civicrm_contact contact_a LEFT JOIN civicrm_relationship ON (civicrm_relationship.contact_id_a = contact_a.id ) LEFT JOIN civicrm_contact contact_b ON (civicrm_relationship.contact_id_b = contact_b.id )"; - $from2 = " FROM civicrm_contact contact_a LEFT JOIN civicrm_relationship ON (civicrm_relationship.contact_id_b = contact_a.id ) LEFT JOIN civicrm_contact contact_b ON (civicrm_relationship.contact_id_a = contact_b.id )"; + $from1 = ' FROM civicrm_contact contact_a LEFT JOIN civicrm_relationship ON (civicrm_relationship.contact_id_a = contact_a.id ) LEFT JOIN civicrm_contact contact_b ON (civicrm_relationship.contact_id_b = contact_b.id )'; + $from2 = ' FROM civicrm_contact contact_a LEFT JOIN civicrm_relationship ON (civicrm_relationship.contact_id_b = contact_a.id ) LEFT JOIN civicrm_contact contact_b ON (civicrm_relationship.contact_id_a = contact_b.id )'; $where1 = "WHERE ( ( civicrm_relationship.is_active = 1 AND ( civicrm_relationship.end_date IS NULL OR civicrm_relationship.end_date >= {$today} ) AND @@ -822,7 +829,7 @@ public function testRelationshipClause() { TRUE, TRUE, FALSE ); - $sql1 = $query1->query(FALSE); + $sql1 = $query1->query(); $this->assertLike($from1, $sql1[1]); $this->assertLike($where1, $sql1[2]); // Test single relationship type selected in multiple select. @@ -855,7 +862,7 @@ public function testRelationshipClause() { TRUE, TRUE, FALSE ); - $sql4 = $query4->query(FALSE); + $sql4 = $query4->query(); $this->assertLike($from1, $sql4[1]); $this->assertLike($where2, $sql4[2]); @@ -960,8 +967,6 @@ public function testGroupClause() { /** * CRM-19562 ensure that only ids are used for contact_id searching. - * - * @throws \CRM_Core_Exception */ public function testContactIDClause() { $params = [ @@ -1123,6 +1128,11 @@ public function testGetSummaryQueryWithFinancialACLEnabled() { * Test relative date filters to ensure they generate correct SQL. * * @dataProvider relativeDateFilters + * + * @param string $filter + * @param string $expectedWhere + * + * @throws \CRM_Core_Exception */ public function testRelativeDateFilters($filter, $expectedWhere) { $params = [['created_date_relative', '=', $filter, 0, 0]]; @@ -1141,6 +1151,11 @@ public function testRelativeDateFilters($filter, $expectedWhere) { $this->assertEquals($expectedWhere, $where); } + /** + * Data provider to relative date filter configurations. + * + * @return array + */ public function relativeDateFilters() { $dataProvider[] = ['this.year', "WHERE ( contact_a.created_date BETWEEN 'date0' AND 'date1' ) AND (contact_a.is_deleted = 0)"]; $dataProvider[] = ['greater.day', "WHERE ( contact_a.created_date >= 'date0' ) AND (contact_a.is_deleted = 0)"]; @@ -1217,7 +1232,7 @@ public function testQillOptions() { */ public function testGenericWhereHandling() { $query = new CRM_Contact_BAO_Query([['suffix_id', '=', 2, 0]]); - $this->assertEquals("contact_a.suffix_id = 2", $query->_where[0][0]); + $this->assertEquals('contact_a.suffix_id = 2', $query->_where[0][0]); $this->assertEquals('Individual Suffix = Sr.', $query->_qill[0][0]); $this->assertNotTrue(isset($query->_tables['civicrm_activity'])); diff --git a/tests/phpunit/api/v3/ContactTest.php b/tests/phpunit/api/v3/ContactTest.php index 7c21d4d0a2d8..af306ee34aa1 100644 --- a/tests/phpunit/api/v3/ContactTest.php +++ b/tests/phpunit/api/v3/ContactTest.php @@ -683,6 +683,7 @@ public function testCreateApiKey($version) { * @param int $version * * @dataProvider versionThreeAndFour + * @throws \CRM_Core_Exception */ public function testCreateWithCustom($version) { $this->_apiversion = $version; @@ -690,7 +691,7 @@ public function testCreateWithCustom($version) { $params = $this->_params; $params['custom_' . $ids['custom_field_id']] = "custom string"; - $description = "This demonstrates setting a custom field through the API."; + $description = 'This demonstrates setting a custom field through the API.'; $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__, $description); $check = $this->callAPISuccess($this->_entity, 'get', [ @@ -705,6 +706,8 @@ public function testCreateWithCustom($version) { /** * CRM-12773 - expectation is that civicrm quietly ignores fields without values. + * + * @throws \CRM_Core_Exception */ public function testCreateWithNULLCustomCRM12773() { $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__); @@ -721,6 +724,8 @@ public function testCreateWithNULLCustomCRM12773() { * @param int $version * * @dataProvider versionThreeAndFour + * + * @throws \CRM_Core_Exception */ public function testCreatePreferredLanguageUnset($version) { $this->_apiversion = $version; @@ -739,6 +744,8 @@ public function testCreatePreferredLanguageUnset($version) { * @param int $version * * @dataProvider versionThreeAndFour + * + * @throws \CRM_Core_Exception */ public function testCreatePreferredLanguageSet($version) { $this->_apiversion = $version; @@ -755,6 +762,8 @@ public function testCreatePreferredLanguageSet($version) { /** * CRM-14232 test preferred language returns setting if not passed where setting is NULL. * TODO: Api4 + * + * @throws \CRM_Core_Exception */ public function testCreatePreferredLanguageNull() { $this->callAPISuccess('Setting', 'create', ['contact_default_language' => 'null']); @@ -773,6 +782,7 @@ public function testCreatePreferredLanguageNull() { * @param int $version * * @dataProvider versionThreeAndFour + * @throws \CRM_Core_Exception */ public function testCreatePreferredLanguagePassed($version) { $this->_apiversion = $version; @@ -789,6 +799,8 @@ public function testCreatePreferredLanguagePassed($version) { /** * CRM-15792 - create/update datetime field for contact. + * + * @throws \CRM_Core_Exception */ public function testCreateContactCustomFldDateTime() { $customGroup = $this->customGroupCreate(['extends' => 'Individual', 'title' => 'datetime_test_group']); @@ -926,6 +938,8 @@ public function testContactCreateDuplicateCurrentEmployerEnables() { * @param int $version * * @dataProvider versionThreeAndFour + * + * @throws \CRM_Core_Exception */ public function testGetDeceasedRetrieved($version) { $this->_apiversion = $version; @@ -942,6 +956,8 @@ public function testGetDeceasedRetrieved($version) { /** * Test that sort works - old syntax. + * + * @throws \CRM_Core_Exception */ public function testGetSort() { $c1 = $this->callAPISuccess($this->_entity, 'create', $this->_params); @@ -990,6 +1006,8 @@ public function testGetEmailLike() { * @param int $version * * @dataProvider versionThreeAndFour + * + * @throws \CRM_Core_Exception */ public function testGetINIDArray($version) { $this->_apiversion = $version; @@ -1014,6 +1032,8 @@ public function testGetINIDArray($version) { /** * Test variants on deleted behaviour. + * + * @throws \CRM_Core_Exception */ public function testGetDeleted() { $params = $this->_params; @@ -1092,6 +1112,7 @@ public function testGetSortNewSyntax($version) { * @param int $version * * @dataProvider versionThreeAndFour + * @throws \CRM_Core_Exception */ public function testSortLimitChainedRelationshipGetCRM15983($version) { $this->_apiversion = $version; @@ -3667,6 +3688,7 @@ public function testGetModifiedDateByOperators($version) { * @param int $version * * @dataProvider versionThreeAndFour + * @throws \CRM_Core_Exception */ public function testGetCreatedDateByOperators($version) { $this->_apiversion = $version; @@ -3688,10 +3710,12 @@ public function testGetCreatedDateByOperators($version) { /** * CRM-14263 check that API is not affected by search profile related bug. + * + * @throws \CRM_Core_Exception */ public function testReturnCityProfile() { $contactID = $this->individualCreate(); - CRM_Core_Config::singleton()->defaultSearchProfileID = 1; + Civi::settings()->set('defaultSearchProfileID', 1); $this->callAPISuccess('address', 'create', [ 'contact_id' => $contactID, 'city' => 'Cool City', @@ -4185,10 +4209,12 @@ public function testContactGetWithGroupTitle() { * Tests the following formats * contact.get group=array('title1', title1) * contact.get group=array('IN' => array('title1', 'title2) + * + * @throws \CRM_Core_Exception */ public function testContactGetWithGroupTitleMultipleGroups() { - $description = "Get all from group and display contacts."; - $subFile = "GroupFilterUsingContactAPI"; + $description = 'Get all from group and display contacts.'; + $subFile = 'GroupFilterUsingContactAPI'; // Set up a contact, asser that they were created. $contact_params = [ 'contact_type' => 'Individual', @@ -4196,9 +4222,9 @@ public function testContactGetWithGroupTitleMultipleGroups() { 'last_name' => 'Groupmember', 'email' => 'test@example.org', ]; - $create_contact = $this->callApiSuccess('Contact', 'create', $contact_params); + $create_contact = $this->callAPISuccess('Contact', 'create', $contact_params); $created_contact_id = $create_contact['id']; - $createdGroupsTitles = $createdGroupsIds = []; + $createdGroupsIds = []; // Set up multiple groups, add the contact to the groups. $test_groups = ['Test group C', 'Test group D']; foreach ($test_groups as $title) { @@ -4206,8 +4232,7 @@ public function testContactGetWithGroupTitleMultipleGroups() { 'title' => $title, 'created_id' => $created_contact_id, ]; - $create_group = $this->callApiSuccess('Group', 'create', $group_params); - $created_group_id = $create_group['id']; + $create_group = $this->callAPISuccess('Group', 'create', $group_params); $createdGroupsIds[] = $create_group['id']; $createdGroupTitles[] = $title; // Add contact to the new group. @@ -4215,7 +4240,7 @@ public function testContactGetWithGroupTitleMultipleGroups() { 'contact_id' => $created_contact_id, 'group_id' => $create_group['id'], ]; - $create_group_contact = $this->callApiSuccess('GroupContact', 'create', $group_contact_params); + $this->callAPISuccess('GroupContact', 'create', $group_contact_params); } $contact_get = $this->callAPISuccess('contact', 'get', ['group' => $createdGroupTitles, 'return' => 'group']); $this->assertEquals(1, $contact_get['count']); @@ -4224,7 +4249,7 @@ public function testContactGetWithGroupTitleMultipleGroups() { foreach ($createdGroupsIds as $id) { $this->assertContains((string) $id, $contact_groups); } - $contact_get2 = $this->callAPIAndDocument('contact', 'get', ['group' => ['IN' => $createdGroupTitles]], __FUNCTION__, __FILE__, $description, $subFile); + $this->callAPIAndDocument('contact', 'get', ['group' => ['IN' => $createdGroupTitles]], __FUNCTION__, __FILE__, $description, $subFile); $contact_get2 = $this->callAPISuccess('contact', 'get', ['group' => ['IN' => $createdGroupTitles], 'return' => 'group']); $this->assertEquals($created_contact_id, $contact_get2['id']); $contact_groups2 = explode(',', $contact_get2['values'][$created_contact_id]['groups']); @@ -4244,6 +4269,8 @@ public function testContactGetWithGroupTitleMultipleGroups() { * contact.get group=array('titke1' => 1, 'title2' => 1) * contact.get group=array('id1' => 1) * contact.get group=array('id1' => 1, id2 => 1) + * + * @throws \CRM_Core_Exception */ public function testContactGetWithGroupTitleMultipleGroupsLegacyFormat() { // Set up a contact, asser that they were created. @@ -4264,7 +4291,6 @@ public function testContactGetWithGroupTitleMultipleGroupsLegacyFormat() { 'created_id' => $created_contact_id, ]; $create_group = $this->callApiSuccess('Group', 'create', $group_params); - $created_group_id = $create_group['id']; $createdGroupsIds[] = $create_group['id']; $createdGroupTitles[] = $title; // Add contact to the new group. @@ -4272,7 +4298,7 @@ public function testContactGetWithGroupTitleMultipleGroupsLegacyFormat() { 'contact_id' => $created_contact_id, 'group_id' => $create_group['id'], ]; - $create_group_contact = $this->callApiSuccess('GroupContact', 'create', $group_contact_params); + $this->callApiSuccess('GroupContact', 'create', $group_contact_params); } $contact_get = $this->callAPISuccess('contact', 'get', ['group' => [$createdGroupTitles[0] => 1], 'return' => 'group']); $this->assertEquals(1, $contact_get['count']); @@ -4311,6 +4337,8 @@ public function testContactGetWithGroupTitleMultipleGroupsLegacyFormat() { * * This is primarily testing functionality in the BAO_Query object that 'happens to be' * accessible via the api. + * + * @throws \CRM_Core_Exception */ public function testContactGetProximity() { CRM_Core_Config::singleton()->geocodeMethod = 'CRM_Utils_MockGeocoder'; @@ -4335,8 +4363,8 @@ public function testContactGetProximity() { } public function testLoggedInUserAPISupportToken() { - $description = "Get contact id of the current logged in user"; - $subFile = "ContactIDOfLoggedInUserContactAPI"; + $description = 'Get contact id of the current logged in user'; + $subFile = 'ContactIDOfLoggedInUserContactAPI'; $cid = $this->createLoggedInUser(); $contact = $this->callAPIAndDocument('contact', 'get', ['id' => 'user_contact_id'], __FUNCTION__, __FILE__, $description, $subFile); $this->assertEquals($cid, $contact['id']); @@ -4516,6 +4544,8 @@ public function testContactGetUnique() { /** * API test to retrieve contact from group having different group title and name. + * + * @throws \CRM_Core_Exception */ public function testContactGetFromGroup() { $groupId = $this->groupCreate([ @@ -4532,17 +4562,15 @@ public function testContactGetFromGroup() { 'group_id' => $groupId, 'status' => 'Pending', ]; - $groupContact = $this->callAPISuccess('groupContact', 'create', $groupContactCreateParams); - $groupGetContact = $this->CallAPISuccess('groupContact', 'get', $groupContactCreateParams); - $this->CallAPISuccess('Contact', 'getcount', [ - 'group' => "Test_Group", - ]); + $this->callAPISuccess('groupContact', 'create', $groupContactCreateParams); + $this->callAPISuccess('groupContact', 'get', $groupContactCreateParams); + $this->callAPISuccess('Contact', 'getcount', ['group' => 'Test_Group']); } /** * Test the related contacts filter. * - * @throws \Exception + * @throws \CRM_Core_Exception */ public function testSmartGroupsForRelatedContacts() { $rtype1 = $this->callAPISuccess('relationship_type', 'create', [ @@ -4609,10 +4637,12 @@ public function testSmartGroupsForRelatedContacts() { /** * Test creating a note from the contact.create API call when only passing the note as a string. + * + * @throws \CRM_Core_Exception */ - public function testCreateNoteinCreate() { + public function testCreateNoteInCreate() { $loggedInContactID = $this->createLoggedInUser(); - $this->_params['note'] = "Test note created by API Call as a String"; + $this->_params['note'] = 'Test note created by API Call as a String'; $contact = $this->callAPISuccess('Contact', 'create', $this->_params); $note = $this->callAPISuccess('Note', 'get', ['contact_id' => $loggedInContactID]); $this->assertEquals($note['values'][$note['id']]['note'], "Test note created by API Call as a String"); @@ -4623,6 +4653,8 @@ public function testCreateNoteinCreate() { /** * Test Creating a note from the contact.create api call when passing the note params as an array. + * + * @throws \CRM_Core_Exception */ public function testCreateNoteinCreateArrayFormat() { $contact1 = $this->callAPISuccess('Contact', 'create', ['first_name' => 'Alan', 'last_name' => 'MouseMouse', 'contact_type' => 'Individual']); @@ -4641,6 +4673,8 @@ public function testCreateNoteinCreateArrayFormat() { * - Contact.get tag='id1' * - Contact.get tag='id1,id2' * - Contact.get tag='id1, id2' + * + * @throws \CRM_Core_Exception */ public function testContactGetWithTag() { $contact = $this->callApiSuccess('Contact', 'create', [ @@ -4704,7 +4738,9 @@ public function testContactGetWithTag() { * * @return array * + * @throws \API_Exception * @throws \CRM_Core_Exception + * @throws \Civi\API\Exception\UnauthorizedException */ protected function createDeeplyConflictedContacts(): array { $this->createCustomGroupWithFieldOfType(); @@ -4726,6 +4762,11 @@ protected function createDeeplyConflictedContacts(): array { return [$contact1, $contact2]; } + /** + * Combinations of versions and privacy choices. + * + * @return array + */ public function versionAndPrivacyOption() { $version = [3, 4]; $fields = ['do_not_mail', 'do_not_email', 'do_not_sms', 'is_opt_out', 'do_not_trade']; @@ -4751,6 +4792,7 @@ public function versionAndPrivacyOption() { * @param $expected * * @throws \CRM_Core_Exception + * * @dataProvider versionAndPrivacyOption */ public function testGetContactsByPrivacyFlag($version, $query, $field, $expected) {