From: Edsel Date: Fri, 26 Feb 2016 13:31:51 +0000 (+0530) Subject: CRM-16526 CIVI-3 Added unit test for permissioned financial types X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=823973c96c9091c511dc2585ced47710404dcfb1;p=civicrm-core.git CRM-16526 CIVI-3 Added unit test for permissioned financial types ---------------------------------------- * CRM-16526: ACLs for Financial Types https://issues.civicrm.org/jira/browse/CRM-16526 --- diff --git a/tests/phpunit/CRM/Financial/BAO/FinancialTypeTest.php b/tests/phpunit/CRM/Financial/BAO/FinancialTypeTest.php index 39f8bb35f8..50ba9d1007 100644 --- a/tests/phpunit/CRM/Financial/BAO/FinancialTypeTest.php +++ b/tests/phpunit/CRM/Financial/BAO/FinancialTypeTest.php @@ -198,5 +198,28 @@ class CRM_Financial_BAO_FinancialTypeTest extends CiviUnitTestCase { CRM_Financial_BAO_FinancialType::getAvailableMembershipTypes($types); $this->assertEquals($expectedResult, $types, 'Verify that removing permission for a financial type restricts the available membership types'); } + + public function testpermissionedFinancialTypes() { + // First get all core permissions + $permissions = $checkPerms = CRM_Core_Permission::getCorePermissions(); + $this->setACL(); + CRM_Financial_BAO_FinancialType::permissionedFinancialTypes($permissions, TRUE); + $financialTypes = CRM_Contribute_PseudoConstant::financialType(); + $prefix = ts('CiviCRM') . ': '; + $actions = array('add', 'view', 'edit', 'delete'); + foreach ($financialTypes as $id => $type) { + foreach ($actions as $action) { + $checkPerms[$action . ' contributions of type ' . $type] = array( + $prefix . ts($action . ' contributions of type ') . $type, + ts(ucfirst($action) . ' contributions of type ') . $type, + ); + } + } + $checkPerms['administer CiviCRM Financial Types'] = array( + $prefix . ts('administer CiviCRM Financial Types'), + ts('Administer access to Financial Types'), + ); + $this->assertEquals($permissions, $checkPerms, 'Verify that permissions for each financial type have been added'); + } }