From d8bf43ffb9a9d0301465cb0d5daaf0ab960d895e Mon Sep 17 00:00:00 2001 From: Edsel Date: Tue, 9 Feb 2016 17:56:59 +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 | 44 ++++++------------- 1 file changed, 14 insertions(+), 30 deletions(-) diff --git a/tests/phpunit/api/v3/FinancialTypeACLTest.php b/tests/phpunit/api/v3/FinancialTypeACLTest.php index a5baf56cce..6a55b922d9 100644 --- a/tests/phpunit/api/v3/FinancialTypeACLTest.php +++ b/tests/phpunit/api/v3/FinancialTypeACLTest.php @@ -262,9 +262,12 @@ class api_v3_FinancialTypeACLTest extends CiviUnitTestCase { 'access CiviCRM', 'access CiviContribute', 'edit contributions', + 'delete in CiviContribute', 'add contributions of type Donation', + 'delete contributions of type Donation', ); $contribution = $this->callAPISuccess('contribution', 'create', $params); + CRM_Financial_BAO_FinancialType::$_availableFinancialTypes = NULL; $lineItemParams = array( 'contribution_id' => $contribution['id'], @@ -283,13 +286,16 @@ class api_v3_FinancialTypeACLTest extends CiviUnitTestCase { $this->callAPISuccess('Contribution', 'Delete', array( 'id' => $contribution['id'], )); - + $config = &CRM_Core_Config::singleton(); $config->userPermissionClass->permissions = array( 'access CiviCRM', 'access CiviContribute', 'edit contributions', - 'add contributions of type Donation', + 'delete in CiviContribute', 'add contributions of type Member Dues', + 'add contributions of type Donation', + 'delete contributions of type Donation', + 'delete contributions of type Member Dues', ); $contribution = $this->callAPIAndDocument('contribution', 'create', $params, __FUNCTION__, __FILE__, $description, $subfile); @@ -299,35 +305,13 @@ class api_v3_FinancialTypeACLTest extends CiviUnitTestCase { ); $lineItems = $this->callAPISuccess('LineItem', 'get', $lineItemParams); $this->assertEquals(3, $lineItems['count']); - $this->assertEquals(100.00, $lineItems['values'][1]['line_total']); - $this->assertEquals(20, $lineItems['values'][2]['line_total']); - $this->assertEquals(80, $lineItems['values'][3]['line_total']); - $this->assertEquals(1, $lineItems['values'][1]['financial_type_id']); - $this->assertEquals(1, $lineItems['values'][2]['financial_type_id']); - $this->assertEquals(2, $lineItems['values'][3]['financial_type_id']); - - $params = array( - 'contribution_id' => $contribution['id'], - ); - $contribution = $this->callAPISuccess('contribution', 'get', $params); + $this->assertEquals(100.00, $lineItems['values'][3]['line_total']); + $this->assertEquals(20, $lineItems['values'][4]['line_total']); + $this->assertEquals(80, $lineItems['values'][5]['line_total']); + $this->assertEquals(1, $lineItems['values'][3]['financial_type_id']); + $this->assertEquals(1, $lineItems['values'][4]['financial_type_id']); + $this->assertEquals(2, $lineItems['values'][5]['financial_type_id']); - $this->assertEquals(1, $contribution['count']); - $this->assertEquals($contribution['values'][$contribution['id']]['contact_id'], $this->_individualId); - $this->assertEquals($contribution['values'][$contribution['id']]['financial_type_id'], 1); - $this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 100.00); - $this->assertEquals($contribution['values'][$contribution['id']]['non_deductible_amount'], 10.00); - $this->assertEquals($contribution['values'][$contribution['id']]['fee_amount'], 50.00); - $this->assertEquals($contribution['values'][$contribution['id']]['net_amount'], 90.00); - $this->assertEquals($contribution['values'][$contribution['id']]['contribution_source'], 'SSF'); - $this->assertEquals($contribution['values'][$contribution['id']]['contribution_status'], 'Completed'); - - $lineItems = $this->callAPISuccess('line_item', 'get', array( - 'entity_id' => $contribution['id'], - 'contribution_id' => $contribution['id'], - 'entity_table' => 'civicrm_contribution', - 'sequential' => 1, - )); - $this->assertEquals(3, $lineItems['count']); $this->callAPISuccess('Contribution', 'Delete', array( 'id' => $contribution['id'], )); -- 2.25.1