This got separated out over a few recent commits (the first one seems to have somewhat
accidentally included the trait & then some others added using it. Am just pushing in this tidy up
private $tx = NULL;
/**
- * @var CRM_Utils_Hook_UnitTests hookClass
- * example of setting a method for a hook
+ * Class used for hooks during tests.
+ *
+ * This can be used to test hooks within tests. For example in the ACL_PermissionTrait:
+ *
* $this->hookClass->setHook('civicrm_aclWhereClause', array($this, 'aclWhereHookAllResults'));
+ *
+ * @var CRM_Utils_Hook_UnitTests hookClass
*/
public $hookClass = NULL;
$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) {
- }
-
/**
* Only specified contact returned.
* @implements CRM_Utils_Hook::aclWhereClause
* @group headless
*/
class api_v3_ACLPermissionTest extends CiviUnitTestCase {
+
+ use CRMTraits_ACL_PermissionTrait;
+
protected $_apiversion = 3;
public $DBResetRequired = FALSE;
protected $_entity;
- protected $allowedContactId = 0;
- protected $allowedContacts = array();
public function setUp() {
parent::setUp();
);
}
- /**
- * All results returned.
- *
- * @implements CRM_Utils_Hook::aclWhereClause
- *
- * @param string $type
- * @param array $tables
- * @param array $whereTables
- * @param int $contactID
- * @param string $where
- */
- public function aclWhereHookAllResults($type, &$tables, &$whereTables, &$contactID, &$where) {
- $where = " (1) ";
- }
-
- /**
- * All but first results returned.
- * @implements CRM_Utils_Hook::aclWhereClause
- * @param $type
- * @param $tables
- * @param $whereTables
- * @param $contactID
- * @param $where
- */
- public function aclWhereOnlySecond($type, &$tables, &$whereTables, &$contactID, &$where) {
- $where = " contact_a.id > 1";
- }
-
- /**
- * Only specified contact returned.
- * @implements CRM_Utils_Hook::aclWhereClause
- * @param $type
- * @param $tables
- * @param $whereTables
- * @param $contactID
- * @param $where
- */
- public function aclWhereOnlyOne($type, &$tables, &$whereTables, &$contactID, &$where) {
- $where = " contact_a.id = " . $this->allowedContactId;
- }
-
/**
* Basic check that an unpermissioned call keeps working and permissioned call fails.
*/
*/
class api_v3_EntityTagACLTest extends CiviUnitTestCase {
+ use CRMTraits_ACL_PermissionTrait;
+
/**
* API Version in use.
*
), ($entity == 'Contacts' ? 1 : 0));
}
- /**
- * All results returned.
- *
- * @implements CRM_Utils_Hook::aclWhereClause
- *
- * @param string $type
- * @param array $tables
- * @param array $whereTables
- * @param int $contactID
- * @param string $where
- */
- public function aclWhereHookAllResults($type, &$tables, &$whereTables, &$contactID, &$where) {
- $where = " (1) ";
- }
-
}
* @group headless
*/
class api_v3_ReportTemplateTest extends CiviUnitTestCase {
+
+ use CRMTraits_ACL_PermissionTrait;
+
protected $_apiversion = 3;
protected $contactIDs = [];