/** * @param $permission * @param $hook */ public function setHookAndRequest($permission, $hook) { CRM_Core_Config::singleton()->userPermissionClass->permissions = (array) $permission; $this->hookClass->setHook('civicrm_aclGroup', array($this, $hook)); CRM_Contact_BAO_Group::getPermissionClause(TRUE); global $_REQUEST; $_REQUEST = $this->_params; }
/** * @dataProvider entities * Function tests that an empty where hook returns no results */ function testEntityGetNoResultsHook($entity) { $this->markTestIncomplete('hook acls only work with contacts so far'); CRM_Core_Config::singleton()->userPermissionClass->permissions = array(); $this->setUpEntities($entity); $this->hookClass->setHook('civicrm_aclWhereClause', array($this, 'aclWhereHookNoResults')); $result = $this->callAPISuccess($entity, 'get', array('check_permission' => 1)); $this->assertEquals(0, $result['count']); }
public function setUp() { parent::setUp(); CRM_Utils_Hook_UnitTests::singleton()->setHook('civicrm_post', array($this, 'onPost')); }
public function testCallDisableExpiredRelationships() { $individualID = $this->individualCreate(); $orgID = $this->organizationCreate(); CRM_Utils_Hook_UnitTests::singleton()->setHook('civicrm_pre', array($this, 'hookPreRelationship')); $relationshipTypeID = $this->callAPISuccess('relationship_type', 'getvalue', array('return' => 'id', 'name_a_b' => 'Employee of')); $result = $this->callAPISuccess('relationship', 'create', array('relationship_type_id' => $relationshipTypeID, 'contact_id_a' => $individualID, 'contact_id_b' => $orgID, 'is_active' => 1, 'end_date' => 'yesterday')); $relationshipID = $result['id']; $this->assertEquals('Hooked', $result['values'][$relationshipID]['description']); $this->callAPISuccess($this->_entity, 'disable_expired_relationships', array()); $result = $this->callAPISuccess('relationship', 'get', array()); $this->assertEquals('Go Go you good thing', $result['values'][$relationshipID]['description']); $this->contactDelete($individualID); $this->contactDelete($orgID); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { parent::setUp(); $this->useTransaction(TRUE); CRM_Utils_Hook_UnitTests::singleton()->setHook('civicrm_apiWrappers', array($this, 'onApiWrappers')); }