public function setUp() {
parent::setUp();
- $baoObj = new CRM_Core_DAO();
- $baoObj->createTestObject('CRM_Pledge_BAO_Pledge', [], 1, 0);
- $baoObj->createTestObject('CRM_Core_BAO_Phone', [], 1, 0);
+ CRM_Core_DAO::createTestObject('CRM_Pledge_BAO_Pledge', [], 1, 0);
+ CRM_Core_DAO::createTestObject('CRM_Core_BAO_Phone', [], 1, 0);
$this->prepareForACLs();
}
/**
* Function tests that an empty where hook returns no results.
+ *
* @param int $version
+ *
* @dataProvider versionThreeAndFour
+ * @throws \CRM_Core_Exception
*/
public function testContactGetNoResultsHook($version) {
$this->_apiversion = $version;
* Function tests that an empty where hook returns exactly 1 result with "view my contact".
*
* CRM-16512 caused contacts with Edit my contact to be able to view all records.
+ *
* @param int $version
+ *
* @dataProvider versionThreeAndFour
+ * @throws \CRM_Core_Exception
*/
public function testContactGetOneResultHookWithViewMyContact($version) {
$this->_apiversion = $version;
/**
* Function tests that a user with "edit my contact" can edit themselves.
+ *
* @param int $version
+ *
* @dataProvider versionThreeAndFour
+ * @throws \CRM_Core_Exception
*/
public function testContactEditHookWithEditMyContact($version) {
$this->_apiversion = $version;
/**
* Ensure contact permissions do not block contact-less location entities.
+ *
* @param int $version
+ *
* @dataProvider versionThreeAndFour
+ * @throws \CRM_Core_Exception
*/
public function testAddressWithoutContactIDAccess($version) {
$this->_apiversion = $version;
/**
* Ensure contact permissions extend to related entities like email
+ *
* @param int $version
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
* @dataProvider versionThreeAndFour
* FIXME: Finish api4 part
*/
/**
* Function tests all results are returned.
+ *
* @param int $version
+ *
* @dataProvider versionThreeAndFour
+ * @throws \CRM_Core_Exception
*/
public function testContactGetAllResultsHook($version) {
$this->_apiversion = $version;
/**
* Function tests that deleted contacts are not returned.
+ *
* @param int $version
+ *
* @dataProvider versionThreeAndFour
+ * @throws \CRM_Core_Exception
*/
public function testContactGetPermissionHookNoDeleted($version) {
$this->_apiversion = $version;
/**
* Test permissions limited by hook.
+ *
* @param int $version
+ *
* @dataProvider versionThreeAndFour
+ * @throws \CRM_Core_Exception
*/
public function testContactGetHookLimitingHook($version) {
$this->_apiversion = $version;
/**
* Confirm that without check permissions we still get 2 contacts returned.
+ *
* @param int $version
+ *
* @dataProvider versionThreeAndFour
+ * @throws \CRM_Core_Exception
*/
public function testContactGetHookLimitingHookDontCheck($version) {
$this->_apiversion = $version;
/**
* Check that chaining doesn't bypass permissions
+ *
* @param int $version
+ *
* @dataProvider versionThreeAndFour
+ * @throws \CRM_Core_Exception
*/
public function testContactGetPledgeNotChainable($version) {
$this->_apiversion = $version;
/**
* @dataProvider entities
* confirm that without check permissions we still get 2 contacts returned
- * @param $entity
+ *
+ * @param string $entity
+ *
+ * @throws \CRM_Core_Exception
*/
public function testEntitiesGetHookLimitingHookNoCheck($entity) {
CRM_Core_Config::singleton()->userPermissionClass->permissions = [];
/**
* @dataProvider entities
* confirm that with check permissions we don't get entities
+ *
* @param $entity
+ *
* @throws \PHPUnit\Framework\IncompleteTestError
+ * @throws \CRM_Core_Exception
*/
public function testEntitiesGetCoreACLLimitingCheck($entity) {
$this->setupCoreACL();
/**
* @dataProvider entities
* Function tests that an empty where hook returns no results
+ *
* @param string $entity
+ *
* @throws \PHPUnit\Framework\IncompleteTestError
+ * @throws \CRM_Core_Exception
*/
public function testEntityGetNoResultsHook($entity) {
$this->markTestIncomplete('hook acls only work with contacts so far');
}
/**
- * Create 2 entities
- * @param $entity
+ * Create 2 entities.
+ *
+ * @param string $entity
*/
public function setUpEntities($entity) {
- $baoObj = new CRM_Core_DAO();
- $baoObj->createTestObject(_civicrm_api3_get_BAO($entity), [], 2, 0);
+ CRM_Core_DAO::createTestObject(_civicrm_api3_get_BAO($entity), [], 2, 0);
CRM_Core_Config::singleton()->userPermissionClass->permissions = [
'access CiviCRM',
'access CiviContribute',
}
/**
- * Basic check that an unpermissioned call keeps working and permissioned call fails.
+ * Basic check that an un-permissioned call keeps working and permissioned call fails.
+ *
* @param int $version
+ *
* @dataProvider versionThreeAndFour
+ * @throws \CRM_Core_Exception
*/
public function testGetActivityNoPermissions($version) {
$this->_apiversion = $version;
$this->setPermissions([]);
- $this->callAPISuccess('Activity', 'get', []);
+ $this->callAPISuccess('Activity', 'get');
$this->callAPIFailure('Activity', 'get', ['check_permissions' => 1]);
}
/**
* View all activities is enough regardless of contact ACLs.
+ *
* @param int $version
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
* @dataProvider versionThreeAndFour
*/
public function testGetActivityViewAllActivitiesDoesntCutItAnymore($version) {
/**
* View all activities is required unless id is passed in.
+ *
* @param int $version
+ *
* @dataProvider versionThreeAndFour
+ * @throws \CRM_Core_Exception
*/
public function testGetActivityViewAllContactsEnoughWithoutID($version) {
$this->_apiversion = $version;
/**
* Without view all activities contact level acls are used.
+ *
* @param int $version
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
* @dataProvider versionThreeAndFour
*/
public function testGetActivityViewAllContactsEnoughWIthID($version) {
/**
* Check the error message is not a permission error.
+ *
* @param int $version
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
* @dataProvider versionThreeAndFour
*/
public function testGetActivityAccessCiviCRMEnough($version) {
*
* (logically the same component limit should apply when they have access to view all too but....
* adding test for 'how it is at the moment.)
+ *
* @param int $version
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
* @dataProvider versionThreeAndFour
*/
public function testGetActivityCheckPermissionsByComponent($version) {
/**
* Check that component related activity filtering works for CiviCase.
+ *
* @param int $version
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
* @dataProvider versionThreeAndFour
*/
public function testGetActivityCheckPermissionsByCaseComponent($version) {
*
* The activities api applies ACLs in a very limited circumstance, if id is passed in.
* Otherwise it sticks with the blunt original permissions.
+ *
* @param int $version
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
* @dataProvider versionThreeAndFour
*/
public function testGetActivityByACL($version) {
}
else {
$this->assertEquals([$contact_id], (array) $result[$roleKey]);
- $this->assertTrue(!empty($result[$roleName . '_name']));
+ $this->assertNotEmpty($result[$roleName . '_name']);
}
}
}
/**
* To leverage ACL permission to view an activity you must be able to see any of the contacts.
+ *
* @param int $version
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
* @dataProvider versionThreeAndFour
*/
public function testGetActivityByAclCannotViewAnyContacts($version) {
*
* CRM-18409.
*
- * @throws \CRM_Core_Exception
* @param int $version
+ *
* @dataProvider versionThreeAndFour
+ * @throws \CiviCRM_API3_Exception
+ * @throws \CRM_Core_Exception
*/
public function testGetActivityACLSourceContactDeleted($version) {
$this->_apiversion = $version;
/**
* Test get activities multiple ids with check permissions
+ *
* @see https://issues.civicrm.org/jira/browse/CRM-20441
+ *
* @param int $version
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
* @dataProvider versionThreeAndFour
*/
public function testActivitiesGetMultipleIdsCheckPermissions($version) {
/**
* Test get activities multiple ids with check permissions
* Limit access to One contact
+ *
* @see https://issues.civicrm.org/jira/browse/CRM-20441
+ *
* @param int $version
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
* @dataProvider versionThreeAndFour
*/
public function testActivitiesGetMultipleIdsCheckPermissionsLimitedACL($version) {
/**
* Test get activities multiple ids with check permissions
+ *
* @see https://issues.civicrm.org/jira/browse/CRM-20441
+ *
* @param int $version
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
* @dataProvider versionThreeAndFour
*/
public function testActivitiesGetMultipleIdsCheckPermissionsNotIN($version) {
/**
* @param int $version
+ *
* @dataProvider versionThreeAndFour
+ * @throws \CRM_Core_Exception
*/
public function testContactGetViaJoin($version) {
$this->_apiversion = $version;
$tag2 = $this->tagCreate(['name' => uniqid('other'), 'created_id' => $other])['id'];
$this->setPermissions(['access CiviCRM']);
$this->hookClass->setHook('civicrm_aclWhereClause', [$this, 'aclWhereHookAllResults']);
- $createdFirstName = $version == 4 ? 'created.first_name' : 'created_id.first_name';
+ $createdFirstName = $version === 4 ? 'created.first_name' : 'created_id.first_name';
$result = $this->callAPISuccess('Tag', 'get', [
'check_permissions' => 1,
'return' => ['id', $createdFirstName],