From be23f1220442ed6fa279e58ac744a0ffecdc91d6 Mon Sep 17 00:00:00 2001 From: Edsel Date: Tue, 9 Feb 2016 18:20:08 +0530 Subject: [PATCH] CRM-16526 CIVI-3 More work done on ft acl test ---------------------------------------- * CRM-16526: ACLs for Financial Types https://issues.civicrm.org/jira/browse/CRM-16526 --- tests/phpunit/api/v3/FinancialTypeACLTest.php | 64 ++++++++++++++++++- 1 file changed, 61 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/api/v3/FinancialTypeACLTest.php b/tests/phpunit/api/v3/FinancialTypeACLTest.php index 6a55b922d9..b98db64dc3 100644 --- a/tests/phpunit/api/v3/FinancialTypeACLTest.php +++ b/tests/phpunit/api/v3/FinancialTypeACLTest.php @@ -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); + } + } -- 2.25.1