From 823973c96c9091c511dc2585ced47710404dcfb1 Mon Sep 17 00:00:00 2001 From: Edsel Date: Fri, 26 Feb 2016 19:01:51 +0530 Subject: [PATCH] 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 --- .../CRM/Financial/BAO/FinancialTypeTest.php | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) 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'); + } } -- 2.25.1