CRM-16526 Added more unit tests for financial acl
authorEdsel <edsel.lopez@jmaconsulting.biz>
Mon, 29 Feb 2016 14:12:49 +0000 (19:42 +0530)
committerEdsel <edsel.lopez@jmaconsulting.biz>
Tue, 1 Mar 2016 06:49:12 +0000 (12:19 +0530)
----------------------------------------
* CRM-16526: ACLs for Financial Types
  https://issues.civicrm.org/jira/browse/CRM-16526

tests/phpunit/CRM/Financial/BAO/FinancialTypeTest.php

index 7ae71ae9ae854ceeb61c6d61aa1dce952e70f48c..7d70849310a5bef62838aad40736c8ab1dcf41ac 100644 (file)
@@ -317,4 +317,24 @@ class CRM_Financial_BAO_FinancialTypeTest extends CiviUnitTestCase {
     $this->assertEquals($isACL, array('acl_financial_type' => 1));
   }
 
+  /**
+   * Check method testisACLFinancialTypeStatus()
+   */
+  public function testbuildPermissionedClause() {
+    $this->setACL();
+    $config = &CRM_Core_Config::singleton();
+    $config->userPermissionClass->permissions = 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';
+    $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)');
+    
+  }
+
 }