From 8484a5f047369f960bca50f37dcc6716a18a94d2 Mon Sep 17 00:00:00 2001 From: "deb.monish" Date: Mon, 19 Sep 2016 13:39:44 +0530 Subject: [PATCH] CRM-16189: additional test improvement dependent on pr-8847 --- .../CRM/Contribute/BAO/ContributionTest.php | 8 ++++---- tests/phpunit/CiviTest/CiviUnitTestCase.php | 15 +++++++++++++-- tests/phpunit/api/v3/MembershipTypeTest.php | 2 +- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php b/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php index 8e6e7244b5..66269545e5 100644 --- a/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php +++ b/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php @@ -866,8 +866,8 @@ WHERE eft.entity_id = %1 AND ft.to_financial_account_id <> %2"; 'contact_id' => $contactId, 'receive_date' => '2010-01-20', 'total_amount' => 300, - 'financial_type_id' => 4, - 'contribution_status_id' => 1, + 'financial_type_id' => $this->getFinancialTypeId('Event Fee'), + 'contribution_status_id' => 'Completed', ); $priceFields = $this->createPriceSet('event', $event['id']); foreach ($priceFields['values'] as $key => $priceField) { @@ -902,8 +902,8 @@ WHERE eft.entity_id = %1 AND ft.to_financial_account_id <> %2"; 'contact_id' => $contactId, 'receive_date' => '2010-01-20', 'total_amount' => 200, - 'financial_type_id' => 2, - 'contribution_status_id' => 1, + 'financial_type_id' => $this->getFinancialTypeId('Member Dues'), + 'contribution_status_id' => 'Completed', ); $membershipType = $this->membershipTypeCreate(); $priceFields = $this->createPriceSet(); diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index 1c0bfb43f8..1d952657b9 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -3305,7 +3305,7 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) 'is_active' => array('1' => 1), 'price_set_id' => $priceset->id, 'is_enter_qty' => 1, - 'financial_type_id' => CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', 'Event Fee', 'id', 'name'), + 'financial_type_id' => $this->getFinancialTypeId('Event Fee'), ); CRM_Price_BAO_PriceField::create($paramsField); @@ -3423,7 +3423,7 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) 'is_active' => array('1' => 1, '2' => 1), 'price_set_id' => $priceSet['id'], 'is_enter_qty' => 1, - 'financial_type_id' => CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', 'Event Fee', 'id', 'name'), + 'financial_type_id' => $this->getFinancialTypeId('Event Fee'), ); $priceField = CRM_Price_BAO_PriceField::create($paramsField); if ($componentId) { @@ -3599,6 +3599,17 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) $this->callAPISuccessGetCount('FinancialItem', array('description' => 'Sales Tax', 'amount' => 0), 0); } + /** + * Return financial type id on basis of name + * + * @param string $name Financial type m/c name + * + * @return int + */ + public function getFinancialTypeId($name) { + return CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $name, 'id', 'name'); + } + /** * Cleanup function for contents of $this->ids. * diff --git a/tests/phpunit/api/v3/MembershipTypeTest.php b/tests/phpunit/api/v3/MembershipTypeTest.php index 9d27887538..8958ddfc20 100644 --- a/tests/phpunit/api/v3/MembershipTypeTest.php +++ b/tests/phpunit/api/v3/MembershipTypeTest.php @@ -77,7 +77,7 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase { $membershipType = $this->callAPIAndDocument('membership_type', 'get', $params, __FUNCTION__, __FILE__); $this->assertEquals($membershipType['values'][$id]['name'], 'General'); $this->assertEquals($membershipType['values'][$id]['member_of_contact_id'], $this->_contactID); - $this->assertEquals($membershipType['values'][$id]['financial_type_id'], 2); + $this->assertEquals($membershipType['values'][$id]['financial_type_id'], $this->getFinancialTypeId('Member Dues')); $this->assertEquals($membershipType['values'][$id]['duration_unit'], 'year'); $this->assertEquals($membershipType['values'][$id]['duration_interval'], '1'); $this->assertEquals($membershipType['values'][$id]['period_type'], 'rolling'); -- 2.25.1