diff --git a/tests/phpunit/CRM/ACL/ListTest.php b/tests/phpunit/CRM/ACL/ListTest.php index c959bd46aa21..1676f0419de8 100644 --- a/tests/phpunit/CRM/ACL/ListTest.php +++ b/tests/phpunit/CRM/ACL/ListTest.php @@ -28,7 +28,7 @@ public function setUp(): void { /** * general test for the 'view all contacts' permission */ - public function testViewAllPermission() { + public function testViewAllPermission(): void { // create test contacts $contacts = $this->createScenarioPlain(); @@ -61,7 +61,7 @@ public function testViewAllPermission() { /** * general test for the 'view all contacts' permission */ - public function testEditAllPermission() { + public function testEditAllPermission(): void { // create test contacts $contacts = $this->createScenarioPlain(); @@ -183,7 +183,7 @@ public function testPermissionByRelation(): void { /** * Test access based on ACL */ - public function testPermissionByACL() { + public function testPermissionByACL(): void { $contacts = $this->createScenarioPlain(); // set custom hook @@ -207,7 +207,7 @@ public function testPermissionByACL() { /** * Test access with a mix of ACL and relationship */ - public function testPermissionACLvsRelationship() { + public function testPermissionACLvsRelationship(): void { $contacts = $this->createScenarioRelations(); // set custom hook @@ -232,7 +232,7 @@ public function testPermissionACLvsRelationship() { /** * Test access related to the 'access deleted contact' permission */ - public function testPermissionCompare() { + public function testPermissionCompare(): void { $contacts = $this->createScenarioRelations(); $contact_index = array_flip($contacts); diff --git a/tests/phpunit/CRM/Activity/BAO/ActivityAssignmentTest.php b/tests/phpunit/CRM/Activity/BAO/ActivityAssignmentTest.php index c5ff3964f317..cb1ef0e5e2ae 100644 --- a/tests/phpunit/CRM/Activity/BAO/ActivityAssignmentTest.php +++ b/tests/phpunit/CRM/Activity/BAO/ActivityAssignmentTest.php @@ -20,7 +20,7 @@ class CRM_Activity_BAO_ActivityAssignmentTest extends CiviUnitTestCase { /** * Pass zero as an id and make sure no Assignees are retrieved. */ - public function testGetAssigneeNamesNoId() { + public function testGetAssigneeNamesNoId(): void { $activity = $this->activityCreate(); $assignees = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames(0); @@ -30,7 +30,7 @@ public function testGetAssigneeNamesNoId() { /** * Pass Null as an id and make sure no Assignees are retrieved. */ - public function testGetAssigneeNamesNullId() { + public function testGetAssigneeNamesNullId(): void { $activity = $this->activityCreate(); $assignees = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames(NULL); @@ -40,7 +40,7 @@ public function testGetAssigneeNamesNullId() { /** * Pass a known activity id as an id and make sure 1 Assignees is retrieved */ - public function testGetAssigneeNamesOneId() { + public function testGetAssigneeNamesOneId(): void { $activity = $this->activityCreate(); $assignees = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames([$activity['id']]); $this->assertEquals(count($assignees), 1, '1 assignee names retrieved'); diff --git a/tests/phpunit/CRM/Activity/BAO/ActivityTest.php b/tests/phpunit/CRM/Activity/BAO/ActivityTest.php index 50392eb0ba4b..1d51f648ac1f 100644 --- a/tests/phpunit/CRM/Activity/BAO/ActivityTest.php +++ b/tests/phpunit/CRM/Activity/BAO/ActivityTest.php @@ -56,7 +56,7 @@ public function tearDown(): void { * * @throws \CRM_Core_Exception */ - public function testCreate() { + public function testCreate(): void { $contactId = $this->individualCreate(); $params = [ @@ -226,7 +226,7 @@ public function testTargetContactNotAvaliable(): void { * Check for errors when viewing a contact's activity tab when there * is an activity that doesn't have a target (With Contact). */ - public function testActivitySelectorNoTargets() { + public function testActivitySelectorNoTargets(): void { $contact_id = $this->individualCreate([], 0, TRUE); $activity = $this->callAPISuccess('activity', 'create', [ 'source_contact_id' => $contact_id, @@ -258,7 +258,7 @@ public function testActivitySelectorNoTargets() { * * @throws \CRM_Core_Exception */ - public function testDeleteActivity() { + public function testDeleteActivity(): void { $contactId = $this->individualCreate(); $params = [ 'first_name' => 'liz', @@ -322,7 +322,7 @@ public function testDeleteActivity() { /** * Test case for deleteActivityContact() method. */ - public function testDeleteActivityTarget() { + public function testDeleteActivityTarget(): void { $contactId = $this->individualCreate(); $params = [ 'first_name' => 'liz', @@ -408,7 +408,7 @@ public function testDeleteActivityAssignment(): void { * Test getActivities BAO method for getting count. * */ - public function testGetActivitiesCountForAdminDashboard() { + public function testGetActivitiesCountForAdminDashboard(): void { // Reset to default $this->setShowCaseActivitiesInCore(FALSE); $this->setUpForActivityDashboardTests(); @@ -434,7 +434,7 @@ public function testGetActivitiesCountForAdminDashboard() { * Test getActivities BAO method for getting count * */ - public function testGetActivitiesCountforNonAdminDashboard() { + public function testGetActivitiesCountforNonAdminDashboard(): void { // Reset to default $this->setShowCaseActivitiesInCore(FALSE); $this->createTestActivities(); @@ -470,7 +470,7 @@ public function testGetActivitiesCountforNonAdminDashboard() { * Test getActivities BAO method for getting count * */ - public function testGetActivitiesCountforContactSummary() { + public function testGetActivitiesCountforContactSummary(): void { // Reset to default $this->setShowCaseActivitiesInCore(FALSE); $this->createTestActivities(); @@ -502,7 +502,7 @@ public function testGetActivitiesCountforContactSummary() { /** * CRM-18706 - Test Include/Exclude Activity Filters */ - public function testActivityFilters() { + public function testActivityFilters(): void { $this->createTestActivities(); Civi::settings()->set('preserve_activity_tab_filter', 1); $this->createLoggedInUser(); @@ -550,7 +550,7 @@ public function testActivityFilters() { /** * Test getActivities BAO method for getting count */ - public function testGetActivitiesCountforContactSummaryWithNoActivities() { + public function testGetActivitiesCountforContactSummaryWithNoActivities(): void { $this->createTestActivities(); $params = [ @@ -572,7 +572,7 @@ public function testGetActivitiesCountforContactSummaryWithNoActivities() { /** * Test getActivities BAO method. */ - public function testGetActivitiesForAdminDashboard() { + public function testGetActivitiesForAdminDashboard(): void { $this->setShowCaseActivitiesInCore(FALSE); $this->setUpForActivityDashboardTests(); $this->addCaseWithActivity(); @@ -607,7 +607,7 @@ public function testGetActivitiesForAdminDashboard() { /** * Test getActivities BAO method. */ - public function testGetActivitiesForAdminDashboardNoViewContacts() { + public function testGetActivitiesForAdminDashboardNoViewContacts(): void { CRM_Core_Config::singleton()->userPermissionClass->permissions = ['access CiviCRM']; $this->setUpForActivityDashboardTests(); foreach ([CRM_Activity_BAO_Activity::getActivities($this->_params)] as $activities) { @@ -619,7 +619,7 @@ public function testGetActivitiesForAdminDashboardNoViewContacts() { /** * Test getActivities BAO method. */ - public function testGetActivitiesForAdminDashboardAclLimitedViewContacts() { + public function testGetActivitiesForAdminDashboardAclLimitedViewContacts(): void { CRM_Core_Config::singleton()->userPermissionClass->permissions = ['access CiviCRM']; $this->allowedContacts = [1, 3, 4, 5]; $this->hookClass->setHook('civicrm_aclWhereClause', [$this, 'aclWhereMultipleContacts']); @@ -630,7 +630,7 @@ public function testGetActivitiesForAdminDashboardAclLimitedViewContacts() { /** * Test getActivities BAO method. */ - public function testGetActivitiesforNonAdminDashboard() { + public function testGetActivitiesforNonAdminDashboard(): void { $this->setShowCaseActivitiesInCore(FALSE); $this->createTestActivities(); $this->addCaseWithActivity(); @@ -685,7 +685,7 @@ public function testGetActivitiesforNonAdminDashboard() { /** * Test target contact count. */ - public function testTargetCountforContactSummary() { + public function testTargetCountforContactSummary(): void { $targetCount = 5; $contactId = $this->individualCreate(); $targetContactIDs = []; @@ -714,7 +714,7 @@ public function testTargetCountforContactSummary() { /** * Test getActivities BAO method. */ - public function testGetActivitiesforContactSummaryWithSortOptions() { + public function testGetActivitiesforContactSummaryWithSortOptions(): void { $this->createTestActivities(); $params = [ 'contact_id' => 9, @@ -738,7 +738,7 @@ public function testGetActivitiesforContactSummaryWithSortOptions() { /** * Test getActivities BAO method. */ - public function testGetActivitiesForContactSummary() { + public function testGetActivitiesForContactSummary(): void { // Reset to default $this->setShowCaseActivitiesInCore(FALSE); $this->createTestActivities(); @@ -807,7 +807,7 @@ public function testGetActivitiesForContactSummary() { /** * Test getActivities BAO method. */ - public function testGetActivitiesforContactSummaryWithActivities() { + public function testGetActivitiesforContactSummaryWithActivities(): void { // Reset to default $this->setShowCaseActivitiesInCore(FALSE); $this->createTestActivities(); @@ -1145,7 +1145,7 @@ public function getActivityDateData() { * * @throws \CRM_Core_Exception */ - public function testEmailAddressOfActivityCopy() { + public function testEmailAddressOfActivityCopy(): void { // Case 1: assert the 'From' Email Address of source Actvity Contact ID // create activity with source contact ID which has email address $assigneeContactId = $this->individualCreate(); @@ -1573,7 +1573,7 @@ public function hook_civicrm_aclWhereClause($type, &$tables, &$whereTables, &$co } } - public function testSendEmailWithCaseId() { + public function testSendEmailWithCaseId(): void { $caseTest = new CiviCaseTestCase(); $caseTest->setUp(); // Create a contact and contactDetails array. diff --git a/tests/phpunit/CRM/Activity/BAO/ActivityTypeTest.php b/tests/phpunit/CRM/Activity/BAO/ActivityTypeTest.php index e0a531f3365b..cfb187cd5744 100644 --- a/tests/phpunit/CRM/Activity/BAO/ActivityTypeTest.php +++ b/tests/phpunit/CRM/Activity/BAO/ActivityTypeTest.php @@ -8,7 +8,7 @@ class CRM_Activity_BAO_ActivityTypeTest extends CiviUnitTestCase { /** * Test ActivityType */ - public function testActivityType() { + public function testActivityType(): void { $actParams = [ 'option_group_id' => 'activity_type', 'name' => 'abc123', diff --git a/tests/phpunit/CRM/Activity/Form/ActivityTest.php b/tests/phpunit/CRM/Activity/Form/ActivityTest.php index 1606517e8f9d..5486c7c751ee 100644 --- a/tests/phpunit/CRM/Activity/Form/ActivityTest.php +++ b/tests/phpunit/CRM/Activity/Form/ActivityTest.php @@ -29,7 +29,7 @@ public function setUp():void { $this->source = $this->individualCreate(); } - public function testActivityCreate() { + public function testActivityCreate(): void { Civi::settings()->set('activity_assignee_notification', TRUE); //Reset filter to none. Civi::settings()->set('do_not_notify_assignees_for', []); @@ -61,7 +61,7 @@ public function testActivityCreate() { $this->assertEmpty($msg); } - public function testActivityDelete() { + public function testActivityDelete(): void { // Set the parameters of the test. $numberOfSingleActivitiesToCreate = 3; $numberOfRepeatingActivitiesToCreate = 6; @@ -158,7 +158,7 @@ public function testActivityDelete() { /** * Test deleting an activity that has an attachment. */ - public function testActivityDeleteWithAttachment() { + public function testActivityDeleteWithAttachment(): void { $loggedInUser = $this->createLoggedInUser(); // Create an activity $activity = $this->callAPISuccess('Activity', 'create', [ @@ -242,7 +242,7 @@ private function deleteActivity($activityId, $mode = NULL) { /** * This is a bit messed up having a variable called name that means label but we don't want to fix it because it's a form member variable _activityTypeName that might be used in form hooks, so just make sure it doesn't flip between name and label. dev/core#1116 */ - public function testActivityTypeNameIsReallyLabel() { + public function testActivityTypeNameIsReallyLabel(): void { $form = new CRM_Activity_Form_Activity(); // the actual value is irrelevant we just need something for the tested function to act on @@ -276,7 +276,7 @@ public function testActivityTypeNameIsReallyLabel() { * * See also testActivityTypeNameIsReallyLabel() */ - public function testActivityTypeAssignment() { + public function testActivityTypeAssignment(): void { $form = new CRM_Activity_Form_Activity(); $form->_currentlyViewedContactId = $this->source; diff --git a/tests/phpunit/CRM/Activity/Form/SearchTest.php b/tests/phpunit/CRM/Activity/Form/SearchTest.php index a50099c5bfc5..696068edd83f 100644 --- a/tests/phpunit/CRM/Activity/Form/SearchTest.php +++ b/tests/phpunit/CRM/Activity/Form/SearchTest.php @@ -79,7 +79,7 @@ public function testSearch(): void { /** * Test the Qill for activity Date time. */ - public function testQill() { + public function testQill(): void { foreach ($this->getSearchCriteria() as $test_name => $data) { $selector = new CRM_Activity_Selector_Search($data['search_criteria']); $this->assertEquals($data['expected_qill'], $selector->getQILL(), "Failed for data set: $test_name"); diff --git a/tests/phpunit/CRM/Activity/Form/Task/PDFTest.php b/tests/phpunit/CRM/Activity/Form/Task/PDFTest.php index bebdcbf741b5..6397d46b929d 100644 --- a/tests/phpunit/CRM/Activity/Form/Task/PDFTest.php +++ b/tests/phpunit/CRM/Activity/Form/Task/PDFTest.php @@ -92,7 +92,7 @@ protected function getActivityTokens(): array { ]; } - public function testCreateDocumentCustomFieldTokens() { + public function testCreateDocumentCustomFieldTokens(): void { // Set up custom group, and field // returns custom_group_id, custom_field_id, custom_field_option_group_id, custom_field_group_options $cg = $this->entityCustomGroupWithSingleStringMultiSelectFieldCreate("MyCustomField", "ActivityTest.php"); diff --git a/tests/phpunit/CRM/Activity/Page/AJAXTest.php b/tests/phpunit/CRM/Activity/Page/AJAXTest.php index d4d30f66a817..7f6b3dee305a 100644 --- a/tests/phpunit/CRM/Activity/Page/AJAXTest.php +++ b/tests/phpunit/CRM/Activity/Page/AJAXTest.php @@ -34,7 +34,7 @@ public function setUp(): void { * passed to the function this test is testing. So there's no form or ajax * being tested here, just the final act of filing the activity. */ - public function testConvertToCaseActivity() { + public function testConvertToCaseActivity(): void { $activity = $this->callAPISuccess('Activity', 'create', [ 'source_contact_id' => $this->loggedInUser, 'activity_type_id' => 'Meeting', @@ -71,7 +71,7 @@ public function testConvertToCaseActivity() { /** * Similar to testConvertToCaseActivity above but for copy-to-case. */ - public function testCopyToCase() { + public function testCopyToCase(): void { $case1 = $this->callAPISuccess('Case', 'create', [ 'contact_id' => $this->target, 'case_type_id' => 'housing_support', @@ -125,7 +125,7 @@ public function testCopyToCase() { /** * Similar to testCopyToCase above but for move-to-case. */ - public function testMoveToCase() { + public function testMoveToCase(): void { $case1 = $this->callAPISuccess('Case', 'create', [ 'contact_id' => $this->target, 'case_type_id' => 'housing_support', @@ -179,7 +179,7 @@ public function testMoveToCase() { /** * Check if the selected filters are saved. */ - public function testPreserveFilters() { + public function testPreserveFilters(): void { \Civi::settings()->set('preserve_activity_tab_filter', '1'); // Simulate visiting activity tab with all the filters set to something diff --git a/tests/phpunit/CRM/Bridge/OG/DrupalTest.php b/tests/phpunit/CRM/Bridge/OG/DrupalTest.php index 02cb1722c519..deb6e9ec9c0d 100644 --- a/tests/phpunit/CRM/Bridge/OG/DrupalTest.php +++ b/tests/phpunit/CRM/Bridge/OG/DrupalTest.php @@ -45,7 +45,7 @@ class CRM_Bridge_OG_DrupalTest extends CiviUnitTestCase { /** * Test that one (ane only one) role (option value) is deleted by the updateCiviACLRole function */ - public function testACLRoleDeleteFunctionality() { + public function testACLRoleDeleteFunctionality(): void { $optionGroup = civicrm_api('OptionGroup', 'Get', [ 'version' => 3, 'name' => 'acl_role', diff --git a/tests/phpunit/CRM/Campaign/BAO/CampaignTest.php b/tests/phpunit/CRM/Campaign/BAO/CampaignTest.php index b5627adff186..47b6046e8915 100644 --- a/tests/phpunit/CRM/Campaign/BAO/CampaignTest.php +++ b/tests/phpunit/CRM/Campaign/BAO/CampaignTest.php @@ -17,7 +17,7 @@ */ class CRM_Campaign_BAO_CampaignTest extends CiviUnitTestCase { - public function testCampaignSummary() { + public function testCampaignSummary(): void { $loggedInContact = $this->createLoggedInUser(); $contact = $this->individualCreate(); $this->callAPISuccess('Campaign', 'create', [ diff --git a/tests/phpunit/CRM/Campaign/BAO/QueryTest.php b/tests/phpunit/CRM/Campaign/BAO/QueryTest.php index 21ecce3e1a37..9067456f7a29 100644 --- a/tests/phpunit/CRM/Campaign/BAO/QueryTest.php +++ b/tests/phpunit/CRM/Campaign/BAO/QueryTest.php @@ -18,7 +18,7 @@ */ class CRM_Campaign_BAO_QueryTest extends CiviUnitTestCase { - public function testCampaignVoterClause() { + public function testCampaignVoterClause(): void { $loggedInContact = $this->createLoggedInUser(); $contact = $this->individualCreate(); $activityType = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'survey'); diff --git a/tests/phpunit/CRM/Case/BAO/CaseTest.php b/tests/phpunit/CRM/Case/BAO/CaseTest.php index bf1adf3c6584..40a3ab39aa8f 100644 --- a/tests/phpunit/CRM/Case/BAO/CaseTest.php +++ b/tests/phpunit/CRM/Case/BAO/CaseTest.php @@ -64,7 +64,7 @@ protected function tearDown(): void { parent::tearDown(); } - public function testAddCaseToContact() { + public function testAddCaseToContact(): void { $this->createLoggedInUser(); $params = [ 'case_id' => 1, @@ -239,7 +239,7 @@ public function testSortByCaseContact(): void { * * @throws \CRM_Core_Exception */ - public function testActiveCaseRole() { + public function testActiveCaseRole(): void { $individual = $this->individualCreate(); $caseObj = $this->createCase($individual); $caseId = $caseObj->id; @@ -251,7 +251,7 @@ public function testActiveCaseRole() { /** * Test that case count is zero for logged in user for user's inactive role. */ - public function testInactiveCaseRole() { + public function testInactiveCaseRole(): void { $individual = $this->individualCreate(); $caseObj = $this->createCase($individual); $caseId = $caseObj->id; @@ -260,12 +260,12 @@ public function testInactiveCaseRole() { $this->assertCasesOfUser($loggedInUser, $caseId, 0); } - public function testGetCaseType() { + public function testGetCaseType(): void { $caseTypeLabel = CRM_Case_BAO_Case::getCaseType(1); $this->assertEquals('Housing Support', $caseTypeLabel); } - public function testRetrieveCaseIdsByContactId() { + public function testRetrieveCaseIdsByContactId(): void { $caseIds = CRM_Case_BAO_Case::retrieveCaseIdsByContactId(3, FALSE, 'housing_support'); $this->assertEquals([1], $caseIds); } @@ -273,7 +273,7 @@ public function testRetrieveCaseIdsByContactId() { /** * Test that all custom files are migrated to new case when case is assigned to new client. */ - public function testCaseReassignForCustomFiles() { + public function testCaseReassignForCustomFiles(): void { $individual = $this->individualCreate(); $customGroup = $this->customGroupCreate(array( 'extends' => 'Case', @@ -348,7 +348,7 @@ public function testCaseReassignForCustomFiles() { * $this->assertEquals(1, $cases[1]['case_type_id']); * } */ - public function testGetCasesSummary() { + public function testGetCasesSummary(): void { $cases = CRM_Case_BAO_Case::getCasesSummary(); $this->assertEquals(1, $cases['rows']['Housing Support']['Ongoing']['count']); } @@ -357,7 +357,7 @@ public function testGetCasesSummary() { * Test that getRelatedCases() returns the other case when you create a * Link Cases activity on one of the cases. */ - public function testGetRelatedCases() { + public function testGetRelatedCases(): void { $loggedInUser = $this->createLoggedInUser(); // create some cases $client_id_1 = $this->individualCreate([], 0); @@ -398,7 +398,7 @@ public function testGetRelatedCases() { /** * Test various things after a case is closed. */ - public function testCaseClosure() { + public function testCaseClosure(): void { $loggedInUser = $this->createLoggedInUser(); $client_id = $this->individualCreate(); $caseObj = $this->createCase($client_id, $loggedInUser); @@ -508,7 +508,7 @@ public function testCaseClosure() { /** * Test getGlobalContacts */ - public function testGetGlobalContacts() { + public function testGetGlobalContacts(): void { //Add contact to case resource. $caseResourceContactID = $this->individualCreate(); $this->callAPISuccess('GroupContact', 'create', [ @@ -683,7 +683,7 @@ public function testMaxInstances(): void { * At the time this test was written this test would fail, demonstrating * one problem with name vs label. */ - public function testCreateCaseWithChangedManagerLabel() { + public function testCreateCaseWithChangedManagerLabel(): void { // We could just assume the relationship that gets created has // relationship_type_id = 1, but let's create a case, see what the // id is, then do our actual test. @@ -743,7 +743,7 @@ public function testCreateCaseWithChangedManagerLabel() { * Test change case status with linked cases choosing the option to * update the linked cases. */ - public function testChangeCaseStatusLinkedCases() { + public function testChangeCaseStatusLinkedCases(): void { $loggedInUser = $this->createLoggedInUser(); $clientId1 = $this->individualCreate(); $clientId2 = $this->individualCreate(); @@ -1165,7 +1165,7 @@ public function caseActivityQueryProvider(): array { * Test that if you only have "my cases" permission you can still view * Manage Case for **closed** cases of yours. */ - public function testCanViewClosedCaseAsNonAdmin() { + public function testCanViewClosedCaseAsNonAdmin(): void { $loggedInUser = $this->createLoggedInUser(); CRM_Core_Config::singleton()->userPermissionClass->permissions = [ 'access CiviCRM', @@ -1202,7 +1202,7 @@ public function testCanViewClosedCaseAsNonAdmin() { /** * Test a high number of assigned case roles. */ - public function testGoingTo11() { + public function testGoingTo11(): void { $loggedInUser = $this->createLoggedInUser(); $individual = $this->individualCreate(); $caseObj = $this->createCase($individual, $loggedInUser); @@ -1234,7 +1234,7 @@ public function testGoingTo11() { * Test that creating a regular activity with a subject including `[case #X]` * gets filed on case X. */ - public function testFileOnCaseBySubject() { + public function testFileOnCaseBySubject(): void { $loggedInUserId = $this->createLoggedInUser(); $clientId = $this->individualCreate(); $caseObj = $this->createCase($clientId, $loggedInUserId); @@ -1271,7 +1271,7 @@ public function testFileOnCaseBySubject() { /** * Same as testFileOnCaseBySubject but editing an existing non-case activity */ - public function testFileOnCaseByEditingSubject() { + public function testFileOnCaseByEditingSubject(): void { $loggedInUserId = $this->createLoggedInUser(); $clientId = $this->individualCreate(); $caseObj = $this->createCase($clientId, $loggedInUserId); @@ -1313,7 +1313,7 @@ public function testFileOnCaseByEditingSubject() { /** * Basic case create test with an Org client */ - public function testOrgClient() { + public function testOrgClient(): void { $loggedInUserId = $this->createLoggedInUser(); $clientId = $this->organizationCreate(); $caseObj = $this->createCase($clientId, $loggedInUserId); @@ -1332,7 +1332,7 @@ public function testOrgClient() { /** * Test getRelatedAndGlobalContacts() */ - public function testGetRelatedAndGlobalContacts() { + public function testGetRelatedAndGlobalContacts(): void { $loggedInUserId = $this->createLoggedInUser(); $clientId = $this->individualCreate(['first_name' => 'Cli', 'last_name' => 'Ent'], 0, TRUE); $caseObj = $this->createCase($clientId, $loggedInUserId); @@ -1382,7 +1382,7 @@ public function testGetRelatedAndGlobalContacts() { * Test that if there's only recently performed activities in the system * and no future ones then it still shows on dashboard. */ - public function testOnlyRecent() { + public function testOnlyRecent(): void { $loggedInUserId = $this->createLoggedInUser(); $clientId = $this->individualCreate([], 0, TRUE); // old start date so there's no upcoming diff --git a/tests/phpunit/CRM/Case/BAO/CaseTypeForkTest.php b/tests/phpunit/CRM/Case/BAO/CaseTypeForkTest.php index e77dbda7d466..42c346cdd4cd 100644 --- a/tests/phpunit/CRM/Case/BAO/CaseTypeForkTest.php +++ b/tests/phpunit/CRM/Case/BAO/CaseTypeForkTest.php @@ -20,7 +20,7 @@ public function tearDown(): void { /** * Test Manager contact is correctly assigned via case type def. */ - public function testManagerContact() { + public function testManagerContact(): void { $caseTypeId = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_CaseType', 'ForkableCaseType', 'id', 'name'); $this->assertTrue(is_numeric($caseTypeId) && $caseTypeId > 0); @@ -45,7 +45,7 @@ public function testManagerContact() { /** * Edit the definition of ForkableCaseType. */ - public function testForkable() { + public function testForkable(): void { $caseTypeId = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_CaseType', 'ForkableCaseType', 'id', 'name'); $this->assertTrue(is_numeric($caseTypeId) && $caseTypeId > 0); @@ -80,7 +80,7 @@ public function testForkable() { /** * Attempt to edit the definition of UnforkableCaseType. This fails. */ - public function testUnforkable() { + public function testUnforkable(): void { $caseTypeId = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_CaseType', 'UnforkableCaseType', 'id', 'name'); $this->assertTrue(is_numeric($caseTypeId) && $caseTypeId > 0); $this->assertDBNull('CRM_Case_BAO_CaseType', $caseTypeId, 'definition', 'id', "Should not have DB-based definition"); diff --git a/tests/phpunit/CRM/Case/BAO/QueryTest.php b/tests/phpunit/CRM/Case/BAO/QueryTest.php index 54f83a133a5f..9f4c168db714 100644 --- a/tests/phpunit/CRM/Case/BAO/QueryTest.php +++ b/tests/phpunit/CRM/Case/BAO/QueryTest.php @@ -19,7 +19,7 @@ class CRM_Case_BAO_QueryTest extends CiviCaseTestCase { * - case_activity_status_id * - case_activity_medium_id */ - public function testWhereClauseSingle() { + public function testWhereClauseSingle(): void { $params = [ 0 => [ 0 => 'case_activity_type', @@ -58,7 +58,7 @@ public function testWhereClauseSingle() { /** * Test the qill for a find cases search. */ - public function testFindCasesQuery() { + public function testFindCasesQuery(): void { $params = [ [ 0 => 'case_type_id', diff --git a/tests/phpunit/CRM/Case/Form/SearchTest.php b/tests/phpunit/CRM/Case/Form/SearchTest.php index e8166be7c917..18173feeffe1 100644 --- a/tests/phpunit/CRM/Case/Form/SearchTest.php +++ b/tests/phpunit/CRM/Case/Form/SearchTest.php @@ -22,7 +22,7 @@ public function setUp():void { * variable so it has a typo in CRM_Case_Form_Search::preProcess(), and then * this test will throw an exception. */ - public function testOpeningFindCaseForm() { + public function testOpeningFindCaseForm(): void { $form = new CRM_Case_Form_Search(); $form->controller = new CRM_Case_Controller_Search('Find Cases'); diff --git a/tests/phpunit/CRM/Case/PseudoConstantTest.php b/tests/phpunit/CRM/Case/PseudoConstantTest.php index 8a2997cb8335..c219bed2b05f 100644 --- a/tests/phpunit/CRM/Case/PseudoConstantTest.php +++ b/tests/phpunit/CRM/Case/PseudoConstantTest.php @@ -7,7 +7,7 @@ */ class CRM_Case_PseudoConstantTest extends CiviCaseTestCase { - public function testCaseType() { + public function testCaseType(): void { CRM_Core_PseudoConstant::flush(); $caseTypes = CRM_Case_PseudoConstant::caseType(); $expectedTypes = [ diff --git a/tests/phpunit/CRM/Case/WorkflowMessage/CaseActivityTest.php b/tests/phpunit/CRM/Case/WorkflowMessage/CaseActivityTest.php index fbe47bb84249..346503aa8090 100644 --- a/tests/phpunit/CRM/Case/WorkflowMessage/CaseActivityTest.php +++ b/tests/phpunit/CRM/Case/WorkflowMessage/CaseActivityTest.php @@ -21,7 +21,7 @@ public function getWorkflowClass(): string { return CRM_Case_WorkflowMessage_CaseActivity::class; } - public function testAdhocClassEquiv() { + public function testAdhocClassEquiv(): void { $examples = \Civi\Api4\ExampleData::get(0) ->setSelect(['name', 'data']) ->addWhere('name', 'IN', ['workflow/case_activity/CaseAdhocExample', 'workflow/case_activity/CaseModelExample']) @@ -38,7 +38,7 @@ public function testAdhocClassEquiv() { * * To see this, we take all the example data and use it with diff constructors. */ - public function testConstructorEquivalence() { + public function testConstructorEquivalence(): void { $examples = $this->findExamples()->execute()->indexBy('name')->column('data'); $this->assertTrue(count($examples) >= 1, 'Must have at least one example data-set'); foreach ($examples as $example) { @@ -52,7 +52,7 @@ public function testConstructorEquivalence() { * @throws \CRM_Core_Exception * @throws \Civi\API\Exception\UnauthorizedException */ - public function testExampleGet() { + public function testExampleGet(): void { $file = \Civi::paths()->getPath('[civicrm.root]/tests/phpunit/CRM/Case/WorkflowMessage/CaseActivity/CaseModelExample.php'); $name = 'workflow/case_activity/CaseModelExample'; diff --git a/tests/phpunit/CRM/Case/XMLProcessor/ProcessTest.php b/tests/phpunit/CRM/Case/XMLProcessor/ProcessTest.php index 4631684f66b2..6799b691aa4c 100644 --- a/tests/phpunit/CRM/Case/XMLProcessor/ProcessTest.php +++ b/tests/phpunit/CRM/Case/XMLProcessor/ProcessTest.php @@ -222,7 +222,7 @@ protected function setupActivityDefinitions() { * Tests the creation of activities where the default assignee should be the * target contact's instructor. Beto is the instructor for Ana. */ - public function testCreateActivityWithDefaultContactByRelationship() { + public function testCreateActivityWithDefaultContactByRelationship(): void { $relationship = $this->relationships['ana_is_pupil_of_beto']; $this->activityTypeXml->default_assignee_type = $this->defaultAssigneeOptionsValues['BY_RELATIONSHIP']; $this->activityTypeXml->default_assignee_relationship = "{$relationship['type_id']}_b_a"; @@ -236,7 +236,7 @@ public function testCreateActivityWithDefaultContactByRelationship() { * end up being a contact from another case where it has the same client * and relationship. */ - public function testCreateActivityWithDefaultContactByRelationshipTwoCases() { + public function testCreateActivityWithDefaultContactByRelationshipTwoCases(): void { /* At this point the stock setup looks like this: Case 1: no roles assigned @@ -326,7 +326,7 @@ public function testCreateActivityWithDefaultContactByRelationshipTwoCases() { * Tests when the default assignee relationship exists, but in the other direction only. * Ana is a pupil, but has no pupils related to her. */ - public function testCreateActivityWithDefaultContactByRelationshipMissing() { + public function testCreateActivityWithDefaultContactByRelationshipMissing(): void { $relationship = $this->relationships['ana_is_pupil_of_beto']; $this->activityTypeXml->default_assignee_type = $this->defaultAssigneeOptionsValues['BY_RELATIONSHIP']; $this->activityTypeXml->default_assignee_relationship = "{$relationship['type_id']}_a_b"; @@ -339,7 +339,7 @@ public function testCreateActivityWithDefaultContactByRelationshipMissing() { * Tests when the the default assignee relationship exists and is a bidirectional * relationship. Ana and Carlos are spouses. */ - public function testCreateActivityWithDefaultContactByRelationshipBidirectional() { + public function testCreateActivityWithDefaultContactByRelationshipBidirectional(): void { $relationship = $this->relationships['ana_is_spouse_of_carlos']; $this->activityParams['clientID'] = $this->contacts['carlos']; $this->activityTypeXml->default_assignee_type = $this->defaultAssigneeOptionsValues['BY_RELATIONSHIP']; @@ -353,7 +353,7 @@ public function testCreateActivityWithDefaultContactByRelationshipBidirectional( * Tests when the default assignee relationship does not exist. Ana is not an * employee for anyone. */ - public function testCreateActivityWithDefaultContactByRelationButTheresNoRelationship() { + public function testCreateActivityWithDefaultContactByRelationButTheresNoRelationship(): void { $relationship = $this->relationships['unassigned_employee']; $this->activityTypeXml->default_assignee_type = $this->defaultAssigneeOptionsValues['BY_RELATIONSHIP']; $this->activityTypeXml->default_assignee_relationship = "{$relationship['type_id']}_b_a"; @@ -365,7 +365,7 @@ public function testCreateActivityWithDefaultContactByRelationButTheresNoRelatio /** * Tests the creation of activities with default assignee set to a specific contact. */ - public function testCreateActivityAssignedToSpecificContact() { + public function testCreateActivityAssignedToSpecificContact(): void { $this->activityTypeXml->default_assignee_type = $this->defaultAssigneeOptionsValues['SPECIFIC_CONTACT']; $this->activityTypeXml->default_assignee_contact = $this->contacts['carlos']; @@ -377,7 +377,7 @@ public function testCreateActivityAssignedToSpecificContact() { * Tests the creation of activities with default assignee set to a specific contact, * but the contact does not exist. */ - public function testCreateActivityAssignedToNonExistantSpecificContact() { + public function testCreateActivityAssignedToNonExistantSpecificContact(): void { $this->activityTypeXml->default_assignee_type = $this->defaultAssigneeOptionsValues['SPECIFIC_CONTACT']; $this->activityTypeXml->default_assignee_contact = 987456321; @@ -389,7 +389,7 @@ public function testCreateActivityAssignedToNonExistantSpecificContact() { * Tests the creation of activities with the default assignee being the one * creating the case's activity. */ - public function testCreateActivityAssignedToUserCreatingTheCase() { + public function testCreateActivityAssignedToUserCreatingTheCase(): void { $this->activityTypeXml->default_assignee_type = $this->defaultAssigneeOptionsValues['USER_CREATING_THE_CASE']; $this->process->createActivity($this->activityTypeXml, $this->activityParams); @@ -399,7 +399,7 @@ public function testCreateActivityAssignedToUserCreatingTheCase() { /** * Tests the creation of activities when the default assignee is set to NONE. */ - public function testCreateActivityAssignedNoUser() { + public function testCreateActivityAssignedNoUser(): void { $this->activityTypeXml->default_assignee_type = $this->defaultAssigneeOptionsValues['NONE']; $this->process->createActivity($this->activityTypeXml, $this->activityParams); @@ -409,7 +409,7 @@ public function testCreateActivityAssignedNoUser() { /** * Tests the creation of activities when the default assignee is set to NONE. */ - public function testCreateActivityWithNoDefaultAssigneeOption() { + public function testCreateActivityWithNoDefaultAssigneeOption(): void { $this->process->createActivity($this->activityTypeXml, $this->activityParams); $this->assertActivityAssignedToContactExists(NULL); } @@ -555,7 +555,7 @@ public function xmlCaseRoleDataProvider() { /** * Test XMLProcessor activityTypes() */ - public function testXmlProcessorActivityTypes() { + public function testXmlProcessorActivityTypes(): void { // First change an activity's label since we also test getting the labels. // @todo Having a brain freeze or something - can't do this in one step? $activity_type_id = $this->callApiSuccess('OptionValue', 'get', [ diff --git a/tests/phpunit/CRM/Case/XMLProcessor/ReportTest.php b/tests/phpunit/CRM/Case/XMLProcessor/ReportTest.php index 5ed613556fa8..1c99e40ba7b6 100644 --- a/tests/phpunit/CRM/Case/XMLProcessor/ReportTest.php +++ b/tests/phpunit/CRM/Case/XMLProcessor/ReportTest.php @@ -80,7 +80,7 @@ public function testGetCaseReport($activitySetName, $expected) { * This is similar to testGetCaseReport but test with a timeline that * does have Meeting in it. */ - public function testGetCaseReportWithMeetingInTimeline() { + public function testGetCaseReportWithMeetingInTimeline(): void { $client_id = $this->individualCreate([ 'first_name' => 'Casey', 'middle_name' => '', diff --git a/tests/phpunit/CRM/Case/XMLProcessorTest.php b/tests/phpunit/CRM/Case/XMLProcessorTest.php index 0150f7eda2ab..54b98060537c 100644 --- a/tests/phpunit/CRM/Case/XMLProcessorTest.php +++ b/tests/phpunit/CRM/Case/XMLProcessorTest.php @@ -22,7 +22,7 @@ public function setUp(): void { * Test that allRelationshipTypes() doesn't have name and label mixed up * and that is has the right directions. */ - public function testAllRelationshipTypes() { + public function testAllRelationshipTypes(): void { // Add a relationship type to test against. $params = [ diff --git a/tests/phpunit/CRM/Case/XMLRepositoryTest.php b/tests/phpunit/CRM/Case/XMLRepositoryTest.php index 9cf37e091e84..dc3e73a1c160 100644 --- a/tests/phpunit/CRM/Case/XMLRepositoryTest.php +++ b/tests/phpunit/CRM/Case/XMLRepositoryTest.php @@ -96,7 +96,7 @@ protected function setUp(): void { } - public function testGetAllDeclaredActivityTypes() { + public function testGetAllDeclaredActivityTypes(): void { $repo = new CRM_Case_XMLRepository( ['CaseTypeWithTwoActivityTypes', 'CaseTypeWithThreeActivityTypes'], [ @@ -113,7 +113,7 @@ public function testGetAllDeclaredActivityTypes() { $this->assertEquals($expected, $actual); } - public function testGetAllDeclaredRelationshipTypes() { + public function testGetAllDeclaredRelationshipTypes(): void { $repo = new CRM_Case_XMLRepository( ['CaseTypeWithTwoRoles', 'CaseTypeWithThreeRoles', 'CaseTypeWithSingleActivityType'], [ @@ -129,7 +129,7 @@ public function testGetAllDeclaredRelationshipTypes() { $this->assertEquals($expected, $actual); } - public function testGetActivityReferenceCount_1() { + public function testGetActivityReferenceCount_1(): void { $repo = new CRM_Case_XMLRepository( ['CaseTypeWithSingleActivityType'], [ @@ -145,7 +145,7 @@ public function testGetActivityReferenceCount_1() { $this->assertEquals(0, $repo->getActivityReferenceCount('Third Activity Type')); } - public function testGetActivityReferenceCount_23() { + public function testGetActivityReferenceCount_23(): void { $repo = new CRM_Case_XMLRepository( ['CaseTypeWithTwoActivityTypes', 'CaseTypeWithThreeActivityTypes'], [ @@ -162,7 +162,7 @@ public function testGetActivityReferenceCount_23() { $this->assertEquals(1, $repo->getActivityReferenceCount('Third Activity Type')); } - public function testGetRoleReferenceCount_1() { + public function testGetRoleReferenceCount_1(): void { $repo = new CRM_Case_XMLRepository( ['CaseTypeWithSingleRole', 'CaseTypeWithSingleActivityType'], [ @@ -178,7 +178,7 @@ public function testGetRoleReferenceCount_1() { $this->assertEquals(0, $repo->getRelationshipReferenceCount('Third Role')); } - public function testGetRoleReferenceCount_23() { + public function testGetRoleReferenceCount_23(): void { $repo = new CRM_Case_XMLRepository( ['CaseTypeWithTwoRoles', 'CaseTypeWithThreeRoles', 'CaseTypeWithSingleActivityType'], [ diff --git a/tests/phpunit/CRM/Contact/BAO/ContactTest.php b/tests/phpunit/CRM/Contact/BAO/ContactTest.php index d323b5c7bebe..7dfd6ddfbd6b 100644 --- a/tests/phpunit/CRM/Contact/BAO/ContactTest.php +++ b/tests/phpunit/CRM/Contact/BAO/ContactTest.php @@ -456,7 +456,7 @@ public function testCreateWithAll(): void { * * Test all pseudoConstant, stateProvince, country. */ - public function testResolveDefaults() { + public function testResolveDefaults(): void { $params = []; $params['address'][1] = [ @@ -1033,7 +1033,7 @@ public function testCreateProfileContact(): void { /** * Test case for getContactDetails( ). */ - public function testGetContactDetails() { + public function testGetContactDetails(): void { //get the contact params $params = $this->contactParams(); @@ -1147,7 +1147,7 @@ public function testGetContactType(): void { /** * Test case for displayName( ). */ - public function testDisplayName() { + public function testDisplayName(): void { //get the contact params $params = $this->contactParams(); @@ -1174,7 +1174,7 @@ public function testDisplayName() { /** * Test case for getDisplayAndImage( ). */ - public function testGetDisplayAndImage() { + public function testGetDisplayAndImage(): void { //get the contact params $params = $this->contactParams(); @@ -1347,7 +1347,7 @@ public function testTimestampsEmail(): void { /** * Ensure that civicrm_contact.modified_date is updated when manipulating an email. */ - public function testTimestampsPhone() { + public function testTimestampsPhone(): void { $test = $this; $this->_testTimestamps([ 'INSERT' => function ($contactId) use ($test) { diff --git a/tests/phpunit/CRM/Contact/BAO/ContactType/ContactSearchTest.php b/tests/phpunit/CRM/Contact/BAO/ContactType/ContactSearchTest.php index a68928fcda0e..a3d20fc598df 100644 --- a/tests/phpunit/CRM/Contact/BAO/ContactType/ContactSearchTest.php +++ b/tests/phpunit/CRM/Contact/BAO/ContactType/ContactSearchTest.php @@ -164,7 +164,7 @@ public function setUp(): void { * * Success expected. */ - public function testSearchWithType() { + public function testSearchWithType(): void { // for type:Individual $params = ['contact_type' => 'Individual', 'version' => 3]; @@ -229,7 +229,7 @@ public function testSearchWithType() { * * Success expected. */ - public function testSearchWithSubype() { + public function testSearchWithSubype(): void { // for subtype:Student $params = ['contact_sub_type' => $this->student, 'version' => 3]; @@ -277,7 +277,7 @@ public function testSearchWithSubype() { * * Success expected. */ - public function testSearchWithTypeSubype() { + public function testSearchWithTypeSubype(): void { // for type:individual subtype:Student $params = ['contact_sub_type' => $this->student, 'version' => 3]; diff --git a/tests/phpunit/CRM/Contact/BAO/ContactType/ContactTest.php b/tests/phpunit/CRM/Contact/BAO/ContactType/ContactTest.php index 4fcbc02c6415..73ae55ce5221 100644 --- a/tests/phpunit/CRM/Contact/BAO/ContactType/ContactTest.php +++ b/tests/phpunit/CRM/Contact/BAO/ContactType/ContactTest.php @@ -84,7 +84,7 @@ public function tearDown(): void { * * Success expected */ - public function testCreateContact() { + public function testCreateContact(): void { //check for Type:Individual $params = [ 'first_name' => 'Anne', @@ -167,7 +167,7 @@ public function testCreateContact() { * * Success expected. */ - public function testUpdateContactNoSubtypeToValid() { + public function testUpdateContactNoSubtypeToValid(): void { $params = [ 'first_name' => 'Anne', 'last_name' => 'Grant', @@ -223,7 +223,7 @@ public function testUpdateContactNoSubtypeToValid() { * Update the contact with subtype to another valid subtype. * success expected */ - public function testUpdateContactSubtype() { + public function testUpdateContactSubtype(): void { $params = [ 'first_name' => 'Anne', 'last_name' => 'Grant', @@ -313,7 +313,7 @@ public function testUpdateContactSubtype() { * * Success expected */ - public function testCRM19133() { + public function testCRM19133(): void { $subtypesToPreserve = [$this->student, $this->parent]; // Create custom group that extends student and parent subtype diff --git a/tests/phpunit/CRM/Contact/BAO/ContactType/ContactTypeTest.php b/tests/phpunit/CRM/Contact/BAO/ContactType/ContactTypeTest.php index f7079061ce78..68860ab33b56 100644 --- a/tests/phpunit/CRM/Contact/BAO/ContactType/ContactTypeTest.php +++ b/tests/phpunit/CRM/Contact/BAO/ContactType/ContactTypeTest.php @@ -59,7 +59,7 @@ public function tearDown(): void { /** * Test contactTypes() and subTypes() methods return correct contact types. */ - public function testGetMethods() { + public function testGetMethods(): void { $result = CRM_Contact_BAO_ContactType::contactTypes(TRUE); $this->assertEquals(array_keys($this->getExpectedContactTypes()), $result); @@ -89,7 +89,7 @@ public function testGetMethods() { /** * Test subTypes() methods with invalid data */ - public function testGetMethodsInvalid() { + public function testGetMethodsInvalid(): void { $params = 'invalid'; $result = CRM_Contact_BAO_ContactType::subTypes($params); @@ -105,7 +105,7 @@ public function testGetMethodsInvalid() { * * @throws \CRM_Core_Exception */ - public function testContactTypeInfo() { + public function testContactTypeInfo(): void { $blahType = ['is_active' => 0, 'name' => 'blah', 'label' => 'blah blah', 'parent_id:name' => 'Individual', 'icon' => 'fa-random']; $createdType = ContactType::create()->setValues($blahType)->execute()->first(); $activeTypes = CRM_Contact_BAO_ContactType::contactTypeInfo(); @@ -340,7 +340,7 @@ public function getExpectedContactSubTypes($parentType) { * Test add() methods with valid data * success expected */ - public function testAdd() { + public function testAdd(): void { $params = [ 'label' => 'indiviSubType', @@ -372,7 +372,7 @@ public function testAdd() { /** * Test del() with valid data. */ - public function testDel() { + public function testDel(): void { $params = [ 'label' => 'indiviSubType', diff --git a/tests/phpunit/CRM/Contact/BAO/ContactType/RelationshipTest.php b/tests/phpunit/CRM/Contact/BAO/ContactType/RelationshipTest.php index 178ee91bada6..bccc0b29082b 100644 --- a/tests/phpunit/CRM/Contact/BAO/ContactType/RelationshipTest.php +++ b/tests/phpunit/CRM/Contact/BAO/ContactType/RelationshipTest.php @@ -111,7 +111,7 @@ public function tearDown(): void { * Methods create relationshipType with valid data. * success expected */ - public function testRelationshipTypeAddIndiviParent() { + public function testRelationshipTypeAddIndiviParent(): void { //check Individual to Parent RelationshipType $params = [ 'name_a_b' => 'indivToparent', @@ -128,7 +128,7 @@ public function testRelationshipTypeAddIndiviParent() { $this->relationshipTypeDelete($result->id); } - public function testRelationshipTypeAddSponcorIndivi() { + public function testRelationshipTypeAddSponcorIndivi(): void { //check Sponcor to Individual RelationshipType $params = [ 'name_a_b' => 'SponsorToIndiv', @@ -145,7 +145,7 @@ public function testRelationshipTypeAddSponcorIndivi() { $this->relationshipTypeDelete($result->id); } - public function testRelationshipTypeAddStudentSponcor() { + public function testRelationshipTypeAddStudentSponcor(): void { //check Student to Sponcer RelationshipType $params = [ 'name_a_b' => 'StudentToSponser', @@ -164,7 +164,7 @@ public function testRelationshipTypeAddStudentSponcor() { $this->relationshipTypeDelete($result->id); } - public function testGetAnyToAnyRelTypes() { + public function testGetAnyToAnyRelTypes(): void { // Create an any to any relationship. $relTypeParams = [ 'name_a_b' => 'MookieIs', diff --git a/tests/phpunit/CRM/Contact/BAO/GroupContactTest.php b/tests/phpunit/CRM/Contact/BAO/GroupContactTest.php index 4587bc7e6430..05016a3df575 100644 --- a/tests/phpunit/CRM/Contact/BAO/GroupContactTest.php +++ b/tests/phpunit/CRM/Contact/BAO/GroupContactTest.php @@ -20,7 +20,7 @@ class CRM_Contact_BAO_GroupContactTest extends CiviUnitTestCase { /** * Test case for add( ). */ - public function testAdd() { + public function testAdd(): void { //creates a test group contact by recursively creation //lets create 10 groupContacts for fun @@ -40,7 +40,7 @@ public function testAdd() { /** * Test case for getGroupId( ) */ - public function testGetGroupId() { + public function testGetGroupId(): void { //creates a test groupContact object //force group_id to 1 so we can compare @@ -62,7 +62,7 @@ public function testGetGroupId() { * * @throws \Exception */ - public function testContactSearchByParentGroup() { + public function testContactSearchByParentGroup(): void { // create a parent group $parentGroup = $this->callAPISuccess('Group', 'create', [ 'title' => 'Parent Group', @@ -160,7 +160,7 @@ public function testContactSearchByParentGroup() { /** * CRM-19698: Test case for combine contact search in regular and smart group */ - public function testContactCombineGroupSearch() { + public function testContactCombineGroupSearch(): void { // create regular group based $regularGroup = $this->callAPISuccess('Group', 'create', [ 'title' => 'Regular Group', @@ -236,7 +236,7 @@ public function testContactCombineGroupSearch() { /** * CRM-19333: Test case for contact search on basis of group type */ - public function testbyGroupType() { + public function testbyGroupType(): void { $groupTypes = CRM_Core_BAO_OptionValue::getOptionValuesAssocArrayFromName('group_type'); $mailingListGT = array_search('Mailing List', $groupTypes); $accessControlGT = array_search('Access Control', $groupTypes); diff --git a/tests/phpunit/CRM/Contact/BAO/GroupTest.php b/tests/phpunit/CRM/Contact/BAO/GroupTest.php index ddde07352d2f..f8924b0848c0 100644 --- a/tests/phpunit/CRM/Contact/BAO/GroupTest.php +++ b/tests/phpunit/CRM/Contact/BAO/GroupTest.php @@ -33,7 +33,7 @@ protected function tearDown(): void { /** * Test case for add( ). */ - public function testAddSimple() { + public function testAddSimple(): void { $checkParams = $params = [ 'title' => 'Group Uno', @@ -247,7 +247,7 @@ public function loadSavedSearches() { * Copy the output to a single sql file and place in the SavedSearchDataSets folder - use the group number as the prefix. * Try to keep as much of the real world irregular glory as you can! Don't change the table ids to be number 1 as this can hide errors */ - public function testGroupData() { + public function testGroupData(): void { $groups = $this->dataProviderSavedSearch(); foreach ($groups[0] as $groupID) { $group = new CRM_Contact_BAO_Group(); @@ -261,7 +261,7 @@ public function testGroupData() { /** * Ensure that when updating a group with a linked organisation record even tho that record's id doesn't match the group id no db error is produced */ - public function testGroupUpdateWithOrganization() { + public function testGroupUpdateWithOrganization(): void { $params = [ 'name' => uniqid(), 'title' => 'Group A', @@ -299,7 +299,7 @@ public function testGroupUpdateWithOrganization() { /** * Ensure that when hidden smart group is created, wildcard string value is not ignored */ - public function testHiddenSmartGroup() { + public function testHiddenSmartGroup(): void { $customGroup = $this->customGroupCreate(); $fields = [ 'label' => 'testFld', @@ -337,7 +337,7 @@ public function testHiddenSmartGroup() { * Test updating a group with just description and check the recent items * list has the right title. */ - public function testGroupUpdateDescription() { + public function testGroupUpdateDescription(): void { // Create a group. Copied from $this->testAddSimple(). // Note we need $checkParams because the function call changes $params. $checkParams = $params = [ diff --git a/tests/phpunit/CRM/Contact/BAO/IndividualTest.php b/tests/phpunit/CRM/Contact/BAO/IndividualTest.php index 0307ef139076..e9e505ed4858 100644 --- a/tests/phpunit/CRM/Contact/BAO/IndividualTest.php +++ b/tests/phpunit/CRM/Contact/BAO/IndividualTest.php @@ -11,7 +11,7 @@ class CRM_Contact_BAO_IndividualTest extends CiviUnitTestCase { * * See CRM-19123: Merging contacts: blank date fields write as 1970 */ - public function testFormatNullDates() { + public function testFormatNullDates(): void { $params = [ 'contact_type' => 'Individual', 'birth_date' => 'null', @@ -29,7 +29,7 @@ public function testFormatNullDates() { * Test case to check the formatting of the Display name and Sort name * Standard formatting is assumed. */ - public function testFormatDisplayName() { + public function testFormatDisplayName(): void { $params = [ 'contact_type' => 'Individual', @@ -52,7 +52,7 @@ public function testFormatDisplayName() { * Standard Prefixes and Suffixes are assumed part of * the test database */ - public function testFormatDisplayNamePrefixesById() { + public function testFormatDisplayNamePrefixesById(): void { $params = [ 'contact_type' => 'Individual', @@ -76,7 +76,7 @@ public function testFormatDisplayNamePrefixesById() { * Standard Prefixes and Suffixes are assumed part of * the test database */ - public function testFormatDisplayNameNoIndividual() { + public function testFormatDisplayNameNoIndividual(): void { $params = [ 'contact_type' => 'Organization', @@ -94,7 +94,7 @@ public function testFormatDisplayNameNoIndividual() { /** * When no first name or last name are defined, the primary email is used */ - public function testFormatDisplayNameOnlyEmail() { + public function testFormatDisplayNameOnlyEmail(): void { $email['1'] = ['email' => "bleu01@example.com"]; $email['2'] = ['email' => "bleu02@example.com", 'is_primary' => 1]; diff --git a/tests/phpunit/CRM/Contact/BAO/QueryStateNameTest.php b/tests/phpunit/CRM/Contact/BAO/QueryStateNameTest.php index 65e75f5f917f..7361ad9bb1e1 100644 --- a/tests/phpunit/CRM/Contact/BAO/QueryStateNameTest.php +++ b/tests/phpunit/CRM/Contact/BAO/QueryStateNameTest.php @@ -12,7 +12,7 @@ class CRM_Contact_BAO_QueryStateNameTest extends CiviUnitTestCase { * See CRM-15505: Mailing labels show the state/province name as the abbreviation rather than the full state/province name * Change to CRM_Contact_BAO_query::convertToPseudoNames() */ - public function testStateName() { + public function testStateName(): void { $state_name = 'Norfolk'; $state_abbreviation = 'NFK'; $create_params = [ diff --git a/tests/phpunit/CRM/Contact/BAO/QueryTest.php b/tests/phpunit/CRM/Contact/BAO/QueryTest.php index 3dede9dc3102..a7c3835394b0 100644 --- a/tests/phpunit/CRM/Contact/BAO/QueryTest.php +++ b/tests/phpunit/CRM/Contact/BAO/QueryTest.php @@ -433,7 +433,7 @@ public function testSearchProfileHomeCityNoResultsCRM14263(): void { * * @throws \CRM_Core_Exception */ - public function testSearchPrimaryLocTypes() { + public function testSearchPrimaryLocTypes(): void { $contactID = $this->individualCreate(); $params = [ 'contact_id' => $contactID, @@ -489,7 +489,7 @@ public function testSearchPrimaryLocTypes() { * * @throws \CRM_Core_Exception */ - public function testSearchOtherLocationUpperLower() { + public function testSearchOtherLocationUpperLower(): void { $params = [ 0 => [ @@ -596,7 +596,7 @@ public function getSearchProfileData() { * * @throws \CRM_Core_Exception */ - public function testSearchBuilderActivityType() { + public function testSearchBuilderActivityType(): void { $queryObj = new CRM_Contact_BAO_Query([['activity_type', '=', '3', 1, 0]]); $this->assertStringContainsString('WHERE ( ( civicrm_activity.activity_type_id = 3 )', $queryObj->getSearchSQL()); $this->assertEquals('Activity Type = Email', $queryObj->_qill[1][0]); @@ -642,7 +642,7 @@ public function testSearchBuilderActivityType() { * * @throws \CRM_Core_Exception */ - public function testGroupContactCacheAddSearch() { + public function testGroupContactCacheAddSearch(): void { $returnProperties = ['contact_id']; $params = [['group', 'IN', [1], 0, 0]]; @@ -664,7 +664,7 @@ public function testGroupContactCacheAddSearch() { * * @throws \CRM_Core_Exception */ - public function testNumericPostal() { + public function testNumericPostal(): void { // Precaution as hitting some inconsistent set up running in isolation vs in the suite. CRM_Core_DAO::executeQuery('UPDATE civicrm_address SET postal_code = NULL'); @@ -704,7 +704,7 @@ public function testNumericPostal() { * * @throws \CRM_Core_Exception */ - public function testCaseInsensitive() { + public function testCaseInsensitive(): void { $orgID = $this->organizationCreate(['organization_name' => 'BOb']); $params = [ 'display_name' => 'Minnie Mouse', @@ -739,7 +739,7 @@ public function testCaseInsensitive() { * * @throws \CRM_Core_Exception */ - public function testNonNumericEqualsPostal() { + public function testNonNumericEqualsPostal(): void { $this->individualCreate(['api.address.create' => ['postal_code' => 5, 'location_type_id' => 'Main']]); $this->individualCreate(['api.address.create' => ['postal_code' => 'EH10 4RB-889', 'location_type_id' => 'Main']]); $this->individualCreate(['api.address.create' => ['postal_code' => '4', 'location_type_id' => 'Main']]); @@ -767,7 +767,7 @@ public function testNonNumericEqualsPostal() { * * @throws \CRM_Core_Exception */ - public function testRelationshipDescription() { + public function testRelationshipDescription(): void { $relType = $this->callAPISuccess('RelationshipType', 'create', [ 'name_a_b' => 'blah', 'name_b_a' => 'other blah', @@ -810,7 +810,7 @@ public function testRelationshipDescription() { * * @throws \CRM_Core_Exception */ - public function testNonReciprocalRelationshipTargetGroupIsCorrectResults() { + public function testNonReciprocalRelationshipTargetGroupIsCorrectResults(): void { $contactID_a = $this->individualCreate(); $contactID_b = $this->individualCreate(); $this->callAPISuccess('Relationship', 'create', [ @@ -862,7 +862,7 @@ public function testNonReciprocalRelationshipTargetGroupIsCorrectResults() { * * @throws \CRM_Core_Exception */ - public function testReciprocalRelationshipWithCustomFields() { + public function testReciprocalRelationshipWithCustomFields(): void { $params = [ 'extends' => 'Relationship', ]; @@ -910,7 +910,7 @@ public function testReciprocalRelationshipWithCustomFields() { /** * @throws \CRM_Core_Exception */ - public function testReciprocalRelationshipTargetGroupIsCorrectResults() { + public function testReciprocalRelationshipTargetGroupIsCorrectResults(): void { $contactID_a = $this->individualCreate(); $contactID_b = $this->individualCreate(); $this->callAPISuccess('Relationship', 'create', [ @@ -962,7 +962,7 @@ public function testReciprocalRelationshipTargetGroupIsCorrectResults() { * * @throws \CRM_Core_Exception */ - public function testReciprocalRelationshipTargetGroupUsesTempTable() { + public function testReciprocalRelationshipTargetGroupUsesTempTable(): void { $groupID = $this->groupCreate(); $params = [ [ @@ -995,7 +995,7 @@ public function testReciprocalRelationshipTargetGroupUsesTempTable() { * * @throws \CRM_Core_Exception */ - public function testRelationshipPermissionClause() { + public function testRelationshipPermissionClause(): void { $params = [['relation_type_id', 'IN', ['1_b_a'], 0, 0], ['relation_permission', 'IN', [2], 0, 0]]; $sql = CRM_Contact_BAO_Query::getQuery($params); $this->assertStringContainsString('(civicrm_relationship.is_permission_a_b IN (2))', $sql); @@ -1006,7 +1006,7 @@ public function testRelationshipPermissionClause() { * * @throws \CRM_Core_Exception */ - public function testRelationshipClause() { + public function testRelationshipClause(): void { $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 )'; @@ -1083,7 +1083,7 @@ public function testRelationshipClause() { * * @throws \CRM_Core_Exception */ - public function testGetByGroupWithStatus() { + public function testGetByGroupWithStatus(): void { $groupID = $this->groupCreate(); $this->groupContactCreate($groupID, 3); $groupContactID = $this->callAPISuccessGetSingle('GroupContact', ['group_id' => $groupID, 'options' => ['limit' => 1]])['id']; @@ -1106,7 +1106,7 @@ public function testGetByGroupWithStatus() { * * @throws \Exception */ - public function testGetByGroupWithStatusSmartGroup() { + public function testGetByGroupWithStatusSmartGroup(): void { $groupID = $this->smartGroupCreate(); // This means they are actually all hard-added, which is fine for this purpose. $this->groupContactCreate($groupID, 3); @@ -1131,7 +1131,7 @@ public function testGetByGroupWithStatusSmartGroup() { * * @throws \Exception */ - public function testGroupClause() { + public function testGroupClause(): void { $this->householdCreate(); $householdID = $this->householdCreate(); $individualID = $this->individualCreate(); @@ -1421,7 +1421,7 @@ protected function createContributionsForSummaryQueryTests(): void { /** * Test the options are handled for the qill. */ - public function testQillOptions() { + public function testQillOptions(): void { $qill = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Activity_BAO_Activity', 'activity_type_id', 2, '='); $this->assertEquals(['=', 'Phone Call'], $qill); diff --git a/tests/phpunit/CRM/Contact/BAO/RelationshipCacheTest.php b/tests/phpunit/CRM/Contact/BAO/RelationshipCacheTest.php index 006d39dfe5fa..a745a5473b59 100644 --- a/tests/phpunit/CRM/Contact/BAO/RelationshipCacheTest.php +++ b/tests/phpunit/CRM/Contact/BAO/RelationshipCacheTest.php @@ -26,7 +26,7 @@ protected function setUp(): void { * Whenever one `Relationship` is created, there should be two corresponding * `RelationshipCache` records. */ - public function testRelationshipCache() { + public function testRelationshipCache(): void { // add a new type $relationship_type_id_1 = $this->relationshipTypeCreate([ 'name_a_b' => 'Praegustator is', diff --git a/tests/phpunit/CRM/Contact/BAO/RelationshipTest.php b/tests/phpunit/CRM/Contact/BAO/RelationshipTest.php index b8b03511f0a0..c690e25dffef 100644 --- a/tests/phpunit/CRM/Contact/BAO/RelationshipTest.php +++ b/tests/phpunit/CRM/Contact/BAO/RelationshipTest.php @@ -41,7 +41,7 @@ protected function tearDown(): void { * * @throws \CRM_Core_Exception */ - public function testRelationshipTypeOptionsWillReturnSpecifiedType() { + public function testRelationshipTypeOptionsWillReturnSpecifiedType(): void { $orgToOrgType = 'A_B_relationship'; $orgToOrgReverseType = 'B_A_relationship'; $this->callAPISuccess('RelationshipType', 'create', [ @@ -69,7 +69,7 @@ public function testRelationshipTypeOptionsWillReturnSpecifiedType() { $this->assertNotContains($orgToOrgReverseType, $result['values']); } - public function testContactIdAndRelationshipIdWillBeUsedInFilter() { + public function testContactIdAndRelationshipIdWillBeUsedInFilter(): void { $individual = civicrm_api3('Contact', 'create', [ 'display_name' => 'Individual A', 'contact_type' => 'Individual', @@ -203,7 +203,7 @@ public function getRelationshipTypeDuplicates() { * * @throws \CRM_Core_Exception */ - public function testSingleMembershipForTwoRelationships() { + public function testSingleMembershipForTwoRelationships(): void { $individualID = $this->individualCreate(['display_name' => 'Individual A']); $organisationID = $this->organizationCreate(['organization_name' => 'Organization B']); $membershipOrganisationID = $this->organizationCreate(['organization_name' => 'Membership Organization']); @@ -283,7 +283,7 @@ public function testSingleMembershipForTwoRelationships() { * for the api, but since it does some more business logic after too the * tests might not be checking exactly the same thing. */ - public function testBAOAdd() { + public function testBAOAdd(): void { // add a new type $relationship_type_id_1 = $this->relationshipTypeCreate([ 'name_a_b' => 'Food poison tester is', @@ -329,7 +329,7 @@ public function testBAOAdd() { * @return void * @throws \CRM_Core_Exception */ - public function testDisableInvalidRelationship() { + public function testDisableInvalidRelationship(): void { $individualStaff = civicrm_api3('Contact', 'create', [ 'display_name' => 'Individual A', 'contact_type' => 'Individual', diff --git a/tests/phpunit/CRM/Contact/BAO/SavedSearchTest.php b/tests/phpunit/CRM/Contact/BAO/SavedSearchTest.php index bfce41175f77..5df4afea73d5 100644 --- a/tests/phpunit/CRM/Contact/BAO/SavedSearchTest.php +++ b/tests/phpunit/CRM/Contact/BAO/SavedSearchTest.php @@ -48,7 +48,7 @@ protected function tearDown(): void { * * @throws \Exception */ - public function testDefaultValues() { + public function testDefaultValues(): void { $this->createCustomGroupWithFieldOfType([], 'int'); $sg = new CRM_Contact_Form_Search_Advanced(); $sg->controller = new CRM_Core_Controller(); @@ -83,7 +83,7 @@ public function testDefaultValues() { * * @throws \Exception */ - public function testGetFormValuesWithCustomFields() { + public function testGetFormValuesWithCustomFields(): void { $this->createCustomGroupWithFieldsOfAllTypes(); $sg = new CRM_Contact_Form_Search_Advanced(); $sg->controller = new CRM_Core_Controller(); @@ -127,7 +127,7 @@ public function testGetFormValues($formValues, $expectedResult, $searchDescripti * Test if skipped elements are correctly * stored and retrieved as formvalues. */ - public function testSkippedElements() { + public function testSkippedElements(): void { $relTypeID = $this->relationshipTypeCreate(); $savedSearch = new CRM_Contact_BAO_SavedSearch(); $formValues = [ diff --git a/tests/phpunit/CRM/Contact/Form/Search/SearchContactTest.php b/tests/phpunit/CRM/Contact/Form/Search/SearchContactTest.php index fcbb20f3adce..9e992a34295b 100644 --- a/tests/phpunit/CRM/Contact/Form/Search/SearchContactTest.php +++ b/tests/phpunit/CRM/Contact/Form/Search/SearchContactTest.php @@ -22,7 +22,7 @@ class CRM_Contact_Form_Search_SearchContactTest extends CiviUnitTestCase { * * @throws \CRM_Core_Exception */ - public function testContactSubtype() { + public function testContactSubtype(): void { foreach (['Contact_sub_type', 'Contact2__sub__type'] as $contactSubType) { $subType = $this->callAPISuccess('ContactType', 'create', [ 'name' => $contactSubType, @@ -88,7 +88,7 @@ protected function searchContacts($contactSubType) { * * @throws \CRM_Core_Exception */ - public function testContactSearchOnGroupType() { + public function testContactSearchOnGroupType(): void { $groupTypes = $this->callAPISuccess('OptionValue', 'get', [ 'return' => ['id', 'name'], 'option_group_id' => 'group_type', diff --git a/tests/phpunit/CRM/Contact/Form/Task/DeleteTest.php b/tests/phpunit/CRM/Contact/Form/Task/DeleteTest.php index 07e48e9cf18f..bd28ad3ef863 100644 --- a/tests/phpunit/CRM/Contact/Form/Task/DeleteTest.php +++ b/tests/phpunit/CRM/Contact/Form/Task/DeleteTest.php @@ -41,7 +41,7 @@ protected function tearDown(): void { /** * Test delete to trash. */ - public function testDeleteToTrash() { + public function testDeleteToTrash(): void { $old_undelete_setting = Civi::settings()->get('contact_undelete'); Civi::settings()->set('contact_undelete', '1'); @@ -66,7 +66,7 @@ public function testDeleteToTrash() { /** * Test restore from trash. */ - public function testRestoreFromTrash() { + public function testRestoreFromTrash(): void { // First, put in trash. $this->testDeleteToTrash(); // Clear session status @@ -100,7 +100,7 @@ public function testRestoreFromTrash() { * This is different from testDeleteWithoutTrash. This is where you have * trash enabled and first move to trash, then delete from the trash. */ - public function testDeletePermanently() { + public function testDeletePermanently(): void { // First, put in trash. $this->testDeleteToTrash(); // Clear session status @@ -134,7 +134,7 @@ public function testDeletePermanently() { * This is different from testDeletePermanently. This is where trash is * not enabled at all. */ - public function testDeleteWithoutTrash() { + public function testDeleteWithoutTrash(): void { $old_undelete_setting = Civi::settings()->get('contact_undelete'); Civi::settings()->set('contact_undelete', '0'); diff --git a/tests/phpunit/CRM/Contact/Form/Task/UseraddTest.php b/tests/phpunit/CRM/Contact/Form/Task/UseraddTest.php index 714a228ebf98..18b606e44dd1 100644 --- a/tests/phpunit/CRM/Contact/Form/Task/UseraddTest.php +++ b/tests/phpunit/CRM/Contact/Form/Task/UseraddTest.php @@ -20,7 +20,7 @@ class CRM_Contact_Form_Task_UseraddTest extends CiviUnitTestCase { * In unit tests, the CMS user creation will always fail, but that's * ok because that's what we're testing here. */ - public function testUserCreateFail() { + public function testUserCreateFail(): void { $form = new CRM_Contact_Form_Task_Useradd(); // We don't need to set params or anything because we're testing fail, // which the user creation will do in unit tests no matter what we set. diff --git a/tests/phpunit/CRM/Contact/Page/AjaxTest.php b/tests/phpunit/CRM/Contact/Page/AjaxTest.php index aec798dd940e..03569884b9bf 100644 --- a/tests/phpunit/CRM/Contact/Page/AjaxTest.php +++ b/tests/phpunit/CRM/Contact/Page/AjaxTest.php @@ -28,7 +28,7 @@ public function tearDown(): void { /** * Minimal test on the testGetDupes function to make sure it completes without error. */ - public function testGetDedupes() { + public function testGetDedupes(): void { $_REQUEST['gid'] = 1; $_REQUEST['rgid'] = 1; $_REQUEST['columns'] = [ @@ -50,7 +50,7 @@ public function testGetDedupes() { * * @throws \Exception */ - public function testProcessDupes() { + public function testProcessDupes(): void { $contact1 = $this->individualCreate(); $contact2 = $this->individualCreate(); $contact3 = $this->individualCreate(); @@ -61,7 +61,7 @@ public function testProcessDupes() { $this->callAPISuccessGetSingle('Exception', ['contact_id1' => $contact1, 'contact_id2' => $contact3]); } - public function testGetDedupesPostCode() { + public function testGetDedupesPostCode(): void { $_REQUEST['gid'] = 1; $_REQUEST['rgid'] = 1; $_REQUEST['snippet'] = 4; @@ -242,7 +242,7 @@ public function testGetDedupesPostCode() { /** * CRM-20621 : Test to check usage count of Tag tree */ - public function testGetTagTree() { + public function testGetTagTree(): void { $contacts = []; // create three contacts for ($i = 0; $i < 3; $i++) { @@ -340,7 +340,7 @@ public function testGetTagTree() { /** * Test to check contact reference field */ - public function testContactReference() { + public function testContactReference(): void { //create group $groupId1 = $this->groupCreate(); $groupId2 = $this->groupCreate([ diff --git a/tests/phpunit/CRM/Contact/Page/DedupeExceptionTest.php b/tests/phpunit/CRM/Contact/Page/DedupeExceptionTest.php index c660c05292d1..af0ec3aac059 100644 --- a/tests/phpunit/CRM/Contact/Page/DedupeExceptionTest.php +++ b/tests/phpunit/CRM/Contact/Page/DedupeExceptionTest.php @@ -17,7 +17,7 @@ */ class CRM_Contact_Page_DedupeExceptionTest extends CiviUnitTestCase { - public function testGetDedupeExceptions() { + public function testGetDedupeExceptions(): void { $contact1 = $this->individualCreate(); $contact2 = $this->individualCreate(); $exception = $this->callAPISuccess('Exception', 'create', [ diff --git a/tests/phpunit/CRM/Contact/Page/View/UserDashboard/GroupContactTest.php b/tests/phpunit/CRM/Contact/Page/View/UserDashboard/GroupContactTest.php index 2a0936eed1d4..7556abfb1d13 100644 --- a/tests/phpunit/CRM/Contact/Page/View/UserDashboard/GroupContactTest.php +++ b/tests/phpunit/CRM/Contact/Page/View/UserDashboard/GroupContactTest.php @@ -21,7 +21,7 @@ class CRM_Contact_Page_View_UserDashboard_GroupContactTest extends CiviUnitTestC * Test that the list of the contact's joined groups, on the Contact Dashboard, * contains the correct groups. */ - public function testBrowseDisplaysCorrectListOfAddedGroups() { + public function testBrowseDisplaysCorrectListOfAddedGroups(): void { // create admin-only non-smart group $adminStdGroupTitle = 'The Admin-only Std Group'; $adminStdGroup = $this->callAPISuccess('Group', 'create', [ @@ -96,7 +96,7 @@ public function testBrowseDisplaysCorrectListOfAddedGroups() { * Test that the select list of available groups, on the Contact Dashboard, * contains the correct groups. */ - public function testBrowseDisplaysCorrectListOfAVailableGroups() { + public function testBrowseDisplaysCorrectListOfAVailableGroups(): void { // create admin-only non-smart group $adminStdGroupTitle = 'The Admin-only Std Group' . uniqid(); diff --git a/tests/phpunit/CRM/Contribute/BAO/ContributionTypeTest.php b/tests/phpunit/CRM/Contribute/BAO/ContributionTypeTest.php index a14714659d35..470bcbb1f0a8 100644 --- a/tests/phpunit/CRM/Contribute/BAO/ContributionTypeTest.php +++ b/tests/phpunit/CRM/Contribute/BAO/ContributionTypeTest.php @@ -28,7 +28,7 @@ public function tearDown(): void { /** * Check method add() */ - public function testAdd() { + public function testAdd(): void { $params = [ 'name' => 'Donations', 'is_deductible' => 0, diff --git a/tests/phpunit/CRM/Contribute/BAO/ProductTest.php b/tests/phpunit/CRM/Contribute/BAO/ProductTest.php index b87dc2bffc97..4a84260672f7 100644 --- a/tests/phpunit/CRM/Contribute/BAO/ProductTest.php +++ b/tests/phpunit/CRM/Contribute/BAO/ProductTest.php @@ -18,7 +18,7 @@ class CRM_Contribute_BAO_ProductTest extends CiviUnitTestCase { /** * Check method add() */ - public function testAdd() { + public function testAdd(): void { $params = [ 'name' => 'Test Product', 'sku' => 'TP-10', @@ -41,7 +41,7 @@ public function testAdd() { /** * Check method retrieve( ) */ - public function testRetrieve() { + public function testRetrieve(): void { $params = [ 'name' => 'Test Product', 'sku' => 'TP-10', @@ -62,7 +62,7 @@ public function testRetrieve() { /** * Check method del( ) */ - public function testDel() { + public function testDel(): void { $params = [ 'name' => 'Test Product', 'sku' => 'TP-10', diff --git a/tests/phpunit/CRM/Contribute/BAO/QueryTest.php b/tests/phpunit/CRM/Contribute/BAO/QueryTest.php index 0c18acc6bed2..e5ea63dc7b80 100644 --- a/tests/phpunit/CRM/Contribute/BAO/QueryTest.php +++ b/tests/phpunit/CRM/Contribute/BAO/QueryTest.php @@ -73,7 +73,7 @@ public function getSortFields() { * * @throws \CRM_Core_Exception */ - public function testRelativeContributionDates() { + public function testRelativeContributionDates(): void { $contribution1 = $this->contributionCreate(['receive_date' => '2018-01-02', 'contact_id' => $this->individualCreate()]); $contribution2 = $this->contributionCreate(['receive_date' => '2017-01-02', 'contact_id' => $this->individualCreate()]); $queryObj = new CRM_Contact_BAO_Query([['receive_date_low', '=', 20170101, 1, 0]]); @@ -86,7 +86,7 @@ public function testRelativeContributionDates() { $this->callAPISuccess('Contribution', 'delete', ['id' => $contribution2]); } - public function testContributionWithoutSoftCredits() { + public function testContributionWithoutSoftCredits(): void { $contribution1 = $this->contributionCreate(['receive_date' => '2018-01-02', 'contact_id' => $this->individualCreate()]); $contact2 = $this->callAPISuccess('Contact', 'create', [ 'display_name' => 'superman', diff --git a/tests/phpunit/CRM/Contribute/Form/ContributionPage/SettingsTest.php b/tests/phpunit/CRM/Contribute/Form/ContributionPage/SettingsTest.php index 9e01fba3a47e..77c38f3007a1 100644 --- a/tests/phpunit/CRM/Contribute/Form/ContributionPage/SettingsTest.php +++ b/tests/phpunit/CRM/Contribute/Form/ContributionPage/SettingsTest.php @@ -19,7 +19,7 @@ private function getCorrectFormFields() { /** * Test correct form submission. */ - public function testValidFormSubmission() { + public function testValidFormSubmission(): void { $values = $this->getCorrectFormFields(); $form = new CRM_Contribute_Form_ContributionPage_Settings(); $validationResult = \CRM_Contribute_Form_ContributionPage_Settings::formRule($values, [], $form); @@ -29,7 +29,7 @@ public function testValidFormSubmission() { /** * Test end date not allowed with only 'time' part. */ - public function testEndDateWithoutDateNotAllowed() { + public function testEndDateWithoutDateNotAllowed(): void { $values = $this->getCorrectFormFields(); $values['end_date'] = '00:01'; $form = new CRM_Contribute_Form_ContributionPage_Settings(); @@ -40,7 +40,7 @@ public function testEndDateWithoutDateNotAllowed() { /** * Test end date must be after start date. */ - public function testEndDateBeforeStartDateNotAllowed() { + public function testEndDateBeforeStartDateNotAllowed(): void { $values = $this->getCorrectFormFields(); $values['end_date'] = '1900-01-01 00:00'; $form = new CRM_Contribute_Form_ContributionPage_Settings(); diff --git a/tests/phpunit/CRM/Contribute/Form/ContributionPageTranslationTest.php b/tests/phpunit/CRM/Contribute/Form/ContributionPageTranslationTest.php index 76a0ac9fc34c..23598a53a829 100644 --- a/tests/phpunit/CRM/Contribute/Form/ContributionPageTranslationTest.php +++ b/tests/phpunit/CRM/Contribute/Form/ContributionPageTranslationTest.php @@ -33,7 +33,7 @@ public function tearDown(): void { /** * Create() method (create Contribution Page with Honor block) */ - public function testCreateHonor() { + public function testCreateHonor(): void { CRM_Core_I18n::singleton()->setLocale('en_US'); $params = [ diff --git a/tests/phpunit/CRM/Contribute/Form/ContributionTest.php b/tests/phpunit/CRM/Contribute/Form/ContributionTest.php index 73139803598f..47f6cca67046 100644 --- a/tests/phpunit/CRM/Contribute/Form/ContributionTest.php +++ b/tests/phpunit/CRM/Contribute/Form/ContributionTest.php @@ -2048,7 +2048,7 @@ public function additionalInfoProvider(): array { /** * Test formRule */ - public function testContributionFormRule() { + public function testContributionFormRule(): void { $fields = [ 'contact_id' => $this->_individualId, 'financial_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'financial_type_id', 'Donation'), diff --git a/tests/phpunit/CRM/Contribute/Form/ContributionViewTest.php b/tests/phpunit/CRM/Contribute/Form/ContributionViewTest.php index d95c0e255f5b..a05f85830fcf 100644 --- a/tests/phpunit/CRM/Contribute/Form/ContributionViewTest.php +++ b/tests/phpunit/CRM/Contribute/Form/ContributionViewTest.php @@ -43,7 +43,7 @@ public function tearDown(): void { /** * Test that can still view a contribution without full permissions. */ - public function testContributionViewLimitedPermissions() { + public function testContributionViewLimitedPermissions(): void { CRM_Core_Config::singleton()->userPermissionClass->permissions = [ 'access CiviCRM', 'access all custom data', @@ -75,7 +75,7 @@ public function testContributionViewLimitedPermissions() { $this->assertStringContainsString('Mr. Anthony Anderson II', $contents); } - public function testInvoiceDownload() { + public function testInvoiceDownload(): void { Civi::settings()->set('invoicing', 1); $_SERVER['REQUEST_URI'] = "civicrm/contribute/invoice?reset=1&id={$this->contribution['id']}&cid={$this->contact_id}"; diff --git a/tests/phpunit/CRM/Contribute/Form/SearchTest.php b/tests/phpunit/CRM/Contribute/Form/SearchTest.php index 0d396b645b81..71b478f0ef9a 100644 --- a/tests/phpunit/CRM/Contribute/Form/SearchTest.php +++ b/tests/phpunit/CRM/Contribute/Form/SearchTest.php @@ -38,7 +38,7 @@ public function tearDown(): void { /** * CRM-19325: Test CRM_Contribute_Form_Search batch filters */ - public function testBatchFilter() { + public function testBatchFilter(): void { $this->quickCleanup($this->_tablesToTruncate); $contactID1 = $this->individualCreate([], 1); $contactID2 = $this->individualCreate([], 2); @@ -155,7 +155,7 @@ public function testBatchFilter() { /** * CRM-20286: Test CRM_Contribute_Form_Search Card type filters */ - public function testCardTypeFilter() { + public function testCardTypeFilter(): void { $this->quickCleanup($this->_tablesToTruncate); $contactID1 = $this->individualCreate([], 1); $contactID2 = $this->individualCreate([], 2); @@ -257,7 +257,7 @@ public function testCardTypeFilter() { /** * CRM-20391: Test CRM_Contribute_Form_Search Card Number filters */ - public function testCardNumberFilter() { + public function testCardNumberFilter(): void { $this->quickCleanup($this->_tablesToTruncate); $contactID1 = $this->individualCreate([], 1); $contactID2 = $this->individualCreate([], 2); @@ -354,7 +354,7 @@ public function testCardNumberFilter() { /** * Test contact contributions. */ - public function testContributionSearchWithContactID() { + public function testContributionSearchWithContactID(): void { $contactID = $this->individualCreate([], 1); $fv = ['contact_id' => $contactID]; $queryParams = CRM_Contact_BAO_Query::convertFormValues($fv); @@ -415,7 +415,7 @@ public function testContributionRecurSearchFilters($formValues, $expectedCount, * * @throws CRM_Core_Exception */ - public function testCancelledFilter() { + public function testCancelledFilter(): void { $this->quickCleanup($this->_tablesToTruncate); $contactID1 = $this->individualCreate([], 1); $contactID2 = $this->individualCreate([], 2); diff --git a/tests/phpunit/CRM/Contribute/Form/Task/StatusTest.php b/tests/phpunit/CRM/Contribute/Form/Task/StatusTest.php index 02b91f99955f..13ece874a009 100644 --- a/tests/phpunit/CRM/Contribute/Form/Task/StatusTest.php +++ b/tests/phpunit/CRM/Contribute/Form/Task/StatusTest.php @@ -79,7 +79,7 @@ public function testUpdatePendingContributionWithSendingEmail(): void { /** * Test update pending contribution without sending a confirmation mail. */ - public function testUpdatePendingContributionWithoutSendingEmail() { + public function testUpdatePendingContributionWithoutSendingEmail(): void { $this->_individualId = $this->individualCreate(); $form = new CRM_Contribute_Form_Task_Status(); diff --git a/tests/phpunit/CRM/Contribute/Form/UpdateSubscriptionTest.php b/tests/phpunit/CRM/Contribute/Form/UpdateSubscriptionTest.php index 2199e7597513..d0d4e7ef9531 100644 --- a/tests/phpunit/CRM/Contribute/Form/UpdateSubscriptionTest.php +++ b/tests/phpunit/CRM/Contribute/Form/UpdateSubscriptionTest.php @@ -60,7 +60,7 @@ public function getExpectedMailStrings(): array { /** * Test the Additional Details pane loads for recurring contributions. */ - public function testAdditionalDetails() { + public function testAdditionalDetails(): void { $this->addContribution(); $templateContribution = CRM_Contribute_BAO_ContributionRecur::getTemplateContribution($this->getContributionRecurID()); $_GET['q'] = $_REQUEST['q'] = 'civicrm/contact/view/contribution'; diff --git a/tests/phpunit/CRM/Contribute/PseudoConstantTest.php b/tests/phpunit/CRM/Contribute/PseudoConstantTest.php index e7421c57b1d4..c12bd1980e8c 100644 --- a/tests/phpunit/CRM/Contribute/PseudoConstantTest.php +++ b/tests/phpunit/CRM/Contribute/PseudoConstantTest.php @@ -30,7 +30,7 @@ public function tearDown(): void { * * Future is CRM_Financial_BAO_FinancialAccount::getFinancialAccountForFinancialTypeByRelationship */ - public function testGetRelationalFinancialAccount() { + public function testGetRelationalFinancialAccount(): void { $financialTypes = $this->callAPISuccess('FinancialType', 'get', [])['values']; $financialAccounts = $this->callAPISuccess('FinancialAccount', 'get', [])['values']; foreach ($financialTypes as $financialType) { @@ -59,7 +59,7 @@ public function testGetRelationalFinancialAccount() { * * Future is CRM_Financial_BAO_FinancialAccount::getFinancialAccountForFinancialTypeByRelationship */ - public function testGetRelationalFinancialAccountForPaymentInstrument() { + public function testGetRelationalFinancialAccountForPaymentInstrument(): void { $paymentInstruments = $this->callAPISuccess('Contribution', 'getoptions', ['field' => 'payment_instrument_id'])['values']; $financialAccounts = $this->callAPISuccess('FinancialAccount', 'get', [])['values']; foreach ($paymentInstruments as $paymentInstrumentID => $paymentInstrumentName) { diff --git a/tests/phpunit/CRM/Contribute/Selector/SearchTest.php b/tests/phpunit/CRM/Contribute/Selector/SearchTest.php index 66810c3d4447..8baaca5234c7 100644 --- a/tests/phpunit/CRM/Contribute/Selector/SearchTest.php +++ b/tests/phpunit/CRM/Contribute/Selector/SearchTest.php @@ -19,7 +19,7 @@ class CRM_Contribute_Selector_SearchTest extends CiviUnitTestCase { /** * CRM-20866 - Soft credit appearance inconsistent in contribution search */ - public function testSoftCreditFieldsSelected() { + public function testSoftCreditFieldsSelected(): void { $queryParams = [['contribution_or_softcredits', '=', 'both_related', 0, 0]]; $searchSelector = new CRM_Contribute_Selector_Search($queryParams, CRM_Core_Action::VIEW); @@ -30,7 +30,7 @@ public function testSoftCreditFieldsSelected() { /** * CRM-20866 - Soft credit appearance inconsistent in contribution search */ - public function testSoftCreditFieldNotSelected() { + public function testSoftCreditFieldNotSelected(): void { $queryParams = [['contribution_or_softcredits', '=', 'only_contribs', 0, 0]]; $searchSelector = new CRM_Contribute_Selector_Search($queryParams, CRM_Core_Action::VIEW); diff --git a/tests/phpunit/CRM/Core/BAO/AddressTest.php b/tests/phpunit/CRM/Core/BAO/AddressTest.php index 5780a6c0a968..760f8ce00b95 100644 --- a/tests/phpunit/CRM/Core/BAO/AddressTest.php +++ b/tests/phpunit/CRM/Core/BAO/AddressTest.php @@ -27,7 +27,7 @@ public function setUp(): void { /** * Create() method (create and update modes) */ - public function testCreate() { + public function testCreate(): void { $contactId = $this->individualCreate(); $params = []; @@ -91,7 +91,7 @@ public function testCreate() { /** * Add() method ( ) */ - public function testAdd() { + public function testAdd(): void { $contactId = $this->individualCreate(); $fixParams = [ @@ -133,7 +133,7 @@ public function testAdd() { * Add 2 billing addresses using the `CRM_Core_BAO_Address::legacyCreate` mode * Only the first array will remain as primary/billing due to the nature of how `legacyCreate` works */ - public function testMultipleBillingAddressesLegacymode() { + public function testMultipleBillingAddressesLegacymode(): void { $contactId = $this->individualCreate(); $entityBlock = ['contact_id' => $contactId]; @@ -193,7 +193,7 @@ public function testMultipleBillingAddressesLegacymode() { * Using the `CRM_Core_BAO_Address::add` mode * */ - public function testMultipleBillingAddressesCurrentmode() { + public function testMultipleBillingAddressesCurrentmode(): void { $contactId = $this->individualCreate(); $entityBlock = ['contact_id' => $contactId]; @@ -263,7 +263,7 @@ public function testMultipleBillingAddressesCurrentmode() { /** * AllAddress() method ( ) */ - public function testallAddress() { + public function testallAddress(): void { $contactId = $this->individualCreate(); $fixParams = [ @@ -325,7 +325,7 @@ public function testallAddress() { /** * AllAddress() method ( ) with null value */ - public function testnullallAddress() { + public function testnullallAddress(): void { $contactId = $this->individualCreate(); $fixParams = [ @@ -365,7 +365,7 @@ public function testnullallAddress() { /** * GetValues() method (get Address fields) */ - public function testGetValues() { + public function testGetValues(): void { $contactId = $this->individualCreate(); $params = []; @@ -432,7 +432,7 @@ public function setStreetAddressParsing($status) { * * @throws \CRM_Core_Exception */ - public function testParseStreetAddressIfEnabled() { + public function testParseStreetAddressIfEnabled(): void { // Turn off address standardization. Parsing should work without it. Civi::settings()->set('address_standardization_provider', NULL); @@ -464,7 +464,7 @@ public function testParseStreetAddressIfEnabled() { /** * ParseStreetAddress() method (get street address parsed) */ - public function testParseStreetAddress() { + public function testParseStreetAddress(): void { // valid Street address to be parsed ( without locale ) $street_address = "54A Excelsior Ave. Apt 1C"; @@ -580,7 +580,7 @@ public function sampleOFUnsupportedAddressParsingLocales() { * Address of Contact C should reflect contact A's address change * Also, Contact C's address' master_id should be Contact A's address id. */ - public function testSharedAddressChaining1() { + public function testSharedAddressChaining1(): void { $contactIdA = $this->individualCreate([], 0); $contactIdB = $this->individualCreate([], 1); $contactIdC = $this->individualCreate([], 2); @@ -640,7 +640,7 @@ public function testSharedAddressChaining1() { * Address of Contact C should reflect contact B's address change * Also, Contact C's address' master_id should be Contact B's address id. */ - public function testSharedAddressChaining2() { + public function testSharedAddressChaining2(): void { $contactIdA = $this->individualCreate([], 0); $contactIdB = $this->individualCreate([], 1); $contactIdC = $this->individualCreate([], 2); @@ -706,7 +706,7 @@ public function testSharedAddressChaining2() { * 3. Use contact A's address for contact A's address * An error should be given, and master_id should remain the same. */ - public function testSharedAddressChaining3() { + public function testSharedAddressChaining3(): void { $contactIdA = $this->individualCreate([], 0); $addressParamsA = [ @@ -737,7 +737,7 @@ public function testSharedAddressChaining3() { * 1. test the creation of the shared address with custom field * 2. test the update of the custom field in the master */ - public function testSharedAddressCustomField() { + public function testSharedAddressCustomField(): void { $this->createCustomGroupWithFieldOfType(['extends' => 'Address'], 'text'); $customField = $this->getCustomFieldName('text'); @@ -784,7 +784,7 @@ public function testSharedAddressCustomField() { /** * Pinned countries with Default country */ - public function testPinnedCountriesWithDefaultCountry() { + public function testPinnedCountriesWithDefaultCountry(): void { // Guyana, Netherlands, United States $pinnedCountries = ['1093', '1152', '1228']; @@ -808,7 +808,7 @@ public function testPinnedCountriesWithDefaultCountry() { /** * Pinned countries with out Default country */ - public function testPinnedCountriesWithOutDefaultCountry() { + public function testPinnedCountriesWithOutDefaultCountry(): void { // Guyana, Netherlands, United States $pinnedCountries = ['1093', '1152', '1228']; @@ -833,7 +833,7 @@ public function testPinnedCountriesWithOutDefaultCountry() { /** * Test dev/core#2379 fix - geocodes shouldn't be > 14 characters. */ - public function testLongGeocodes() { + public function testLongGeocodes(): void { $contactId = $this->individualCreate(); $fixParams = [ diff --git a/tests/phpunit/CRM/Core/BAO/CacheTest.php b/tests/phpunit/CRM/Core/BAO/CacheTest.php index c11a7912c7a9..bab5c1707148 100644 --- a/tests/phpunit/CRM/Core/BAO/CacheTest.php +++ b/tests/phpunit/CRM/Core/BAO/CacheTest.php @@ -29,7 +29,7 @@ public function createSimpleCache() { ); } - public function testMultiVersionDecode() { + public function testMultiVersionDecode(): void { $encoders = ['serialize', ['CRM_Core_BAO_Cache', 'encode']]; $values = [NULL, 0, 1, TRUE, FALSE, [], ['abcd'], 'ab;cd', new stdClass()]; foreach ($encoders as $encoder) { diff --git a/tests/phpunit/CRM/Core/BAO/ConfigSettingTest.php b/tests/phpunit/CRM/Core/BAO/ConfigSettingTest.php index 47c112b5755f..7b328201336b 100644 --- a/tests/phpunit/CRM/Core/BAO/ConfigSettingTest.php +++ b/tests/phpunit/CRM/Core/BAO/ConfigSettingTest.php @@ -15,7 +15,7 @@ */ class CRM_Core_BAO_ConfigSettingTest extends CiviUnitTestCase { - public function testToggleComponent() { + public function testToggleComponent(): void { $origNames = []; foreach (CRM_Core_Component::getEnabledComponents() as $c) { $origNames[] = $c->name; diff --git a/tests/phpunit/CRM/Core/BAO/CustomFieldTest.php b/tests/phpunit/CRM/Core/BAO/CustomFieldTest.php index 0ca6ea7229f7..ca77e5441e68 100644 --- a/tests/phpunit/CRM/Core/BAO/CustomFieldTest.php +++ b/tests/phpunit/CRM/Core/BAO/CustomFieldTest.php @@ -53,7 +53,7 @@ public function testCreateCustomField(): void { /** * Test changing a data type from multiple-choice to Text. */ - public function testChangeDataType() { + public function testChangeDataType(): void { $customGroup = $this->createCustomField(); $fields = [ 'label' => 'Radio to Text', @@ -81,7 +81,7 @@ public function testChangeDataType() { /** * Test custom field create accepts passed column name. */ - public function testCreateCustomFieldColumnName() { + public function testCreateCustomFieldColumnName(): void { $customGroup = $this->customGroupCreate(['extends' => 'Individual']); $fields = [ 'label' => 'testFld 2', @@ -104,7 +104,7 @@ public function testCreateCustomFieldColumnName() { /** * Test that name is used for the column. */ - public function testCreateCustomFieldName() { + public function testCreateCustomFieldName(): void { $customGroup = $this->customGroupCreate(['extends' => 'Individual']); $fields = [ 'label' => 'testFld 2', @@ -127,7 +127,7 @@ public function testCreateCustomFieldName() { /** * Test get fields function. */ - public function testGetFields() { + public function testGetFields(): void { $customGroup = $this->customGroupCreate(['extends' => 'Individual']); $fields = [ 'label' => 'testFld1', @@ -158,7 +158,7 @@ public function testGetFields() { /** * @throws \Exception */ - public function testGetDisplayedValues() { + public function testGetDisplayedValues(): void { $customGroup = $this->customGroupCreate(['extends' => 'Individual']); $fieldsToCreate = [ [ @@ -249,7 +249,7 @@ public function testGetDisplayedValues() { * @throws \CRM_Core_Exception * @throws \Exception */ - public function testGetDisplayedValuesContactRef() { + public function testGetDisplayedValuesContactRef(): void { $customGroup = $this->customGroupCreate(['extends' => 'Individual']); $params = [ 'data_type' => 'ContactReference', @@ -269,7 +269,7 @@ public function testGetDisplayedValuesContactRef() { $this->customGroupDelete($customGroup['id']); } - public function testDeleteCustomField() { + public function testDeleteCustomField(): void { $customGroup = $this->customGroupCreate(['extends' => 'Individual']); $fields = [ 'custom_group_id' => $customGroup['id'], @@ -296,7 +296,7 @@ public function testDeleteCustomField() { * * @throws \CRM_Core_Exception */ - public function testMoveField() { + public function testMoveField(): void { $countriesByName = array_flip(CRM_Core_PseudoConstant::country(FALSE, FALSE)); $this->assertTrue($countriesByName['Andorra'] > 0); $groups = [ @@ -427,7 +427,7 @@ public function testMoveField() { * * @throws \CRM_Core_Exception */ - public function testGetCustomFieldID() { + public function testGetCustomFieldID(): void { $this->createCustomField(); $fieldID = CRM_Core_BAO_CustomField::getCustomFieldID('testFld'); $this->assertEquals($this->customFieldID, $fieldID); @@ -473,7 +473,7 @@ protected function createCustomField($groupTitle = 'new custom group') { * * @throws \Exception */ - public function testGetFieldsForImport() { + public function testGetFieldsForImport(): void { $this->createCustomGroupWithFieldsOfAllTypes(); $customGroupID = $this->ids['CustomGroup']['Custom Group']; $expected = [ @@ -1004,7 +1004,7 @@ public function testFileDisplayValueNoDescription(): void { /** * Test for hook_civicrm_alterCustomFieldDisplayValue(). */ - public function testAlterCustomFieldDisplayValueHook() { + public function testAlterCustomFieldDisplayValueHook(): void { CRM_Utils_Hook_UnitTests::singleton()->setHook('civicrm_alterCustomFieldDisplayValue', [$this, 'alterCustomFieldDisplayValue']); $customGroupId = $this->customGroupCreate([ 'extends' => 'Individual', @@ -1051,7 +1051,7 @@ public function alterCustomFieldDisplayValue(&$displayValue, $value, $entityId, * Test for single select Autocomplete custom field. * */ - public function testSingleSelectAutoComplete() { + public function testSingleSelectAutoComplete(): void { $customGroupId = $this->customGroupCreate([ 'extends' => 'Individual', ])['id']; @@ -1072,7 +1072,7 @@ public function testSingleSelectAutoComplete() { * Test for multi select Autocomplete custom field. * */ - public function testMultiSelectAutoComplete() { + public function testMultiSelectAutoComplete(): void { $customGroupId = $this->customGroupCreate([ 'extends' => 'Individual', ])['id']; diff --git a/tests/phpunit/CRM/Core/BAO/CustomGroupTest.php b/tests/phpunit/CRM/Core/BAO/CustomGroupTest.php index 473edd46dfb6..43ec4a488200 100644 --- a/tests/phpunit/CRM/Core/BAO/CustomGroupTest.php +++ b/tests/phpunit/CRM/Core/BAO/CustomGroupTest.php @@ -30,7 +30,7 @@ public function tearDown(): void { /** * Test getTree(). */ - public function testGetTree() { + public function testGetTree(): void { $customGroup = $this->CustomGroupCreate(); $customField = $this->customFieldCreate(['custom_group_id' => $customGroup['id']]); $result = CRM_Core_BAO_CustomGroup::getTree('Individual', NULL, $customGroup['id']); @@ -43,7 +43,7 @@ public function testGetTree() { * Note that the function seems to support a range of formats so 3 are tested. Yay for * inconsistency. */ - public function testGetTreeContactSubType() { + public function testGetTreeContactSubType(): void { $contactType = $this->callAPISuccess('ContactType', 'create', ['name' => 'Big Bank', 'label' => 'biggee', 'parent_id' => 'Organization']); $customGroup = $this->CustomGroupCreate(['extends' => 'Organization', 'extends_entity_column_value' => ['Big_Bank']]); $customField = $this->customFieldCreate(['custom_group_id' => $customGroup['id']]); @@ -67,7 +67,7 @@ public function testGetTreeContactSubType() { /** * Test calling getTree for a custom field extending a renamed contact type. */ - public function testGetTreeContactSubTypeForNameChangedContactType() { + public function testGetTreeContactSubTypeForNameChangedContactType(): void { $contactType = $this->callAPISuccess('ContactType', 'create', ['name' => 'Big Bank', 'label' => 'biggee', 'parent_id' => 'Organization']); CRM_Core_DAO::executeQuery('UPDATE civicrm_contact_type SET label = "boo" WHERE name = "Organization"'); $customGroup = $this->CustomGroupCreate(['extends' => 'Organization', 'extends_entity_column_value' => ['Big_Bank']]); @@ -81,7 +81,7 @@ public function testGetTreeContactSubTypeForNameChangedContactType() { /** * Test calling getTree for a custom field extending a disabled contact type. */ - public function testGetTreeContactSubTypeForDisabledChangedContactType() { + public function testGetTreeContactSubTypeForDisabledChangedContactType(): void { $contactType = $this->callAPISuccess('ContactType', 'create', ['name' => 'Big Bank', 'label' => 'biggee', 'parent_id' => 'Organization']); $customGroup = $this->CustomGroupCreate(['extends' => 'Organization', 'extends_entity_column_value' => ['Big_Bank']]); $customField = $this->customFieldCreate(['custom_group_id' => $customGroup['id']]); @@ -95,7 +95,7 @@ public function testGetTreeContactSubTypeForDisabledChangedContactType() { /** * Test calling GetTree for a custom field extending multiple subTypes. */ - public function testGetTreetContactSubTypeForMultipleSubTypes() { + public function testGetTreetContactSubTypeForMultipleSubTypes(): void { $contactType1 = $this->callAPISuccess('ContactType', 'create', ['name' => 'Big Bank', 'label' => 'biggee', 'parent_id' => 'Organization']); $contactType2 = $this->callAPISuccess('ContactType', 'create', ['name' => 'Small Bank', 'label' => 'smallee', 'parent_id' => 'Organization']); $customGroup = $this->CustomGroupCreate(['extends' => 'Organization', 'extends_entity_column_value' => ['Big_Bank', 'Small_Bank']]); @@ -110,7 +110,7 @@ public function testGetTreetContactSubTypeForMultipleSubTypes() { /** * Test calling GetTree for a custom field that extends a non numerical Event Type. */ - public function testGetTreeEventSubTypeAlphabetical() { + public function testGetTreeEventSubTypeAlphabetical(): void { $eventType = $this->callAPISuccess('OptionValue', 'Create', ['option_group_id' => 'event_type', 'value' => 'meeting', 'label' => 'Meeting']); $customGroup = $this->CustomGroupCreate(['extends' => 'Event', 'extends_entity_column_value' => ['Meeting']]); $customField = $this->customFieldCreate(['custom_group_id' => $customGroup['id']]); @@ -126,7 +126,7 @@ public function testGetTreeEventSubTypeAlphabetical() { * Note that the function seems to support a range of formats so 3 are tested. Yay for * inconsistency. */ - public function testGetTreeCampaignSubType() { + public function testGetTreeCampaignSubType(): void { $sep = CRM_Core_DAO::VALUE_SEPARATOR; $this->campaignCreate(); $this->campaignCreate(); @@ -143,7 +143,7 @@ public function testGetTreeCampaignSubType() { /** * Test calling getTree with contact subtype data. */ - public function testGetTreeActivitySubType() { + public function testGetTreeActivitySubType(): void { $customGroup = $this->CustomGroupCreate(['extends' => 'Activity', 'extends_entity_column_value' => 1]); $customField = $this->customFieldCreate(['custom_group_id' => $customGroup['id']]); $result = CRM_Core_BAO_CustomGroup::getTree('Activity', NULL, NULL, NULL, 1); @@ -162,7 +162,7 @@ public function testRetrieveEmptyParams(): void { /** * Test retrieve() with Inalid Params */ - public function testRetrieveInvalidParams() { + public function testRetrieveInvalidParams(): void { $params = ['id' => 99]; $customGroup = CRM_Core_BAO_CustomGroup::retrieve($params, $dafaults); $this->assertNull($customGroup, 'Check that no custom Group is retreived'); @@ -171,7 +171,7 @@ public function testRetrieveInvalidParams() { /** * Test retrieve() */ - public function testRetrieve() { + public function testRetrieve(): void { $customGroupTitle = 'Custom Group'; $groupParams = [ 'title' => $customGroupTitle, @@ -193,7 +193,7 @@ public function testRetrieve() { /** * Test getGroupDetail() with Empty Params */ - public function testGetGroupDetailEmptyParams() { + public function testGetGroupDetailEmptyParams(): void { $customGroupId = []; $customGroup = CRM_Core_BAO_CustomGroup::getGroupDetail($customGroupId); $this->assertTrue(empty($customGroup), 'Check that no custom Group details is retreived'); @@ -202,7 +202,7 @@ public function testGetGroupDetailEmptyParams() { /** * Test getGroupDetail with Invalid Params. */ - public function testGetGroupDetailInvalidParams() { + public function testGetGroupDetailInvalidParams(): void { $customGroupId = 99; $customGroup = CRM_Core_BAO_CustomGroup::getGroupDetail($customGroupId); $this->assertTrue(empty($customGroup), 'Check that no custom Group details is retreived'); @@ -211,7 +211,7 @@ public function testGetGroupDetailInvalidParams() { /** * Test getGroupDetail(). */ - public function testGetGroupDetail() { + public function testGetGroupDetail(): void { $customGroupTitle = 'My Custom Group'; $groupParams = [ 'title' => $customGroupTitle, @@ -262,7 +262,7 @@ public function testGetGroupDetail() { /** * Test getTitle() with Invalid Params() */ - public function testGetTitleWithInvalidParams() { + public function testGetTitleWithInvalidParams(): void { $params = 99; $customGroupTitle = CRM_Core_BAO_CustomGroup::getTitle($params); @@ -272,7 +272,7 @@ public function testGetTitleWithInvalidParams() { /** * Test getTitle() */ - public function testGetTitle() { + public function testGetTitle(): void { $customGroupTitle = 'Custom Group'; $groupParams = [ 'title' => $customGroupTitle, @@ -297,7 +297,7 @@ public function testGetTitle() { /** * Test deleteGroup. */ - public function testDeleteGroup() { + public function testDeleteGroup(): void { $customGroupTitle = 'My Custom Group'; $groupParams = [ 'title' => $customGroupTitle, @@ -362,7 +362,7 @@ public function testCreateTable(): void { * * @throws \CRM_Core_Exception */ - public function testCheckCustomField() { + public function testCheckCustomField(): void { $groupParams = [ 'title' => 'My Custom Group', 'name' => 'my_custom_group', @@ -425,7 +425,7 @@ public function testGetActiveGroupsWithInvalidParams(): void { $this->assertEquals(empty($activeGroups), TRUE, 'Check that Emprt params are retreived'); } - public function testGetActiveGroups() { + public function testGetActiveGroups(): void { $contactId = $this->individualCreate(); $customGroupTitle = 'Custom Group'; $groupParams = [ @@ -514,7 +514,7 @@ public function testCreateTableName(): void { /** * Test isGroupEmpty() */ - public function testIsGroupEmpty() { + public function testIsGroupEmpty(): void { $customGroupTitle = 'Test Custom Group'; $groupParams = [ 'title' => $customGroupTitle, @@ -536,7 +536,7 @@ public function testIsGroupEmpty() { /** * Test getGroupTitles() with Invalid Params() */ - public function testGetGroupTitlesWithInvalidParams() { + public function testGetGroupTitlesWithInvalidParams(): void { $params = [99]; $groupTitles = CRM_Core_BAO_CustomGroup::getGroupTitles($params); $this->assertTrue(empty($groupTitles), 'Check that no titles are received'); @@ -545,7 +545,7 @@ public function testGetGroupTitlesWithInvalidParams() { /** * Test getGroupTitles() */ - public function testGetGroupTitles() { + public function testGetGroupTitles(): void { $groupParams = [ 'title' => 'Test Group', 'name' => 'test_custom_group', @@ -581,7 +581,7 @@ public function testGetGroupTitles() { /** * Test that passed dates are extracted from the url when processing custom data. */ - public function testExtractGetParamsReturnsDates() { + public function testExtractGetParamsReturnsDates(): void { // Create a custom group to contain the custom field. $groupParams = [ 'title' => 'My Custom Group', @@ -657,7 +657,7 @@ public function testAllowedGroupNames(string $extends, string $name, bool $isAll $this->assertEquals($expectedName, $group->name); } - public function testCustomGroupExtends() { + public function testCustomGroupExtends(): void { $extends = \CRM_Core_SelectValues::customGroupExtends(); $this->assertArrayHasKey('Contribution', $extends); $this->assertArrayHasKey('Case', $extends); @@ -671,7 +671,7 @@ public function testCustomGroupExtends() { $this->assertArrayHasKey('ParticipantEventType', $extends); } - public function testMapTableName() { + public function testMapTableName(): void { $this->assertEquals('civicrm_case', CRM_Core_BAO_CustomGroup::mapTableName('Case')); $this->assertEquals('civicrm_contact', CRM_Core_BAO_CustomGroup::mapTableName('Contact')); $this->assertEquals('civicrm_contact', CRM_Core_BAO_CustomGroup::mapTableName('Individual')); diff --git a/tests/phpunit/CRM/Core/BAO/CustomQueryTest.php b/tests/phpunit/CRM/Core/BAO/CustomQueryTest.php index c7a0ef4df47a..678c32a30c07 100644 --- a/tests/phpunit/CRM/Core/BAO/CustomQueryTest.php +++ b/tests/phpunit/CRM/Core/BAO/CustomQueryTest.php @@ -27,7 +27,7 @@ public function tearDown(): void { * * @throws \CRM_Core_Exception */ - public function testSearchCustomDataDateRelative() { + public function testSearchCustomDataDateRelative(): void { $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, 'ContactTestTest'); $dateCustomField = $this->customFieldCreate([ 'custom_group_id' => $ids['custom_group_id'], @@ -99,7 +99,7 @@ public function testSearchCustomDataDateRelative() { * @throws \CRM_Core_Exception * @throws \Civi\API\Exception\UnauthorizedException */ - public function testSearchCustomDataDateHighLow() { + public function testSearchCustomDataDateHighLow(): void { $this->createCustomGroupWithFieldOfType([], 'date'); $dateCustomFieldName = $this->getCustomFieldName('date'); // Assigning the relevant form value to be within a custom key is normally done in @@ -132,7 +132,7 @@ public function testSearchCustomDataDateHighLow() { * @throws \CRM_Core_Exception * @throws \Civi\API\Exception\UnauthorizedException */ - public function testSearchCustomDataDateLowWithPermsInPlay() { + public function testSearchCustomDataDateLowWithPermsInPlay(): void { $this->createLoggedInUser(); CRM_Core_Config::singleton()->userPermissionClass->permissions = ['view all contacts', 'access all custom data']; $this->createCustomGroupWithFieldOfType([], 'date'); @@ -166,7 +166,7 @@ public function testSearchCustomDataDateLowWithPermsInPlay() { * * @throws \CRM_Core_Exception */ - public function testSearchCustomDataDateFromTo() { + public function testSearchCustomDataDateFromTo(): void { $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, 'ContactTestTest'); $dateCustomField = $this->customFieldCreate([ 'custom_group_id' => $ids['custom_group_id'], @@ -203,7 +203,7 @@ public function testSearchCustomDataDateFromTo() { * * @throws \CRM_Core_Exception */ - public function testSearchCustomDataFromTo() { + public function testSearchCustomDataFromTo(): void { $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, 'ContactTestTest'); $datas = [ 'Int' => 2, @@ -247,7 +247,7 @@ public function testSearchCustomDataFromTo() { * * @throws \CRM_Core_Exception */ - public function testLocalizedSearchCustomDataFromTo() { + public function testLocalizedSearchCustomDataFromTo(): void { $this->setMonetaryDecimalPoint(','); $this->setMonetaryThousandSeparator('.'); $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, 'ContactTestTest'); @@ -299,7 +299,7 @@ public function testLocalizedSearchCustomDataFromTo() { * * @throws \CRM_Core_Exception */ - public function testSearchCustomDataFromAndTo() { + public function testSearchCustomDataFromAndTo(): void { $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, 'ContactTestTest'); $dataSet = [ 'Date' => ['value' => '2015-06-06', 'sql_string' => '"20150606235959"', 'qill_string' => "'June 6th, 2015 11:59 PM'", 'qill_string_greater' => "'June 6th, 2015 12:00 AM'"], @@ -374,7 +374,7 @@ public function testSearchCustomDataFromAndTo() { * * @throws \CRM_Core_Exception */ - public function testLocalizedSearchCustomDataFromAndTo() { + public function testLocalizedSearchCustomDataFromAndTo(): void { $this->setMonetaryDecimalPoint(','); $this->setMonetaryThousandSeparator('.'); $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, 'ContactTestTest'); @@ -455,7 +455,7 @@ public function testLocalizedSearchCustomDataFromAndTo() { * * @throws \CRM_Core_Exception */ - public function testSearchCustomDataDateEquals() { + public function testSearchCustomDataDateEquals(): void { $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, 'ContactTestTest'); $dateCustomField = $this->customFieldCreate([ 'custom_group_id' => $ids['custom_group_id'], @@ -487,7 +487,7 @@ public function testSearchCustomDataDateEquals() { * @throws \CRM_Core_Exception * @throws \Civi\API\Exception\UnauthorizedException */ - public function testAddressCustomFields() { + public function testAddressCustomFields(): void { $this->createCustomGroupWithFieldOfType(['extends' => 'Address'], 'int'); $individualID = $this->individualCreate(); $this->callAPISuccess('Address', 'create', [ diff --git a/tests/phpunit/CRM/Core/BAO/CustomValueTableMultipleTest.php b/tests/phpunit/CRM/Core/BAO/CustomValueTableMultipleTest.php index 21a283af9af7..f3cbb81e1c48 100644 --- a/tests/phpunit/CRM/Core/BAO/CustomValueTableMultipleTest.php +++ b/tests/phpunit/CRM/Core/BAO/CustomValueTableMultipleTest.php @@ -50,7 +50,7 @@ public function testCustomGroupMultipleSingle(): void { $this->contactDelete($contactID); } - public function testCustomGroupMultipleDouble() { + public function testCustomGroupMultipleDouble(): void { $contactID = $this->individualCreate(); $customGroup = $this->customGroupCreate(['is_multiple' => 1]); $fields = [ @@ -82,7 +82,7 @@ public function testCustomGroupMultipleDouble() { $this->contactDelete($contactID); } - public function testCustomGroupMultipleUpdate() { + public function testCustomGroupMultipleUpdate(): void { $contactID = $this->individualCreate(); $customGroup = $this->customGroupCreate(['is_multiple' => 1]); $fields = [ @@ -123,7 +123,7 @@ public function testCustomGroupMultipleUpdate() { $this->contactDelete($contactID); } - public function testCustomGroupMultipleOldFormat() { + public function testCustomGroupMultipleOldFormat(): void { $contactID = $this->individualCreate(); $customGroup = $this->customGroupCreate(['is_multiple' => 1]); $fields = [ diff --git a/tests/phpunit/CRM/Core/BAO/CustomValueTableSetGetTest.php b/tests/phpunit/CRM/Core/BAO/CustomValueTableSetGetTest.php index 58363e42ca01..4aaa8a5e86dd 100644 --- a/tests/phpunit/CRM/Core/BAO/CustomValueTableSetGetTest.php +++ b/tests/phpunit/CRM/Core/BAO/CustomValueTableSetGetTest.php @@ -109,7 +109,7 @@ public function testSetGetValuesDate(): void { /** * Test setValues() and getValues() methods with custom field YesNo(Boolean) Radio */ - public function testSetGetValuesYesNoRadio() { + public function testSetGetValuesYesNoRadio(): void { $contactID = $this->individualCreate(); $customGroup = $this->customGroupCreate(['is_multiple' => 1]); diff --git a/tests/phpunit/CRM/Core/BAO/CustomValueTableTest.php b/tests/phpunit/CRM/Core/BAO/CustomValueTableTest.php index 7961daca8ccc..03d43b8e4955 100644 --- a/tests/phpunit/CRM/Core/BAO/CustomValueTableTest.php +++ b/tests/phpunit/CRM/Core/BAO/CustomValueTableTest.php @@ -14,7 +14,7 @@ public function tearDown(): void { /** * Test store function for country. */ - public function testStoreCountry() { + public function testStoreCountry(): void { $params = []; $contactID = $this->individualCreate(); $customGroup = $this->customGroupCreate(); @@ -45,7 +45,7 @@ public function testStoreCountry() { /** * Test store function for file. */ - public function testStoreFile() { + public function testStoreFile(): void { $contactID = $this->individualCreate(); $file = $this->callAPISuccess('File', 'create', ['uri' => 'dummy_data']); $customGroup = $this->customGroupCreate(); diff --git a/tests/phpunit/CRM/Core/BAO/CustomValueTest.php b/tests/phpunit/CRM/Core/BAO/CustomValueTest.php index 98e740ab8054..37189346d706 100644 --- a/tests/phpunit/CRM/Core/BAO/CustomValueTest.php +++ b/tests/phpunit/CRM/Core/BAO/CustomValueTest.php @@ -21,7 +21,7 @@ */ class CRM_Core_BAO_CustomValueTest extends CiviUnitTestCase { - public function testTypeCheckWithValidInput() { + public function testTypeCheckWithValidInput(): void { $values = [ 'Memo' => 'Test1', @@ -45,7 +45,7 @@ public function testTypeCheckWithValidInput() { } } - public function testTypeCheckWithInvalidInput() { + public function testTypeCheckWithInvalidInput(): void { $values = ['check1' => 'chk']; foreach ($values as $type => $value) { $valid = CRM_Core_BAO_CustomValue::typecheck($type, $value); @@ -53,7 +53,7 @@ public function testTypeCheckWithInvalidInput() { } } - public function testTypeCheckWithWrongInput() { + public function testTypeCheckWithWrongInput(): void { $values = [ 'String' => 1, 'Boolean' => 'US', @@ -64,7 +64,7 @@ public function testTypeCheckWithWrongInput() { } } - public function testTypeToFieldWithValidInput() { + public function testTypeToFieldWithValidInput(): void { $values = [ 'String' => 'char_data', 'File' => 'char_data', @@ -85,7 +85,7 @@ public function testTypeToFieldWithValidInput() { } } - public function testTypeToFieldWithWrongInput() { + public function testTypeToFieldWithWrongInput(): void { $values = [ 'String' => 'memo_data', 'File' => 'date_data', @@ -97,7 +97,7 @@ public function testTypeToFieldWithWrongInput() { } } - public function testFixCustomFieldValue() { + public function testFixCustomFieldValue(): void { $customGroup = $this->customGroupCreate(['extends' => 'Individual']); $params = [ 'email' => 'abc@example.com', @@ -154,7 +154,7 @@ public function testFixCustomFieldValue() { $this->customGroupDelete($customGroup['id']); } - public function testFixCustomFieldValueWithEmptyParams() { + public function testFixCustomFieldValueWithEmptyParams(): void { $params = []; $result = CRM_Core_BAO_CustomValue::fixCustomFieldValue($params); $this->assertEquals($result, NULL, 'Checking the returned value of type Memo.'); diff --git a/tests/phpunit/CRM/Core/BAO/EmailTest.php b/tests/phpunit/CRM/Core/BAO/EmailTest.php index 8a0f96e13af3..40696634bd3b 100644 --- a/tests/phpunit/CRM/Core/BAO/EmailTest.php +++ b/tests/phpunit/CRM/Core/BAO/EmailTest.php @@ -21,7 +21,7 @@ public function setUp(): void { * * @throws \CRM_Core_Exception */ - public function testCreate() { + public function testCreate(): void { $contactId = $this->individualCreate(); $params = [ 'email' => 'jane.doe@example.com', @@ -59,7 +59,7 @@ public function testCreate() { * * @throws \CRM_Core_Exception */ - public function testHoldEmail() { + public function testHoldEmail(): void { $contactId = $this->individualCreate(); $params = [ @@ -154,7 +154,7 @@ public function testHoldEmail() { * * @throws \CRM_Core_Exception */ - public function testAllEmails() { + public function testAllEmails(): void { $contactParams = [ 'first_name' => 'Alan', 'last_name' => 'Smith', @@ -182,7 +182,7 @@ public function testAllEmails() { * * @throws \CRM_Core_Exception */ - public function testGetFromEmail() { + public function testGetFromEmail(): void { $this->createLoggedInUser(); $fromEmails = CRM_Core_BAO_Email::getFromEmail(); $emails = array_values($fromEmails); diff --git a/tests/phpunit/CRM/Core/BAO/FinancialTrxnTest.php b/tests/phpunit/CRM/Core/BAO/FinancialTrxnTest.php index d503dcdd1efb..5ccb5a027699 100644 --- a/tests/phpunit/CRM/Core/BAO/FinancialTrxnTest.php +++ b/tests/phpunit/CRM/Core/BAO/FinancialTrxnTest.php @@ -27,7 +27,7 @@ public function tearDown(): void { * * @throws \CRM_Core_Exception */ - public function testCreate() { + public function testCreate(): void { $contactId = $this->individualCreate(); $financialTypeId = 1; $contributionID = $this->contributionCreate([ @@ -193,7 +193,7 @@ public function testUpdateCreditCardDetailsUsingContributionAPI(): void { * * @throws \CRM_Core_Exception */ - public function testUpdateCreditCardDetails() { + public function testUpdateCreditCardDetails(): void { $cid = $this->individualCreate(); $params = [ 'contact_id' => $cid, @@ -229,7 +229,7 @@ public function testUpdateCreditCardDetails() { * * @throws \CRM_Core_Exception */ - public function testGetContributionBalance() { + public function testGetContributionBalance(): void { //create the contribution that isn't paid yet $contactId = $this->individualCreate(); $params = [ @@ -259,7 +259,7 @@ public function testGetContributionBalance() { * * @throws \CRM_Core_Exception */ - public function testFeeAmountTrxns() { + public function testFeeAmountTrxns(): void { $contactId = $this->individualCreate(); // Get the expected financial account of a payment made with a credit card. diff --git a/tests/phpunit/CRM/Core/BAO/IMTest.php b/tests/phpunit/CRM/Core/BAO/IMTest.php index 9b56f1568f33..3105f89ffa5b 100644 --- a/tests/phpunit/CRM/Core/BAO/IMTest.php +++ b/tests/phpunit/CRM/Core/BAO/IMTest.php @@ -11,7 +11,7 @@ class CRM_Core_BAO_IMTest extends CiviUnitTestCase { /** * Create() method (create and update modes) */ - public function testCreate() { + public function testCreate(): void { $contactId = $this->individualCreate(); $params = [ @@ -50,7 +50,7 @@ public function testCreate() { /** * AllIMs() method - get all IMs for our contact, with primary IM first */ - public function testAllIMs() { + public function testAllIMs(): void { $this->loadXMLDataSet(dirname(__FILE__) . '/dataset/im_test.xml'); $contactId = 69; diff --git a/tests/phpunit/CRM/Core/BAO/MappingTest.php b/tests/phpunit/CRM/Core/BAO/MappingTest.php index fee5ff7179c9..3d080460bcf4 100644 --- a/tests/phpunit/CRM/Core/BAO/MappingTest.php +++ b/tests/phpunit/CRM/Core/BAO/MappingTest.php @@ -222,7 +222,7 @@ public function getMappingMaps() { /** * Ensure getCreateMappingValues() doesn't return an error when there are spaces in the name. */ - public function testGetCreateMappingValues() { + public function testGetCreateMappingValues(): void { CRM_Core_BAO_Mapping::getCreateMappingValues("Import Multi value custom data"); } diff --git a/tests/phpunit/CRM/Core/BAO/NavigationTest.php b/tests/phpunit/CRM/Core/BAO/NavigationTest.php index b865fa6055e8..3ede2f914e2a 100644 --- a/tests/phpunit/CRM/Core/BAO/NavigationTest.php +++ b/tests/phpunit/CRM/Core/BAO/NavigationTest.php @@ -19,7 +19,7 @@ public function setUp(): void { /** * Test that a missing report menu link is added by rebuildReportsNavigation. */ - public function testCreateMissingReportMenuItemLink() { + public function testCreateMissingReportMenuItemLink(): void { $reportCount = $this->getCountReportInstances(); CRM_Core_DAO::executeQuery("DELETE FROM civicrm_navigation WHERE url LIKE 'civicrm/report/instance/1?reset=1%'"); $this->assertEquals($reportCount - 1, $this->getCountReportInstances()); @@ -36,7 +36,7 @@ public function testCreateMissingReportMenuItemLink() { /** * Test that a link with output=criteria at the end is not duplicated. */ - public function testNoDuplicateReportMenuItemLink() { + public function testNoDuplicateReportMenuItemLink(): void { CRM_Core_BAO_Navigation::rebuildReportsNavigation(CRM_Core_Config::domainID()); $reportCount = $this->getCountReportInstances(); CRM_Core_DAO::executeQuery(" @@ -56,7 +56,7 @@ public function testNoDuplicateReportMenuItemLink() { * both winding up under the Reports menu - since they already exist they should be unchanged * by rebuilding reports. */ - public function testNoDuplicateAllReportsLink() { + public function testNoDuplicateAllReportsLink(): void { $existing_links = $this->callAPISuccess('Navigation', 'get', ['label' => 'All Reports', 'sequential' => 1]); $this->assertNotEquals($existing_links['values'][0]['parent_id'], $existing_links['values'][1]['parent_id']); CRM_Core_BAO_Navigation::rebuildReportsNavigation(CRM_Core_Config::domainID()); @@ -70,7 +70,7 @@ public function testNoDuplicateAllReportsLink() { * * Function tests CRM_Core_BAO_Navigation::rebuildReportsNavigation. */ - public function testUpdateExistingReportMenuLink() { + public function testUpdateExistingReportMenuLink(): void { $url = 'civicrm/report/instance/1'; $url_params = 'reset=1'; $existing_nav = CRM_Core_BAO_Navigation::getNavItemByUrl($url, $url_params); @@ -93,7 +93,7 @@ public function testUpdateExistingReportMenuLink() { /** * Test that a navigation item can be retrieved by it's url. */ - public function testGetNavItemByUrl() { + public function testGetNavItemByUrl(): void { $random_string = substr(sha1(rand()), 0, 7); $name = "Test Menu Link {$random_string}"; $url = "civicrm/test/{$random_string}"; @@ -121,7 +121,7 @@ public function testGetNavItemByUrl() { * We want to be able to get a report url with OR without the output=criteria since * that is part of the navigation but not the instance. */ - public function testGetNavItemByUrlWildcard() { + public function testGetNavItemByUrlWildcard(): void { $random_string = substr(sha1(rand()), 0, 7); $name = "Test Menu Link {$random_string}"; $url = "civicrm/test/{$random_string}"; @@ -168,7 +168,7 @@ protected function getCountURL($url) { * Run fixNavigationMenu() on a menu which already has navIDs * everywhere. They should be unchanged. */ - public function testFixNavigationMenu_preserveIDs() { + public function testFixNavigationMenu_preserveIDs(): void { $input[10] = [ 'attributes' => [ 'label' => 'Custom Menu Entry', @@ -201,7 +201,7 @@ public function testFixNavigationMenu_preserveIDs() { * Run fixNavigationMenu() on a menu which is missing some navIDs. They * should be filled in, and others should be preserved. */ - public function testFixNavigationMenu_inferIDs() { + public function testFixNavigationMenu_inferIDs(): void { $input[10] = [ 'attributes' => [ 'label' => 'Custom Menu Entry', @@ -242,7 +242,7 @@ public function testFixNavigationMenu_inferIDs() { $this->assertEquals(100, $output[10]['child'][100]['attributes']['navID']); } - public function testFixNavigationMenu_inferIDs_deep() { + public function testFixNavigationMenu_inferIDs_deep(): void { $input[10] = [ 'attributes' => [ 'label' => 'Custom Menu Entry', @@ -287,7 +287,7 @@ public function testFixNavigationMenu_inferIDs_deep() { /** * Tests that permissions and component status are checked with the correct operator. */ - public function testCheckPermissions() { + public function testCheckPermissions(): void { $menuItem = [ 'permission' => 'access CiviCRM, access CiviContribute', 'operator' => 'AND', diff --git a/tests/phpunit/CRM/Core/BAO/OpenIDTest.php b/tests/phpunit/CRM/Core/BAO/OpenIDTest.php index 85b5899d440e..726134128a13 100644 --- a/tests/phpunit/CRM/Core/BAO/OpenIDTest.php +++ b/tests/phpunit/CRM/Core/BAO/OpenIDTest.php @@ -16,7 +16,7 @@ public function tearDown(): void { /** * Add() method (create and update modes) */ - public function testAdd() { + public function testAdd(): void { $contactId = $this->individualCreate(); $this->assertDBRowExist('CRM_Contact_DAO_Contact', $contactId); @@ -55,7 +55,7 @@ public function testAdd() { /** * AllOpenIDs() method - get all OpenIDs for the given contact */ - public function testAllOpenIDs() { + public function testAllOpenIDs(): void { $contactId = $this->individualCreate(); $this->assertDBRowExist('CRM_Contact_DAO_Contact', $contactId); diff --git a/tests/phpunit/CRM/Core/BAO/OptionGroupTest.php b/tests/phpunit/CRM/Core/BAO/OptionGroupTest.php index ef9d7d5d5252..cd45b4a04483 100644 --- a/tests/phpunit/CRM/Core/BAO/OptionGroupTest.php +++ b/tests/phpunit/CRM/Core/BAO/OptionGroupTest.php @@ -29,7 +29,7 @@ public function setUp(): void { /** * Ensure only one option value exists after calling ensureOptionValueExists. */ - public function testEnsureOptionGroupExistsExistingValue() { + public function testEnsureOptionGroupExistsExistingValue(): void { CRM_Core_BAO_OptionGroup::ensureOptionGroupExists(['name' => 'contribution_status']); $this->callAPISuccessGetSingle('OptionGroup', ['name' => 'contribution_status']); } @@ -37,7 +37,7 @@ public function testEnsureOptionGroupExistsExistingValue() { /** * Ensure only one option value exists adds a new value. */ - public function testEnsureOptionGroupExistsNewValue() { + public function testEnsureOptionGroupExistsNewValue(): void { CRM_Core_BAO_OptionGroup::ensureOptionGroupExists(['name' => 'Bombed']); $optionGroups = $this->callAPISuccess('OptionValue', 'getoptions', ['context' => 'validate', 'field' => 'option_group_id'])['values']; $this->assertTrue(in_array('bombed', $optionGroups)); diff --git a/tests/phpunit/CRM/Core/BAO/PhoneTest.php b/tests/phpunit/CRM/Core/BAO/PhoneTest.php index bf1a3734e3ab..9b0d26302041 100644 --- a/tests/phpunit/CRM/Core/BAO/PhoneTest.php +++ b/tests/phpunit/CRM/Core/BAO/PhoneTest.php @@ -18,7 +18,7 @@ class CRM_Core_BAO_PhoneTest extends CiviUnitTestCase { /** * Add() method (create and update modes) */ - public function testAdd() { + public function testAdd(): void { $contactId = $this->individualCreate(); $params = [ @@ -59,7 +59,7 @@ public function testAdd() { /** * AllPhones() method - get all Phones for our contact, with primary Phone first. */ - public function testAllPhones() { + public function testAllPhones(): void { $contactParams = [ 'first_name' => 'Alan', 'last_name' => 'Smith', diff --git a/tests/phpunit/CRM/Core/BAO/PreferencesTest.php b/tests/phpunit/CRM/Core/BAO/PreferencesTest.php index 56ed1cf814f4..22cb1bad4207 100644 --- a/tests/phpunit/CRM/Core/BAO/PreferencesTest.php +++ b/tests/phpunit/CRM/Core/BAO/PreferencesTest.php @@ -15,7 +15,7 @@ */ class CRM_Core_BAO_PreferencesTest extends CiviUnitTestCase { - public function testValueOptions() { + public function testValueOptions(): void { $addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options' diff --git a/tests/phpunit/CRM/Core/BAO/PrevNextCacheTest.php b/tests/phpunit/CRM/Core/BAO/PrevNextCacheTest.php index 3c1e92fc8b63..895996580b0a 100644 --- a/tests/phpunit/CRM/Core/BAO/PrevNextCacheTest.php +++ b/tests/phpunit/CRM/Core/BAO/PrevNextCacheTest.php @@ -15,7 +15,7 @@ */ class CRM_Core_BAO_PrevNextCacheTest extends CiviUnitTestCase { - public function testFlipData() { + public function testFlipData(): void { $dao = new CRM_Core_BAO_PrevNextCache(); $dao->entity_id1 = 1; $dao->entity_id2 = 2; diff --git a/tests/phpunit/CRM/Core/BAO/RecurringEntityTest.php b/tests/phpunit/CRM/Core/BAO/RecurringEntityTest.php index a20b8cd6a4ba..4c0e73c06616 100644 --- a/tests/phpunit/CRM/Core/BAO/RecurringEntityTest.php +++ b/tests/phpunit/CRM/Core/BAO/RecurringEntityTest.php @@ -23,7 +23,7 @@ public function tearDown(): void { /** * Testing Activity Generation through Entity Recursion. */ - public function testActivityGeneration() { + public function testActivityGeneration(): void { //Activity set initial params $daoActivity = new CRM_Activity_DAO_Activity(); $daoActivity->activity_type_id = 1; @@ -144,7 +144,7 @@ public function testRepeatEventCreation(): void { /** * Testing Event Generation through Entity Recursion. */ - public function testEventGeneration() { + public function testEventGeneration(): void { //Event set initial params $daoEvent = new CRM_Event_DAO_Event(); $daoEvent->title = 'Test event for Recurring Entity'; @@ -294,7 +294,7 @@ public function testEventGeneration() { /** * Testing Activity Generation through Entity Recursion with Custom Data and Tags. */ - public function testRecurringEntityGenerationWithCustomDataAndTags() { + public function testRecurringEntityGenerationWithCustomDataAndTags(): void { // Create custom group and field $customGroup = $this->customGroupCreate([ @@ -373,7 +373,7 @@ public function testRecurringEntityGenerationWithCustomDataAndTags() { /** * Testing Activity Generation through Entity Recursion with minute units. */ - public function testRecurringEntityGenerationWithMinuteUnit() { + public function testRecurringEntityGenerationWithMinuteUnit(): void { // Create original activity $activityDateTime = '2021-11-11 15:00:00'; $activityId = $this->activityCreate([ diff --git a/tests/phpunit/CRM/Core/BAO/SettingTest.php b/tests/phpunit/CRM/Core/BAO/SettingTest.php index 3aecff724747..79ed20f4b812 100644 --- a/tests/phpunit/CRM/Core/BAO/SettingTest.php +++ b/tests/phpunit/CRM/Core/BAO/SettingTest.php @@ -44,7 +44,7 @@ public function tearDown(): void { /** * Test that enabling a valid component works. */ - public function testEnableComponentValid() { + public function testEnableComponentValid(): void { CRM_Core_Config::singleton(TRUE, TRUE); $result = CRM_Core_BAO_ConfigSetting::enableComponent('CiviCampaign'); $this->assertTrue($result); @@ -53,7 +53,7 @@ public function testEnableComponentValid() { /** * Test that we get a success result if we try to enable an enabled component. */ - public function testEnableComponentAlreadyPresent() { + public function testEnableComponentAlreadyPresent(): void { CRM_Core_Config::singleton(TRUE, TRUE); CRM_Core_BAO_ConfigSetting::enableComponent('CiviCampaign'); $result = CRM_Core_BAO_ConfigSetting::enableComponent('CiviCampaign'); @@ -63,7 +63,7 @@ public function testEnableComponentAlreadyPresent() { /** * Test that we get a false result if we try to enable an invalid component. */ - public function testEnableComponentInvalid() { + public function testEnableComponentInvalid(): void { CRM_Core_Config::singleton(TRUE, TRUE); $result = CRM_Core_BAO_ConfigSetting::enableComponent('CiviFake'); $this->assertFalse($result); @@ -82,7 +82,7 @@ public function testEnableComponentInvalid() { * * @throws \CRM_Core_Exception */ - public function testHandlingOfContributionInvoiceSetting() { + public function testHandlingOfContributionInvoiceSetting(): void { $contributionSettings = [ 'invoice_prefix' => 'G_', 'credit_notes_prefix' => 'XX_', @@ -117,7 +117,7 @@ public function testHandlingOfContributionInvoiceSetting() { * Ensure that overrides in $civicrm_setting apply when * using getItem($group,$name). */ - public function testGetItem_Override() { + public function testGetItem_Override(): void { global $civicrm_setting; $civicrm_setting[CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME]['imageUploadDir'] = '/test/override'; Civi::service('settings_manager')->useMandatory(); @@ -140,7 +140,7 @@ public function testGetItem_Override() { CRM_Core_DAO::executeQuery($query); } - public function testDefaults() { + public function testDefaults(): void { CRM_Core_DAO::executeQuery('DELETE FROM civicrm_setting WHERE name = "max_attachments"'); Civi::service('settings_manager')->flush(); $this->assertEquals(3, Civi::settings()->get('max_attachments')); @@ -154,7 +154,7 @@ public function testDefaults() { * are very similar, but they exercise different codepaths. The first uses the API * and setItems [plural]; the second uses setItem [singular]. */ - public function testOnChange() { + public function testOnChange(): void { global $_testOnChange_hookCalls; $this->setMockSettingsMetaData([ 'onChangeExample' => [ @@ -213,7 +213,7 @@ public static function _testOnChange_onChangeExample($oldValue, $newValue, $meta * Test to set isProductionEnvironment * */ - public function testSetCivicrmEnvironment() { + public function testSetCivicrmEnvironment(): void { Civi::settings()->set('environment', 'Staging'); $values = Civi::settings()->get('environment'); $this->assertEquals('Staging', $values); @@ -227,7 +227,7 @@ public function testSetCivicrmEnvironment() { /** * Test that options defined as a pseudoconstant can be converted to options. */ - public function testPseudoConstants() { + public function testPseudoConstants(): void { $this->contributionPageCreate(); $metadata = \Civi\Core\SettingsMetadata::getMetadata(['name' => ['default_invoice_page']], NULL, TRUE); $this->assertEquals('Test Contribution Page', $metadata['default_invoice_page']['options'][1]); diff --git a/tests/phpunit/CRM/Core/BAO/TagTest.php b/tests/phpunit/CRM/Core/BAO/TagTest.php index c3672c0d45e8..fa395dba0343 100644 --- a/tests/phpunit/CRM/Core/BAO/TagTest.php +++ b/tests/phpunit/CRM/Core/BAO/TagTest.php @@ -1,149 +1,149 @@ -quickCleanup(['civicrm_tag']); - - // Create an example hierarchy of tags. - // The family tree of Abraham is used as a well known example of a hierarchy (no statement intended). - // The order of ids is important because of: https://lab.civicrm.org/dev/core/-/issues/4049, that's why we create Isaac before Abraham. - CRM_Core_DAO::executeQuery("INSERT INTO civicrm_tag (id,name,used_for,is_tagset) VALUES(1, 'Isaac', 'civicrm_contact', 0);"); - CRM_Core_DAO::executeQuery("INSERT INTO civicrm_tag (id,name,used_for,is_tagset) VALUES(2, 'Abraham', 'civicrm_contact', 0);"); - CRM_Core_DAO::executeQuery("INSERT INTO civicrm_tag (id,name,used_for,is_tagset) VALUES(3, 'Jacob', 'civicrm_contact', 0);"); - CRM_Core_DAO::executeQuery("INSERT INTO civicrm_tag (id,name,used_for,is_tagset) VALUES(4, 'Ishmael', 'civicrm_contact', 1);"); - CRM_Core_DAO::executeQuery("INSERT INTO civicrm_tag (id,name,used_for,is_tagset) VALUES(5, 'Kedar', 'civicrm_contact', 1);"); - CRM_Core_DAO::executeQuery("INSERT INTO civicrm_tag (id,name,used_for,is_tagset) VALUES(6, 'Working', 'civicrm_activity', 1);"); - CRM_Core_DAO::executeQuery("INSERT INTO civicrm_tag (id,name,used_for,is_tagset) VALUES(7, 'Eating', 'civicrm_activity', 1);"); - - // Isaac is the son of abraham - CRM_Core_DAO::executeQuery("UPDATE civicrm_tag SET parent_id = 2 WHERE name = 'Isaac';"); - - // Jacob is the son of Isaac - CRM_Core_DAO::executeQuery("UPDATE civicrm_tag SET parent_id = 1 WHERE name = 'Jacob';"); - - // Ishmael is the son of abraham - CRM_Core_DAO::executeQuery("UPDATE civicrm_tag SET parent_id = 2 WHERE name = 'Ishmael';"); - - // Kedar is the son of Ishmael - CRM_Core_DAO::executeQuery("UPDATE civicrm_tag SET parent_id = 4 WHERE name = 'Kedar';"); - } - - /** - * Test that we can generate a correct tree of tags without suppliying additional filters. - * - * @throws \CRM_Core_Exception - */ - public function testGetTreeWithoutFilters() { - $bao = new CRM_Core_BAO_Tag(); - - $tree = $bao->getTree(); - - $expected = [ - 2 => [ - 'parent_id' => NULL, - 'name' => 'Abraham', - 'description' => NULL, - 'is_selectable' => '1', - 'children' => [ - 1 => [ - 'parent_id' => '2', - 'name' => 'Isaac', - 'description' => NULL, - 'is_selectable' => '1', - 'children' => [ - 3 => [ - 'parent_id' => '1', - 'name' => 'Jacob', - 'description' => NULL, - 'is_selectable' => '1', - 'children' => [], - ], - ], - ], - 4 => [ - 'parent_id' => '2', - 'name' => 'Ishmael', - 'is_selectable' => '1', - 'description' => NULL, - 'children' => [ - 5 => [ - 'parent_id' => '4', - 'name' => 'Kedar', - 'description' => NULL, - 'is_selectable' => '1', - 'children' => [], - ], - ], - ], - ], - ], - 7 => [ - 'parent_id' => NULL, - 'name' => 'Eating', - 'description' => NULL, - 'is_selectable' => '1', - 'children' => [], - ], - 6 => [ - 'parent_id' => NULL, - 'name' => 'Working', - 'description' => NULL, - 'is_selectable' => '1', - 'children' => [], - ], - ]; - - $this->assertEquals($expected, $tree); - } - - /** - * Test that we can generate a correct tree of tags when using a usedFor filter and we're excluding hidden tags. - * - * @throws \CRM_Core_Exception - */ - public function testGetTreeWithFilters() { - $bao = new CRM_Core_BAO_Tag(); - - $tree = $bao->getTree('civicrm_contact', TRUE); - - $expected = [ - 2 => [ - 'parent_id' => NULL, - 'name' => 'Abraham', - 'description' => NULL, - 'is_selectable' => '1', - 'children' => [ - 1 => [ - 'parent_id' => '2', - 'name' => 'Isaac', - 'description' => NULL, - 'is_selectable' => '1', - 'children' => [ - 3 => [ - 'parent_id' => '1', - 'name' => 'Jacob', - 'description' => NULL, - 'is_selectable' => '1', - 'children' => [], - ], - ], - ], - ], - ], - ]; - - $this->assertEquals($expected, $tree); - } - -} +quickCleanup(['civicrm_tag']); + + // Create an example hierarchy of tags. + // The family tree of Abraham is used as a well known example of a hierarchy (no statement intended). + // The order of ids is important because of: https://lab.civicrm.org/dev/core/-/issues/4049, that's why we create Isaac before Abraham. + CRM_Core_DAO::executeQuery("INSERT INTO civicrm_tag (id,name,used_for,is_tagset) VALUES(1, 'Isaac', 'civicrm_contact', 0);"); + CRM_Core_DAO::executeQuery("INSERT INTO civicrm_tag (id,name,used_for,is_tagset) VALUES(2, 'Abraham', 'civicrm_contact', 0);"); + CRM_Core_DAO::executeQuery("INSERT INTO civicrm_tag (id,name,used_for,is_tagset) VALUES(3, 'Jacob', 'civicrm_contact', 0);"); + CRM_Core_DAO::executeQuery("INSERT INTO civicrm_tag (id,name,used_for,is_tagset) VALUES(4, 'Ishmael', 'civicrm_contact', 1);"); + CRM_Core_DAO::executeQuery("INSERT INTO civicrm_tag (id,name,used_for,is_tagset) VALUES(5, 'Kedar', 'civicrm_contact', 1);"); + CRM_Core_DAO::executeQuery("INSERT INTO civicrm_tag (id,name,used_for,is_tagset) VALUES(6, 'Working', 'civicrm_activity', 1);"); + CRM_Core_DAO::executeQuery("INSERT INTO civicrm_tag (id,name,used_for,is_tagset) VALUES(7, 'Eating', 'civicrm_activity', 1);"); + + // Isaac is the son of abraham + CRM_Core_DAO::executeQuery("UPDATE civicrm_tag SET parent_id = 2 WHERE name = 'Isaac';"); + + // Jacob is the son of Isaac + CRM_Core_DAO::executeQuery("UPDATE civicrm_tag SET parent_id = 1 WHERE name = 'Jacob';"); + + // Ishmael is the son of abraham + CRM_Core_DAO::executeQuery("UPDATE civicrm_tag SET parent_id = 2 WHERE name = 'Ishmael';"); + + // Kedar is the son of Ishmael + CRM_Core_DAO::executeQuery("UPDATE civicrm_tag SET parent_id = 4 WHERE name = 'Kedar';"); + } + + /** + * Test that we can generate a correct tree of tags without suppliying additional filters. + * + * @throws \CRM_Core_Exception + */ + public function testGetTreeWithoutFilters(): void { + $bao = new CRM_Core_BAO_Tag(); + + $tree = $bao->getTree(); + + $expected = [ + 2 => [ + 'parent_id' => NULL, + 'name' => 'Abraham', + 'description' => NULL, + 'is_selectable' => '1', + 'children' => [ + 1 => [ + 'parent_id' => '2', + 'name' => 'Isaac', + 'description' => NULL, + 'is_selectable' => '1', + 'children' => [ + 3 => [ + 'parent_id' => '1', + 'name' => 'Jacob', + 'description' => NULL, + 'is_selectable' => '1', + 'children' => [], + ], + ], + ], + 4 => [ + 'parent_id' => '2', + 'name' => 'Ishmael', + 'is_selectable' => '1', + 'description' => NULL, + 'children' => [ + 5 => [ + 'parent_id' => '4', + 'name' => 'Kedar', + 'description' => NULL, + 'is_selectable' => '1', + 'children' => [], + ], + ], + ], + ], + ], + 7 => [ + 'parent_id' => NULL, + 'name' => 'Eating', + 'description' => NULL, + 'is_selectable' => '1', + 'children' => [], + ], + 6 => [ + 'parent_id' => NULL, + 'name' => 'Working', + 'description' => NULL, + 'is_selectable' => '1', + 'children' => [], + ], + ]; + + $this->assertEquals($expected, $tree); + } + + /** + * Test that we can generate a correct tree of tags when using a usedFor filter and we're excluding hidden tags. + * + * @throws \CRM_Core_Exception + */ + public function testGetTreeWithFilters(): void { + $bao = new CRM_Core_BAO_Tag(); + + $tree = $bao->getTree('civicrm_contact', TRUE); + + $expected = [ + 2 => [ + 'parent_id' => NULL, + 'name' => 'Abraham', + 'description' => NULL, + 'is_selectable' => '1', + 'children' => [ + 1 => [ + 'parent_id' => '2', + 'name' => 'Isaac', + 'description' => NULL, + 'is_selectable' => '1', + 'children' => [ + 3 => [ + 'parent_id' => '1', + 'name' => 'Jacob', + 'description' => NULL, + 'is_selectable' => '1', + 'children' => [], + ], + ], + ], + ], + ], + ]; + + $this->assertEquals($expected, $tree); + } + +} diff --git a/tests/phpunit/CRM/Core/BAO/UFMatchTest.php b/tests/phpunit/CRM/Core/BAO/UFMatchTest.php index e9916b8ebc15..c18da7fb46ea 100644 --- a/tests/phpunit/CRM/Core/BAO/UFMatchTest.php +++ b/tests/phpunit/CRM/Core/BAO/UFMatchTest.php @@ -9,7 +9,7 @@ class CRM_Core_BAO_UFMatchTest extends CiviUnitTestCase { /** * Don't crash if the uf_id doesn't exist */ - public function testGetUFValuesWithNonexistentUFId() { + public function testGetUFValuesWithNonexistentUFId(): void { $max_id = (int) CRM_Core_DAO::singleValueQuery('SELECT MAX(uf_id) FROM civicrm_uf_match'); $dontcrash = CRM_Core_BAO_UFMatch::getUFValues($max_id + 1); $this->assertNull($dontcrash); diff --git a/tests/phpunit/CRM/Core/CodeGen/FreshnessTest.php b/tests/phpunit/CRM/Core/CodeGen/FreshnessTest.php index 2cd67ff18823..dc269fc1d03d 100644 --- a/tests/phpunit/CRM/Core/CodeGen/FreshnessTest.php +++ b/tests/phpunit/CRM/Core/CodeGen/FreshnessTest.php @@ -9,7 +9,7 @@ */ class CRM_Core_CodeGen_FreshnessTest extends CiviUnitTestCase { - public function testDAOs() { + public function testDAOs(): void { $tasks = $this->findTasks('CRM_Core_CodeGen_DAO'); $names = []; foreach ($tasks as $task) { @@ -23,7 +23,7 @@ public function testDAOs() { 'Expect the list of tables to include civicrm_contact'); } - public function testReflection() { + public function testReflection(): void { $tasks = $this->findTasks('CRM_Core_CodeGen_Reflection'); $this->assertEquals(1, count($tasks), 'Expect to find one Reflection task'); foreach ($tasks as $task) { diff --git a/tests/phpunit/CRM/Core/CommunityMessagesTest.php b/tests/phpunit/CRM/Core/CommunityMessagesTest.php index 34104e7cb8ac..e396799602a3 100644 --- a/tests/phpunit/CRM/Core/CommunityMessagesTest.php +++ b/tests/phpunit/CRM/Core/CommunityMessagesTest.php @@ -151,7 +151,7 @@ public function badWebResponses() { return $result; } - public function testIsEnabled() { + public function testIsEnabled(): void { $communityMessages = new CRM_Core_CommunityMessages( $this->cache, $this->expectNoHttpRequest() @@ -159,7 +159,7 @@ public function testIsEnabled() { $this->assertTrue($communityMessages->isEnabled()); } - public function testIsEnabled_false() { + public function testIsEnabled_false(): void { $communityMessages = new CRM_Core_CommunityMessages( $this->cache, $this->expectNoHttpRequest(), @@ -171,7 +171,7 @@ public function testIsEnabled_false() { /** * Download a document; after the set expiration period, download again. */ - public function testGetDocument_NewOK_CacheOK_UpdateOK() { + public function testGetDocument_NewOK_CacheOK_UpdateOK(): void { // first try, good response CRM_Utils_Time::setTime('2013-03-01 10:00:00'); $communityMessages = new CRM_Core_CommunityMessages( @@ -306,7 +306,7 @@ public function testGetDocument_NewOK_UpdateFailure_CacheOK_UpdateOK($badWebResp /** * Randomly pick among two options. */ - public function testPick_rand() { + public function testPick_rand(): void { $communityMessages = new CRM_Core_CommunityMessages( $this->cache, $this->expectOneHttpRequest(self::$webResponses['two-messages']) @@ -334,7 +334,7 @@ public function testPick_rand() { * When presented with two options using component filters, always * choose the one which references an active component. */ - public function testPick_componentFilter() { + public function testPick_componentFilter(): void { $communityMessages = new CRM_Core_CommunityMessages( $this->cache, $this->expectOneHttpRequest(self::$webResponses['two-messages-halfbadcomp']) @@ -355,7 +355,7 @@ public function testPick_componentFilter() { $this->assertEquals($trials, $freq['