CRM-16526 CIVI-3 More work done on ft acl test
authorEdsel <edsel.lopez@jmaconsulting.biz>
Tue, 9 Feb 2016 12:50:08 +0000 (18:20 +0530)
committerPradeep Nayak <pradpnayak@gmail.com>
Mon, 22 Feb 2016 18:11:38 +0000 (23:41 +0530)
----------------------------------------
* CRM-16526: ACLs for Financial Types
  https://issues.civicrm.org/jira/browse/CRM-16526

tests/phpunit/api/v3/FinancialTypeACLTest.php

index 6a55b922d999a6625490b9de87bbc273a8f1c33e..b98db64dc3d4a7d559015d31f362c31b68c894c2 100644 (file)
@@ -203,17 +203,14 @@ class api_v3_FinancialTypeACLTest extends CiviUnitTestCase {
     $config->userPermissionClass->permissions = array(
       'access CiviCRM',
       'access CiviContribute',
-      'view debug output'
     );
     $contribution = $this->callAPISuccess('contribution', 'get', $params);
-    // We should not get any contributions returned since we do not have permissions to view contributions of financial type Donation
     $this->assertEquals($contribution['count'], 0);
     
     $config->userPermissionClass->permissions = array(
       'access CiviCRM',
       'access CiviContribute',
       'view contributions of type Donation',
-      'view debug output'
     );
     $contribution = $this->callAPISuccess('contribution', 'get', $params);
    
@@ -317,4 +314,65 @@ class api_v3_FinancialTypeACLTest extends CiviUnitTestCase {
     ));
   }
 
+  /**
+   * Test that acl contributions can be edited.
+   */
+  public function testEditACLContribution() {
+    $this->setACL();
+    $contribution = $this->callAPISuccess('Contribution', 'create', $this->_params);
+
+    $params = array(
+      'id' => $contribution['id'],
+      'check_permissions' => TRUE,
+      'total_amount' => 200.00,
+    );
+    $config = &CRM_Core_Config::singleton();
+    $config->userPermissionClass->permissions = array(
+      'access CiviCRM',
+      'access CiviContribute',
+      'edit contributions',
+    );
+    $contribution = $this->callAPIFailure('Contribution', 'create', $params);
+    
+    $config->userPermissionClass->permissions = array(
+      'access CiviCRM',
+      'access CiviContribute',
+      'edit contributions',
+      'edit contributions of type Donation',
+    );
+    $contribution = $this->callAPISuccess('Contribution', 'create', $params);
+
+    $this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 200.00);
+  }
+
+  /**
+   * Test that acl contributions can be deleted.
+   */
+  public function testDeleteACLContribution() {
+    $this->setACL();
+    $contribution = $this->callAPISuccess('Contribution', 'create', $this->_params);
+
+    $params = array(
+      'contribution_id' => $contribution['id'],
+      'check_permissions' => TRUE,
+    );
+    $config = &CRM_Core_Config::singleton();
+    $config->userPermissionClass->permissions = array(
+      'access CiviCRM',
+      'access CiviContribute',
+      'delete in CiviContribute',
+    );
+    $contribution = $this->callAPIFailure('Contribution', 'delete', $params);
+    
+    $config->userPermissionClass->permissions = array(
+      'access CiviCRM',
+      'access CiviContribute',
+      'delete in CiviContribute',
+      'delete contributions of type Donation',
+    );
+    $contribution = $this->callAPISuccess('Contribution', 'delete', $params);
+   
+    $this->assertEquals($contribution['count'], 1);
+  }
+
 }