Skip to content

Commit

Permalink
Merge pull request #9923 from eileenmcnaughton/acl
Browse files Browse the repository at this point in the history
CRM-19773 unit test to verify acls apply
  • Loading branch information
eileenmcnaughton authored Mar 3, 2017
2 parents 6b15c95 + 33072bc commit 290b764
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 14 deletions.
14 changes: 14 additions & 0 deletions tests/phpunit/CiviTest/CiviUnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3770,4 +3770,18 @@ public function createPriceSetWithPage($entity = NULL, $params = array()) {
$this->_ids['membership_type'] = $membershipTypeID;
}

/**
* No results returned.
*
* @implements CRM_Utils_Hook::aclWhereClause
*
* @param string $type
* @param array $tables
* @param array $whereTables
* @param int $contactID
* @param string $where
*/
public function aclWhereHookNoResults($type, &$tables, &$whereTables, &$contactID, &$where) {
}

}
14 changes: 0 additions & 14 deletions tests/phpunit/api/v3/ACLPermissionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -427,20 +427,6 @@ public function setUpEntities($entity) {
);
}

/**
* No results returned.
*
* @implements CRM_Utils_Hook::aclWhereClause
*
* @param string $type
* @param array $tables
* @param array $whereTables
* @param int $contactID
* @param string $where
*/
public function aclWhereHookNoResults($type, &$tables, &$whereTables, &$contactID, &$where) {
}

/**
* All results returned.
*
Expand Down
24 changes: 24 additions & 0 deletions tests/phpunit/api/v3/ReportTemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,30 @@ public function testLybuntReportWithData() {
$this->assertEquals(1, $rows['count'], "Report failed - the sql used to generate the results was " . print_r($rows['metadata']['sql'], TRUE));
}

/**
* Test Lybunt report applies ACLs.
*/
public function testLybuntReportWithDataAndACLFilter() {
CRM_Core_Config::singleton()->userPermissionClass->permissions = array('administer CiviCRM');
$inInd = $this->individualCreate();
$outInd = $this->individualCreate();
$this->contributionCreate(array('contact_id' => $inInd, 'receive_date' => '2014-03-01'));
$this->contributionCreate(array('contact_id' => $outInd, 'receive_date' => '2015-03-01', 'trxn_id' => NULL, 'invoice_id' => NULL));
$this->hookClass->setHook('civicrm_aclWhereClause', array($this, 'aclWhereHookNoResults'));
$params = array(
'report_id' => 'contribute/lybunt',
'yid_value' => 2015,
'yid_op' => 'calendar',
'options' => array('metadata' => array('sql')),
'check_permissions' => 1,
);

$rows = $this->callAPISuccess('report_template', 'getrows', $params);
$this->assertEquals(0, $rows['count'], "Report failed - the sql used to generate the results was " . print_r($rows['metadata']['sql'], TRUE));

CRM_Utils_Hook::singleton()->reset();
}

/**
* Test Lybunt report to check basic inclusion of a contact who gave in the year before the chosen year.
*/
Expand Down

0 comments on commit 290b764

Please sign in to comment.