+--------------------------------------------------------------------+
*/
+namespace Civi\Test;
+
/**
- * Trait ACL_Permission_Trait.
+ * Trait Civi\Test\ACLPermissionTrait.
*
* Trait for working with ACLs in tests
*/
-trait CRMTraits_ACL_PermissionTrait {
+trait ACLPermissionTrait {
/**
* ContactID of allowed Contact
$permittedRoleID = ($groupAllowedAccess === 'Everyone') ? 0 : $groupAllowedAccess;
if ($permittedRoleID !== 0) {
- throw new CRM_Core_Exception('only handling everyone group as yet');
+ throw new \CRM_Core_Exception('only handling everyone group as yet');
}
foreach ($permissionedEntities as $permissionedEntityID) {
$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->scenarioIDs['Contact']['non_permitted_contact'] = $this->individualCreate();
- CRM_Core_Config::singleton()->userPermissionClass->permissions = [];
+ \CRM_Core_Config::singleton()->userPermissionClass->permissions = [];
$this->setupCoreACLPermittedAcl([$this->scenarioIDs['Group']['permitted_group']]);
}
$this->quickCleanup(['civicrm_acl_cache', 'civicrm_acl_contact_cache']);
$this->scenarioIDs['Event']['permitted_event'] = $this->eventCreate()['id'];
$this->scenarioIDs['Contact']['permitted_contact'] = $this->individualCreate();
- CRM_Core_Config::singleton()->userPermissionClass->permissions = ['view event info'];
+ \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.
*/
protected function cleanupCachedPermissions() {
- if (isset(Civi::$statics['CRM_Contact_BAO_Contact_Permission'])) {
- unset(Civi::$statics['CRM_Contact_BAO_Contact_Permission']);
+ if (isset(\Civi::$statics['CRM_Contact_BAO_Contact_Permission'])) {
+ unset(\Civi::$statics['CRM_Contact_BAO_Contact_Permission']);
}
- CRM_Core_DAO::executeQuery('TRUNCATE civicrm_acl_contact_cache');
+ \CRM_Core_DAO::executeQuery('TRUNCATE civicrm_acl_contact_cache');
}
}
use Civi\Test\HeadlessInterface;
use Civi\Test\TransactionalInterface;
-// FIXME: This shouldn't be needed but the core classLoader doesn't seem present when this file loads
-require_once 'tests/phpunit/CRMTraits/ACL/PermissionTrait.php';
-
/**
* @group headless
*/
class SearchRunTest extends \PHPUnit\Framework\TestCase implements HeadlessInterface, TransactionalInterface {
- use \CRMTraits_ACL_PermissionTrait;
+ use \Civi\Test\ACLPermissionTrait;
public function setUpHeadless() {
// Civi\Test has many helpers, like install(), uninstall(), sql(), and sqlFile().