CRM-16189: additional test improvement dependent on pr-8847
authordeb.monish <monish.deb@webaccessglobal.com>
Mon, 19 Sep 2016 08:09:44 +0000 (13:39 +0530)
committerdeb.monish <monish.deb@webaccessglobal.com>
Mon, 19 Sep 2016 08:13:39 +0000 (13:43 +0530)
tests/phpunit/CRM/Contribute/BAO/ContributionTest.php
tests/phpunit/CiviTest/CiviUnitTestCase.php
tests/phpunit/api/v3/MembershipTypeTest.php

index 8e6e7244b5370b7cd17ff038e8029d054f86d4fa..66269545e574cf43c7f96cafb0310534d32a41a4 100644 (file)
@@ -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();
index 1c0bfb43f8975903c2b1178fc4f9825da6300a47..1d952657b92634345cd269ef53dec5f253606855 100644 (file)
@@ -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.
    *
index 9d27887538dccfb376f06121a325a53c866b5c74..8958ddfc2006f72774ea87a36e736008b09939a5 100644 (file)
@@ -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');