* Trait for working with ACLs in tests
*/
trait ACLPermissionTrait {
+ use EventTestTrait;
/**
* ContactID of allowed Contact
* @param array $tables
* @param array $whereTables
* @param int $contactID
- * @param string $where
+ * @param string|null $where
+ *
+ * @noinspection PhpUnusedParameterInspection
*/
- public function aclWhereHookAllResults($type, &$tables, &$whereTables, &$contactID, &$where) {
- $where = " (1) ";
+ public function aclWhereHookAllResults(string $type, array &$tables, array &$whereTables, int &$contactID, ?string &$where): void {
+ $where = ' (1) ';
}
/**
* @param array $tables
* @param array $whereTables
* @param int $contactID
- * @param string $where
+ * @param string|null $where
*/
- public function aclWhereHookNoResults($type, &$tables, &$whereTables, &$contactID, &$where) {
+ public function aclWhereHookNoResults(string $type, array &$tables, array &$whereTables, int &$contactID, ?string &$where): void {
}
/**
* @param array $tables
* @param array $whereTables
* @param int $contactID
- * @param string $where
+ * @param string|null $where
+ *
+ * @noinspection PhpUnusedParameterInspection
*/
- public function aclWhereOnlySecond($type, &$tables, &$whereTables, &$contactID, &$where) {
- $where = " contact_a.id > 1";
+ public function aclWhereOnlySecond(string $type, array &$tables, array &$whereTables, int &$contactID, ?string &$where): void {
+ $where = ' contact_a.id > 1';
}
/**
* @param array $tables
* @param array $whereTables
* @param int $contactID
- * @param string $where
+ * @param string|null $where
+ *
+ * @noinspection PhpUnusedParameterInspection
*/
- public function aclWhereOnlyOne($type, &$tables, &$whereTables, &$contactID, &$where) {
- $where = " contact_a.id = " . $this->allowedContactId;
+ public function aclWhereOnlyOne(string $type, array &$tables, array &$whereTables, int &$contactID, ?string &$where): void {
+ $where = ' contact_a.id = ' . $this->allowedContactId;
}
/**
* @param array $tables
* @param array $whereTables
* @param int $contactID
- * @param string $where
+ * @param string|null $where
+ *
+ * @noinspection PhpUnusedParameterInspection
*/
- public function aclWhereGreaterThan($type, &$tables, &$whereTables, &$contactID, &$where) {
- $where = " contact_a.id > " . $this->allowedContactId;
+ public function aclWhereGreaterThan(string $type, array &$tables, array &$whereTables, int &$contactID, ?string &$where): void {
+ $where = ' contact_a.id > ' . $this->allowedContactId;
}
/**
* An ID of 0 means that 'Everyone' can access the group.
* @param string $operation View|Edit|Create|Delete|Search|All
* @param string $entity Group|CustomGroup|Profile|Event
- *
- * @throws CRM_Core_Exception
*/
- public function setupCoreACLPermittedAcl($permissionedEntities = [], $groupAllowedAccess = 'Everyone', $operation = 'View', $entity = 'Group') {
+ public function setupCoreACLPermittedAcl(array $permissionedEntities = [], $groupAllowedAccess = 'Everyone', string $operation = 'View', string $entity = 'Group'): void {
$tableMap = ['Group' => 'civicrm_group', 'CustomGroup' => 'civicrm_custom_group', 'Profile' => 'civicrm_uf_group', 'Event' => 'civicrm_event'];
$entityTable = $tableMap[$entity];
$permittedRoleID = ($groupAllowedAccess === 'Everyone') ? 0 : $groupAllowedAccess;
if ($permittedRoleID !== 0) {
- throw new \CRM_Core_Exception('only handling everyone group as yet');
+ $this->fail('only handling everyone group as yet');
}
foreach ($permissionedEntities as $permissionedEntityID) {
- $this->callAPISuccess('Acl', 'create', [
- 'name' => uniqid(),
+ $this->createTestEntity('ACL', [
+ 'name' => 'test acl' . $permissionedEntityID,
'operation' => $operation,
'entity_id' => $permittedRoleID,
'object_id' => $permissionedEntityID,
* $this->scenarioIDs['Contact'] = ['permitted_contact' => x, 'non_permitted_contact' => y]
* $this->scenarioIDs['Group'] = ['permitted_group' => x]
*/
- public function setupScenarioCoreACLEveryonePermittedToGroup() {
+ public function setupScenarioCoreACLEveryonePermittedToGroup(): void {
$this->quickCleanup(['civicrm_acl_cache', 'civicrm_acl_contact_cache']);
$this->scenarioIDs['Group']['permitted_group'] = $this->groupCreate();
$this->scenarioIDs['Contact']['permitted_contact'] = $this->individualCreate();
- $result = $this->callAPISuccess('GroupContact', 'create', ['group_id' => $this->scenarioIDs['Group']['permitted_group'], 'contact_id' => $this->scenarioIDs['Contact']['permitted_contact'], 'status' => 'Added']);
+ $this->callAPISuccess('GroupContact', 'create', ['group_id' => $this->scenarioIDs['Group']['permitted_group'], 'contact_id' => $this->scenarioIDs['Contact']['permitted_contact'], 'status' => 'Added']);
$this->scenarioIDs['Contact']['non_permitted_contact'] = $this->individualCreate();
\CRM_Core_Config::singleton()->userPermissionClass->permissions = [];
$this->setupCoreACLPermittedAcl([$this->scenarioIDs['Group']['permitted_group']]);
/**
* Set up a scenario where everyone can access the permissioned group.
*
- * A scenario in this class involves multiple defined assets. In this case we create
+ * A scenario in this class involves multiple defined assets. In this case we
+ * create
* - a group to which the everyone has permission
* - a contact in the group
* - a contact not in the group
*
* These are arrayed as follows
- * $this->scenarioIDs['Contact'] = ['permitted_contact' => x, 'non_permitted_contact' => y]
+ * $this->scenarioIDs['Contact'] = ['permitted_contact' => x,
+ * 'non_permitted_contact' => y]
* $this->scenarioIDs['Group'] = ['permitted_group' => x]
*/
- public function setupScenarioCoreACLEveryonePermittedToEvent() {
+ public function setupScenarioCoreACLEveryonePermittedToEvent(): void {
$this->quickCleanup(['civicrm_acl_cache', 'civicrm_acl_contact_cache']);
- $this->scenarioIDs['Event']['permitted_event'] = $this->eventCreate()['id'];
+ $this->scenarioIDs['Event']['permitted_event'] = $this->eventCreateUnpaid()['id'];
$this->scenarioIDs['Contact']['permitted_contact'] = $this->individualCreate();
\CRM_Core_Config::singleton()->userPermissionClass->permissions = ['view event info'];
$this->setupCoreACLPermittedAcl([$this->scenarioIDs['Event']['permitted_event']], 'Everyone', 'View', 'Event');
/**
* Clean up places where permissions get cached.
+ *
+ * @noinspection PhpUnhandledExceptionInspection
*/
- protected function cleanupCachedPermissions() {
+ protected function cleanupCachedPermissions(): void {
if (isset(\Civi::$statics['CRM_Contact_BAO_Contact_Permission'])) {
unset(\Civi::$statics['CRM_Contact_BAO_Contact_Permission']);
}
+--------------------------------------------------------------------+
*/
+use Civi\Test\ACLPermissionTrait;
+
/**
* Class CRM_Event_BAO_EventPermissionsTest
* @group headless
*/
class CRM_Event_BAO_EventPermissionsTest extends CiviUnitTestCase {
- use Civi\Test\ACLPermissionTrait;
-
- /**
- * @var int
- */
- private $contactID;
-
- /**
- * @var int
- */
- private $ownEventID;
-
- /**
- * @var int
- */
- private $otherEventID;
+ use ACLPermissionTrait;
public function setUp(): void {
parent::setUp();
- $this->contactID = $this->createLoggedInUser();
+ $this->createLoggedInUser();
$this->createOwnEvent();
$this->createOtherEvent();
}
+ public function tearDown(): void {
+ $this->quickCleanUpFinancialEntities();
+ parent::tearDown();
+ }
+
public function createOwnEvent(): void {
$event = $this->eventCreateUnpaid([
- 'created_id' => $this->contactID,
- ]);
- $this->ownEventID = $event['id'];
+ 'created_id' => $this->ids['Contact']['logged_in'],
+ ], 'own');
+ $this->ids['Event']['own'] = $event['id'];
}
public function createOtherEvent(): void {
- $otherContactID = $this->contactID + 1;
$event = $this->eventCreateUnpaid([
- 'created_id' => $otherContactID,
+ 'created_id' => $this->individualCreate([], 'other'),
], 'other');
- $this->otherEventID = $event['id'];
+ $this->ids['Event']['other'] = $event['id'];
}
private function setViewOwnEventPermissions(): void {
*/
public function testViewOwnEvent(): void {
$this->setViewOwnEventPermissions();
- $this->assertTrue(CRM_Event_BAO_Event::checkPermission($this->ownEventID, CRM_Core_Permission::VIEW));
- // Now check that caching is actually working
- \Civi::$statics['CRM_Event_BAO_Event']['permission']['view'][$this->ownEventID] = FALSE;
- $permissions = CRM_Event_BAO_Event::checkPermission($this->ownEventID, CRM_Core_Permission::VIEW);
+ $this->assertTrue(CRM_Event_BAO_Event::checkPermission($this->ids['Event']['own'], CRM_Core_Permission::VIEW));
+ // Now check that caching is actually working.
+ \Civi::$statics['CRM_Event_BAO_Event']['permission']['view'][$this->ids['Event']['own']] = FALSE;
+ $permissions = CRM_Event_BAO_Event::checkPermission($this->ids['Event']['own'], CRM_Core_Permission::VIEW);
$this->assertFalse($permissions);
}
*/
public function testEditOwnEvent(): void {
$this->setViewOwnEventPermissions();
- $permissions = CRM_Event_BAO_Event::checkPermission($this->ownEventID, CRM_Core_Permission::EDIT);
+ $permissions = CRM_Event_BAO_Event::checkPermission($this->ids['Event']['own'], CRM_Core_Permission::EDIT);
$this->assertTrue($permissions);
}
public function testDeleteOwnEvent(): void {
// Check that you can't delete your own event without "Delete in CiviEvent" permission
$this->setViewOwnEventPermissions();
- $this->assertFalse(CRM_Event_BAO_Event::checkPermission($this->ownEventID, CRM_Core_Permission::DELETE));
+ $this->assertFalse(CRM_Event_BAO_Event::checkPermission($this->ids['Event']['own'], CRM_Core_Permission::DELETE));
}
/**
*/
public function testViewOtherEventDenied(): void {
$this->setViewOwnEventPermissions();
- $this->assertFalse(CRM_Event_BAO_Event::checkPermission($this->otherEventID, CRM_Core_Permission::VIEW));
+ $this->assertFalse(CRM_Event_BAO_Event::checkPermission($this->ids['Event']['other'], CRM_Core_Permission::VIEW));
}
/**
*/
public function testViewOtherEventAllowed(): void {
$this->setViewAllEventPermissions();
- $this->assertTrue(CRM_Event_BAO_Event::checkPermission($this->otherEventID, CRM_Core_Permission::VIEW));
+ $this->assertTrue(CRM_Event_BAO_Event::checkPermission($this->ids['Event']['other'], CRM_Core_Permission::VIEW));
}
/**
*/
public function testEditOtherEventDenied(): void {
$this->setViewAllEventPermissions();
- $this->assertFalse(CRM_Event_BAO_Event::checkPermission($this->otherEventID, CRM_Core_Permission::EDIT));
+ $this->assertFalse(CRM_Event_BAO_Event::checkPermission($this->ids['Event']['other'], CRM_Core_Permission::EDIT));
}
/**
*/
public function testEditOtherEventAllowed(): void {
$this->setEditAllEventPermissions();
- $this->assertTrue(CRM_Event_BAO_Event::checkPermission($this->otherEventID, CRM_Core_Permission::EDIT));
+ $this->assertTrue(CRM_Event_BAO_Event::checkPermission($this->ids['Event']['other'], CRM_Core_Permission::EDIT));
}
/**
*/
public function testDeleteOtherEventAllowed(): void {
$this->setDeleteAllEventPermissions();
- $this->assertTrue(CRM_Event_BAO_Event::checkPermission($this->otherEventID, CRM_Core_Permission::DELETE));
+ $this->assertTrue(CRM_Event_BAO_Event::checkPermission($this->ids['Event']['other'], CRM_Core_Permission::DELETE));
}
/**
*/
public function testDeleteOtherEventDenied(): void {
$this->setEditAllEventPermissions();
- $this->assertFalse(CRM_Event_BAO_Event::checkPermission($this->otherEventID, CRM_Core_Permission::DELETE));
+ $this->assertFalse(CRM_Event_BAO_Event::checkPermission($this->ids['Event']['other'], CRM_Core_Permission::DELETE));
}
/**
}
/**
- * @param \CRM_Core_DAO $entity
+ * @param string $entity
* @param array $clauses
*/
- public function hookSelectWhere($entity, &$clauses) {
+ public function hookSelectWhere(string $entity, array &$clauses): void {
// Restrict access to cases by type
if ($entity === 'Contact') {
$clauses['contact_type'][] = " = 'Organization' ";
/**
* Test getrows on contact summary report.
- *
- * @throws \CRM_Core_Exception
*/
- public function testReportTemplateGetRowsContactSummary() {
+ public function testReportTemplateGetRowsContactSummary(): void {
$result = $this->callAPISuccess('report_template', 'getrows', [
'report_id' => 'contact/summary',
'options' => ['metadata' => ['labels', 'title']],
/**
* Test getrows on Mailing Opened report.
*/
- public function testReportTemplateGetRowsMailingUniqueOpened() {
+ public function testReportTemplateGetRowsMailingUniqueOpened(): void {
$description = 'Retrieve rows from a mailing opened report template.';
$this->loadXMLDataSet(__DIR__ . '/../../CRM/Mailing/BAO/queryDataset.xml');
*
* @dataProvider getReportTemplates
*
- * @param $reportID
- *
- * @throws \CRM_Core_Exception
+ * @param string $reportID
*/
- public function testReportTemplateGetRowsAllReports($reportID) {
+ public function testReportTemplateGetRowsAllReports(string $reportID): void {
//$reportID = 'logging/contact/summary';
if (stripos($reportID, 'has existing issues') !== FALSE) {
$this->markTestIncomplete($reportID);
* Test logging report when a custom data table has a table removed by hook.
*
* Here we are checking that no fatal is triggered.
- *
- * @throws \CRM_Core_Exception
*/
- public function testLoggingReportWithHookRemovalOfCustomDataTable() {
+ public function testLoggingReportWithHookRemovalOfCustomDataTable(): void {
Civi::settings()->set('logging', 1);
$group1 = $this->customGroupCreate();
$group2 = $this->customGroupCreate(['name' => 'second_one', 'title' => 'second one', 'table_name' => 'civicrm_value_second_one']);
'report_id' => 'logging/contact/summary',
]);
Civi::settings()->set('logging', 0);
- $this->customGroupDelete($group1['id']);
- $this->customGroupDelete($group2['id']);
}
/**
*
* @param array $logTableSpec
*/
- public function alterLogTablesRemoveCustom(&$logTableSpec) {
+ public function alterLogTablesRemoveCustom(array &$logTableSpec): void {
unset($logTableSpec['civicrm_value_second_one']);
}
* @dataProvider getReportTemplates
*
* @param $reportID
- *
- * @throws \PHPUnit\Framework\IncompleteTestError
- * @throws \CRM_Core_Exception
*/
- public function testReportTemplateGetRowsAllReportsACL($reportID) {
+ public function testReportTemplateGetRowsAllReportsACL($reportID): void {
if (stripos($reportID, 'has existing issues') !== FALSE) {
$this->markTestIncomplete($reportID);
}
*
* @dataProvider getReportTemplates
*
- * @param $reportID
+ * @param string $reportID
*
- * @throws \PHPUnit\Framework\IncompleteTestError
*/
- public function testReportTemplateGetStatisticsAllReports($reportID) {
+ public function testReportTemplateGetStatisticsAllReports(string $reportID): void {
if (stripos($reportID, 'has existing issues') !== FALSE) {
$this->markTestIncomplete($reportID);
}
if (in_array($reportID, ['contribute/softcredit', 'contribute/bookkeeping'])) {
- $this->markTestIncomplete($reportID . ' has non enotices when calling statistics fn');
+ $this->markTestIncomplete($reportID . ' has non e-notices when calling statistics fn');
}
if (strpos($reportID, 'logging') === 0) {
Civi::settings()->set('logging', 1);
/**
* Implements hook_civicrm_alterReportVar().
+ *
+ * @noinspection PhpParameterByRefIsNotUsedAsReferenceInspection
*/
- public function alterReportVarHook($varType, &$var, &$object) {
+ public function alterReportVarHook($varType, &$var, &$object): void {
if ($varType === 'sql' && $object instanceof CRM_Report_Form_Contribute_Summary) {
$from = $var->getVar('_from');
$from .= ' LEFT JOIN civicrm_financial_type as temp ON temp.id = contribution_civireport.financial_type_id';
*
* These templates require minimal data config.
*/
- public static function getContributionReportTemplates() {
+ public static function getContributionReportTemplates(): array {
return [['contribute/summary'], ['contribute/detail'], ['contribute/repeat'], ['topDonor' => 'contribute/topDonor']];
}
* Get contribution templates that work with basic filter tests.
*
* These templates require minimal data config.
+ *
+ * @return array
*/
- public static function getMembershipReportTemplates() {
+ public static function getMembershipReportTemplates(): array {
return [['member/detail']];
}
*
* @return array
*/
- public static function getMembershipAndContributionReportTemplatesForGroupTests() {
+ public static function getMembershipAndContributionReportTemplatesForGroupTests(): array {
$templates = array_merge(self::getContributionReportTemplates(), self::getMembershipReportTemplates());
foreach ($templates as $key => $value) {
if (array_key_exists('topDonor', $value)) {
/**
* Test Lybunt report to check basic inclusion of a contact who gave in the year before the chosen year.
- *
- * @throws \CRM_Core_Exception
*/
- public function testLybuntReportWithData() {
+ public function testLybuntReportWithData(): void {
$inInd = $this->individualCreate();
$outInd = $this->individualCreate();
$this->contributionCreate(['contact_id' => $inInd, 'receive_date' => '2014-03-01']);
/**
* Test Lybunt report applies ACLs.
- *
- * @throws \CRM_Core_Exception
*/
- public function testLybuntReportWithDataAndACLFilter() {
+ public function testLybuntReportWithDataAndACLFilter(): void {
CRM_Core_Config::singleton()->userPermissionClass->permissions = ['administer CiviCRM'];
$inInd = $this->individualCreate();
$outInd = $this->individualCreate();
/**
* Test Lybunt report to check basic inclusion of a contact who gave in the year before the chosen year.
- *
- * @throws \CRM_Core_Exception
*/
- public function testLybuntReportWithFYData() {
+ public function testLybuntReportWithFYData(): void {
$inInd = $this->individualCreate();
$outInd = $this->individualCreate();
$this->contributionCreate(['contact_id' => $inInd, 'receive_date' => '2014-10-01']);
AND ( contribution_civireport.contribution_status_id IN (1) )
GROUP BY contact_civireport.id');
// Exclude whitespace in comparison as we don't care if it changes & this allows us to make the above readable.
- $whitespacelessSql = preg_replace('/\s+/', ' ', $rows['metadata']['sql'][0]);
- $this->assertStringContainsString($expected, $whitespacelessSql);
+ $whitespaceFreeSql = preg_replace('/\s+/', ' ', $rows['metadata']['sql'][0]);
+ $this->assertStringContainsString($expected, $whitespaceFreeSql);
}
/**
* Test Lybunt report to check basic inclusion of a contact who gave in the year before the chosen year.
- *
- * @throws \CRM_Core_Exception
*/
- public function testLybuntReportWithFYDataOrderByLastYearAmount() {
+ public function testLybuntReportWithFYDataOrderByLastYearAmount(): void {
$inInd = $this->individualCreate();
$outInd = $this->individualCreate();
$this->contributionCreate(['contact_id' => $inInd, 'receive_date' => '2014-10-01']);
*
* @throws \CRM_Core_Exception
*/
- public function testContributionSummaryWithNotINSmartGroupFilter($template): void {
+ public function testContributionSummaryWithNotINSmartGroupFilter(string $template): void {
$groupID = $this->setUpPopulatedSmartGroup();
$rows = $this->callAPISuccess('report_template', 'getrows', [
'report_id' => 'contribute/summary',
*
* @param string $template
* Report template unique identifier.
- *
- * @throws \CRM_Core_Exception
*/
- public function testReportsWithNonSmartGroupFilterWithACL($template): void {
+ public function testReportsWithNonSmartGroupFilterWithACL(string $template): void {
$this->aclGroupID = $this->setUpPopulatedGroup();
$this->createLoggedInUser();
CRM_Core_Config::singleton()->userPermissionClass->permissions = ['access CiviCRM'];
* Rows returned from the report.
* @param string $template
*/
- protected function assertNumberOfContactsInResult($numberExpected, $rows, $template) {
+ protected function assertNumberOfContactsInResult(int $numberExpected, array $rows, string $template): void {
if (isset($rows['values'][0]['civicrm_contribution_total_amount_count'])) {
$this->assertEquals($numberExpected, $rows['values'][0]['civicrm_contribution_total_amount_count'], 'wrong row count in ' . $template);
}
/**
* Test we don't get a fatal grouping with QUARTER frequency.
- *
- * @throws \CRM_Core_Exception
*/
- public function testContributionSummaryGroupByYearQuarterFrequency() {
+ public function testContributionSummaryGroupByYearQuarterFrequency(): void {
$params = [
'report_id' => 'contribute/summary',
'fields' => ['total_amount' => 1, 'country_id' => 1],
/**
* Test we don't get a fatal grouping with QUARTER frequency.
- *
- * @throws \CRM_Core_Exception
*/
- public function testContributionSummaryGroupByDateFrequency() {
+ public function testContributionSummaryGroupByDateFrequency(): void {
$params = [
'report_id' => 'contribute/summary',
'fields' => ['total_amount' => 1, 'country_id' => 1],
/**
* Test we don't get a fatal grouping with QUARTER frequency.
- *
- * @throws \CRM_Core_Exception
*/
- public function testContributionSummaryGroupByWeekFrequency() {
+ public function testContributionSummaryGroupByWeekFrequency(): void {
$params = [
'report_id' => 'contribute/summary',
'fields' => ['total_amount' => 1, 'country_id' => 1],
/**
* CRM-20640: Test the group filter works on the contribution summary when a single contact in 2 groups.
- *
- * @throws \CRM_Core_Exception
*/
public function testContributionSummaryWithSingleContactsInTwoGroups(): void {
$groupID1 = $this->setUpPopulatedGroup();
*
* @return int
*/
- public function setUpPopulatedGroup() {
+ public function setUpPopulatedGroup(): int {
$individual1ID = $this->individualCreate();
$individualID = $this->ids['Contact']['primary'] = $this->individualCreate();
$individualIDRemoved = $this->individualCreate();
/**
* Test Deferred Revenue Report.
- *
- * @throws \CRM_Core_Exception
*/
public function testDeferredRevenueReport(): void {
- $indv1 = $this->individualCreate();
- $indv2 = $this->individualCreate();
+ $this->individualCreate([], 'first');
+ $this->individualCreate([], 'second');
Civi::settings()->set('deferred_revenue_enabled', TRUE);
$this->contributionCreate(
[
- 'contact_id' => $indv1,
+ 'contact_id' => $this->ids['Contact']['first'],
'receive_date' => '2016-10-01',
'revenue_recognition_date' => date('Y-m-t', strtotime(date('ymd') . '+3 month')),
'financial_type_id' => 2,
);
$this->contributionCreate(
[
- 'contact_id' => $indv1,
+ 'contact_id' => $this->ids['Contact']['first'],
'revenue_recognition_date' => date('Y-m-t', strtotime(date('ymd') . '+22 month')),
'financial_type_id' => 4,
'trxn_id' => NULL,
);
$this->contributionCreate(
[
- 'contact_id' => $indv2,
+ 'contact_id' => $this->ids['Contact']['second'],
'revenue_recognition_date' => date('Y-m-t', strtotime(date('ymd') . '+1 month')),
'financial_type_id' => 4,
'trxn_id' => NULL,
);
$this->contributionCreate(
[
- 'contact_id' => $indv2,
+ 'contact_id' => $this->ids['Contact']['second'],
'receive_date' => '2016-03-01',
'revenue_recognition_date' => date('Y-m-t', strtotime(date('ymd') . '+4 month')),
'financial_type_id' => 2,
/**
* Test we don't get a fatal grouping with various frequencies.
- *
- * @throws \CRM_Core_Exception
*/
- public function testActivitySummaryGroupByFrequency() {
+ public function testActivitySummaryGroupByFrequency(): void {
$this->createContactsWithActivities();
foreach (['MONTH', 'YEARWEEK', 'QUARTER', 'YEAR'] as $frequency) {
$params = [
/**
* Test activity details report - requiring all current fields to be output.
- *
- * @throws \CRM_Core_Exception
*/
- public function testActivityDetails() {
+ public function testActivityDetails(): void {
$this->createContactsWithActivities();
$fields = [
'contact_source' => '1',
/**
* Activity Details report has some whack-a-mole to fix when filtering on null/not null.
- *
- * @throws \CRM_Core_Exception
*/
- public function testActivityDetailsNullFilters() {
+ public function testActivityDetailsNullFilters(): void {
$this->createContactsWithActivities();
$params = [
'report_id' => 'activity',
*
* @throws \CRM_Core_Exception
*/
- public function testActivityDetailsContactFilter() {
+ public function testActivityDetailsContactFilter(): void {
$this->createContactsWithActivities();
$params = [
'report_id' => 'activity',
/**
* Set up some activity data..... use some chars that challenge our utf handling.
- *
- * @throws \CRM_Core_Exception
*/
- public function createContactsWithActivities() {
+ public function createContactsWithActivities(): void {
$this->contactIDs[] = $this->individualCreate(['last_name' => 'Brzęczysław', 'email' => 'techo@spying.com']);
$this->contactIDs[] = $this->individualCreate(['last_name' => 'Łąchowski-Roberts']);
$this->contactIDs[] = $this->individualCreate(['last_name' => 'Łąchowski-Roberts']);
/**
* Test the group filter works on the contribution summary.
- *
- * @throws \CRM_Core_Exception
*/
- public function testContributionDetailTotalHeader() {
+ public function testContributionDetailTotalHeader(): void {
$contactID = $this->individualCreate();
$contactID2 = $this->individualCreate();
$this->contributionCreate(['contact_id' => $contactID, 'api.ContributionSoft.create' => ['amount' => 5, 'contact_id' => $contactID2]]);
/**
* Test contact subtype filter on summary report.
- *
- * @throws \CRM_Core_Exception
*/
- public function testContactSubtypeNotNull() {
+ public function testContactSubtypeNotNull(): void {
$this->individualCreate(['contact_sub_type' => ['Student', 'Parent']]);
$this->individualCreate();
/**
* Test contact subtype filter on summary report.
- *
- * @throws \CRM_Core_Exception
*/
- public function testContactSubtypeNull() {
+ public function testContactSubtypeNull(): void {
$this->individualCreate(['contact_sub_type' => ['Student', 'Parent']]);
$this->individualCreate();
/**
* Test contact subtype filter on summary report.
- *
- * @throws \CRM_Core_Exception
*/
- public function testContactSubtypeIn() {
+ public function testContactSubtypeIn(): void {
$this->individualCreate(['contact_sub_type' => ['Student', 'Parent']]);
$this->individualCreate();
/**
* Test contact subtype filter on summary report.
- *
- * @throws \CRM_Core_Exception
*/
- public function testContactSubtypeNotIn() {
+ public function testContactSubtypeNotIn(): void {
$this->individualCreate(['contact_sub_type' => ['Student', 'Parent']]);
$this->individualCreate();
/**
* Test a report that uses getAddressColumns();
- *
- * @throws \CRM_Core_Exception
*/
- public function testGetAddressColumns() {
+ public function testGetAddressColumns(): void {
$template = 'event/participantlisting';
$this->callAPISuccess('report_template', 'getrows', [
'report_id' => $template,
* Test that the contribution aggregate by relationship report filters
* by financial type.
*/
- public function testContributionAggregateByRelationship() {
+ public function testContributionAggregateByRelationship(): void {
$contact = $this->individualCreate();
// Two contributions with different financial types.
// We don't really care which types, just different.
/**
* Basic test of the repeat contributions report.
*/
- public function testRepeatContributions() {
+ public function testRepeatContributions(): void {
// our sorting options are limited in this report - default is last name so let's ensure order
- $contact1 = $this->individualCreate(['last_name' => 'aaaaa']);
- $contact2 = $this->individualCreate(['last_name' => 'zzzzz']);
+ $contact1 = $this->individualCreate(['last_name' => 'Aardvark']);
+ $contact2 = $this->individualCreate(['last_name' => 'Zebra']);
$this->contributionCreate(['contact_id' => $contact1, 'receive_date' => (date('Y') - 1) . '-07-01', 'financial_type_id' => 1, 'total_amount' => '10']);
$this->contributionCreate(['contact_id' => $contact1, 'receive_date' => (date('Y') - 1) . '-08-01', 'financial_type_id' => 1, 'total_amount' => '20']);
$this->contributionCreate(['contact_id' => $contact1, 'receive_date' => date('Y') . '-01-01', 'financial_type_id' => 1, 'total_amount' => '40']);
* In practice, besides some setup and trigger-wrangling, the report isn't
* useful for activities, so we're checking activity_contact records, and
* because of how an activity update works that's actually a delete+insert.
+ *
+ * @throws \CRM_Core_Exception
*/
- public function testLoggingDetail() {
+ public function testLoggingDetail(): void {
\Civi::settings()->set('logging', 1);
$this->createContactsWithActivities();
$this->doQuestionableStuffInASeparateFunctionSoNobodyNotices();
*
* On the plus side, this doesn't affect other tests since if they enable
* logging then that'll just recreate the variable and triggers.
+ *
+ * @throws \Civi\Core\Exception\DBQueryException
*/
private function doQuestionableStuffInASeparateFunctionSoNobodyNotices(): void {
CRM_Core_DAO::executeQuery("DELETE FROM civicrm_setting WHERE name='logging_uniqueid_date'");
/**
* Implement hook to restrict to test group 1.
*
+ * @implements hook_aclGroups
+ *
* @param string $type
* @param int $contactID
* @param string $tableName
* @param array $allGroups
* @param array $ids
+ *
+ * @noinspection PhpUnusedParameterInspection
*/
- public function aclGroupOnly($type, $contactID, $tableName, $allGroups, &$ids) {
+ public function aclGroupOnly(string $type, int $contactID, string $tableName, array $allGroups, array &$ids): void {
if ($tableName === 'civicrm_group') {
$ids = [$this->aclGroupID];
}
* @param array $tables
* @param array $whereTables
* @param int|null $contactID
- * @param string $where
+ * @param string|null $where
+ *
+ * @noinspection PhpUnusedParameterInspection
*/
- public function aclGroupContactsOnly(string $type, array &$tables, array &$whereTables, &$contactID, &$where) {
+ public function aclGroupContactsOnly(string $type, array &$tables, array &$whereTables, ?int &$contactID, ?string &$where): void {
if (!empty($where)) {
$where .= ' AND ';
}