}
/**
- * Check method add()
+ * Check method add().
*/
public function testAdd() {
$params = array(
}
/**
- * Check method retrive()
+ * Check method retrieve().
*/
public function testRetrieve() {
$params = array(
}
/**
- * Check method testgetAvailableFinancialTypes()
+ * Check method testGetAvailableFinancialTypes()
*/
- public function testgetAvailableFinancialTypes() {
+ public function testGetAvailableFinancialTypes() {
$this->setACL();
- $config = &CRM_Core_Config::singleton();
- $config->userPermissionClass->permissions = array(
+ $this->setPermissions(array(
'view contributions of type Donation',
'view contributions of type Member Dues',
- );
+ ));
+
CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($types);
$expectedResult = array(
1 => "Donation",
2 => "Member Dues",
);
$this->assertEquals($expectedResult, $types, 'Verify that only certain financial types can be retrieved');
- CRM_Financial_BAO_FinancialType::$_availableFinancialTypes = NULL;
- $config->userPermissionClass->permissions = array(
+
+ $this->setPermissions(array(
'view contributions of type Donation',
- );
+ ));
unset($expectedResult[2]);
CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($types);
$this->assertEquals($expectedResult, $types, 'Verify that removing permission for a financial type restricts the available financial types');
$membershipType = CRM_Member_BAO_MembershipType::add($params, $ids);
$this->setACL();
- $config = &CRM_Core_Config::singleton();
- $config->userPermissionClass->permissions = array(
+
+ $this->setPermissions(array(
'view contributions of type Donation',
'view contributions of type Member Dues',
- );
+ ));
CRM_Financial_BAO_FinancialType::getAvailableMembershipTypes($types);
$expectedResult = array(
1 => "Type One",
2 => "Type Two",
);
$this->assertEquals($expectedResult, $types, 'Verify that only certain membership types can be retrieved');
- $config->userPermissionClass->permissions = array(
+ $this->setPermissions(array(
'view contributions of type Donation',
- );
+ ));
unset($expectedResult[2]);
CRM_Financial_BAO_FinancialType::getAvailableMembershipTypes($types);
$this->assertEquals($expectedResult, $types, 'Verify that removing permission for a financial type restricts the available membership types');
}
/**
- * Check method testpermissionedFinancialTypes()
+ * Check method testPermissionedFinancialTypes()
*/
- public function testpermissionedFinancialTypes() {
+ public function testPermissionedFinancialTypes() {
// First get all core permissions
$permissions = $checkPerms = CRM_Core_Permission::getCorePermissions();
$this->setACL();
$contributions = CRM_Contribute_BAO_Contribution::create($contributionParams);
CRM_Financial_BAO_FinancialType::$_statusACLFt = array();
$this->setACL();
- $config = &CRM_Core_Config::singleton();
- $config->userPermissionClass->permissions = array(
+
+ $this->setPermissions(array(
'view contributions of type Member Dues',
- );
+ ));
try {
- $error = CRM_Financial_BAO_FinancialType::checkPermissionedLineItems($contributions->id, 'view');
+ CRM_Financial_BAO_FinancialType::checkPermissionedLineItems($contributions->id, 'view');
$this->fail("Missed expected exception");
}
catch (Exception $e) {
$this->assertEquals("A fatal error was triggered: You do not have permission to access this page.", $e->getMessage());
}
- $config = &CRM_Core_Config::singleton();
- $config->userPermissionClass->permissions = array(
+
+ $this->setPermissions(array(
'view contributions of type Donation',
- );
+ ));
$perm = CRM_Financial_BAO_FinancialType::checkPermissionedLineItems($contributions->id, 'view');
$this->assertEquals($perm, TRUE, 'Verify that lineitems now have permission.');
}
/**
* Check method testisACLFinancialTypeStatus()
*/
- public function testbuildPermissionedClause() {
+ public function testBuildPermissionedClause() {
$this->setACL();
- $config = &CRM_Core_Config::singleton();
- $config->userPermissionClass->permissions = array(
+ $this->setPermissions(array(
'view contributions of type Donation',
'view contributions of type Member Dues',
- );
+ ));
CRM_Financial_BAO_FinancialType::buildPermissionedClause($whereClause, 'contribution');
$this->assertEquals($whereClause, ' civicrm_contribution.financial_type_id IN (1,2)');
- $config->userPermissionClass->permissions[] = 'view contributions of type Event Fee';
+ $this->setPermissions(array(
+ 'view contributions of type Donation',
+ 'view contributions of type Member Dues',
+ 'view contributions of type Event Fee',
+ ));
$whereClause = NULL;
- CRM_Financial_BAO_FinancialType::$_availableFinancialTypes = array();
+
CRM_Financial_BAO_FinancialType::buildPermissionedClause($whereClause, 'contribution');
$this->assertEquals($whereClause, ' civicrm_contribution.financial_type_id IN (1,4,2)');
}