Skip to content

Commit

Permalink
Test - Add return type hints to test functions
Browse files Browse the repository at this point in the history
  • Loading branch information
colemanw committed Aug 28, 2023
1 parent 44fa0ef commit 9df1541
Show file tree
Hide file tree
Showing 406 changed files with 2,073 additions and 2,071 deletions.
10 changes: 5 additions & 5 deletions tests/phpunit/CRM/ACL/ListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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);

Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/CRM/Activity/BAO/ActivityAssignmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);

Expand All @@ -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');
Expand Down
38 changes: 19 additions & 19 deletions tests/phpunit/CRM/Activity/BAO/ActivityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function tearDown(): void {
*
* @throws \CRM_Core_Exception
*/
public function testCreate() {
public function testCreate(): void {
$contactId = $this->individualCreate();

$params = [
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -550,7 +550,7 @@ public function testActivityFilters() {
/**
* Test getActivities BAO method for getting count
*/
public function testGetActivitiesCountforContactSummaryWithNoActivities() {
public function testGetActivitiesCountforContactSummaryWithNoActivities(): void {
$this->createTestActivities();

$params = [
Expand All @@ -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();
Expand Down Expand Up @@ -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) {
Expand All @@ -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']);
Expand All @@ -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();
Expand Down Expand Up @@ -685,7 +685,7 @@ public function testGetActivitiesforNonAdminDashboard() {
/**
* Test target contact count.
*/
public function testTargetCountforContactSummary() {
public function testTargetCountforContactSummary(): void {
$targetCount = 5;
$contactId = $this->individualCreate();
$targetContactIDs = [];
Expand Down Expand Up @@ -714,7 +714,7 @@ public function testTargetCountforContactSummary() {
/**
* Test getActivities BAO method.
*/
public function testGetActivitiesforContactSummaryWithSortOptions() {
public function testGetActivitiesforContactSummaryWithSortOptions(): void {
$this->createTestActivities();
$params = [
'contact_id' => 9,
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Activity/BAO/ActivityTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
10 changes: 5 additions & 5 deletions tests/phpunit/CRM/Activity/Form/ActivityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', []);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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', [
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Activity/Form/SearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Activity/Form/Task/PDFTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
8 changes: 4 additions & 4 deletions tests/phpunit/CRM/Activity/Page/AJAXTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Bridge/OG/DrupalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Campaign/BAO/CampaignTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', [
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Campaign/BAO/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Loading

0 comments on commit 9df1541

Please sign in to comment.