Soft Credit API plus unit tests
authorJon goldberg - Linux laptop <jon@palantetech.coop>
Sat, 4 May 2013 22:07:53 +0000 (15:07 -0700)
committerJon goldberg - Linux laptop <jon@palantetech.coop>
Sat, 4 May 2013 22:17:33 +0000 (15:17 -0700)
api/v3/ContributionSoft.php [new file with mode: 0644]
tests/phpunit/api/v3/ContributionSoftTest.php [new file with mode: 0644]

diff --git a/api/v3/ContributionSoft.php b/api/v3/ContributionSoft.php
new file mode 100644 (file)
index 0000000..978f9ec
--- /dev/null
@@ -0,0 +1,100 @@
+<?php
+// $Id$
+
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.3                                                |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2013                                |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM.                                    |
+ |                                                                    |
+ | CiviCRM is free software; you can copy, modify, and distribute it  |
+ | under the terms of the GNU Affero General Public License           |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
+ |                                                                    |
+ | CiviCRM is distributed in the hope that it will be useful, but     |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of         |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
+ | See the GNU Affero General Public License for more details.        |
+ |                                                                    |
+ | You should have received a copy of the GNU Affero General Public   |
+ | License and the CiviCRM Licensing Exception along                  |
+ | with this program; if not, contact CiviCRM LLC                     |
+ | at info[AT]civicrm[DOT]org. If you have questions about the        |
+ | GNU Affero General Public License or the licensing of CiviCRM,     |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
+ +--------------------------------------------------------------------+
+*/
+
+/**
+ * File for the CiviCRM APIv3 soft credit functions
+ *
+ * @package CiviCRM_APIv3
+ * @subpackage API_ContributionSoft
+ *
+ * @copyright CiviCRM LLC (c) 2004-2013
+ * @version $Id: ContributionSoft.php 2013-05-01 Jon Goldberg $
+ */
+
+/**
+ * Create or Update a Soft Credit
+ *
+ * @param array $params  Associative array of property
+ *                       name/value pairs to insert in new 'contribution_soft'
+ *
+ * @example ContributionSoftCreate.php Standard Create Example //FIXME
+ *
+ * @return array API result array
+ * {@getfields contribution_soft_create}
+ * @access public
+ */
+function civicrm_api3_contribution_soft_create($params) {
+  return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+}
+
+/**
+ * Adjust Metadata for Create action
+ *
+ * The metadata is used for setting defaults, documentation & validation
+ * @param array $params array or parameters determined by getfields
+ */
+function _civicrm_api3_contribution_soft_create_spec(&$params) {
+  $params['contribution_id']['api.required'] = 1;
+  $params['contact_id']['api.required'] = 1;
+  $params['amount']['api.required'] = 1;
+}
+
+/**
+ * Deletes an existing Soft Credit
+ *
+ * @param  array  $params
+ *
+ * @example ContributionSoftDelete.php Standard Delete Example
+ *
+ * @return boolean | error  true if successfull, error otherwise
+ * {@getfields contribution_soft_delete}
+ * @access public
+ */
+function civicrm_api3_contribution_soft_delete($params) {
+  return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+}
+
+/**
+ * Retrieve one or more Soft Credits
+ *
+ * @param  array input parameters
+ *
+ *
+ * @example ContributionSoftGet.php Standard Get Example
+ *
+ * @param  array $params  an associative array of name/value pairs.
+ *
+ * @return  array api result
+ * {@getfields contribution_soft_get}
+ * @access public
+ */
+function civicrm_api3_contribution_soft_get($params) {
+  return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+}
+
diff --git a/tests/phpunit/api/v3/ContributionSoftTest.php b/tests/phpunit/api/v3/ContributionSoftTest.php
new file mode 100644 (file)
index 0000000..e0a79e7
--- /dev/null
@@ -0,0 +1,486 @@
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.3                                                |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2013                                |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM.                                    |
+ |                                                                    |
+ | CiviCRM is free software; you can copy, modify, and distribute it  |
+ | under the terms of the GNU Affero General Public License           |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
+ |                                                                    |
+ | CiviCRM is distributed in the hope that it will be useful, but     |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of         |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
+ | See the GNU Affero General Public License for more details.        |
+ |                                                                    |
+ | You should have received a copy of the GNU Affero General Public   |
+ | License and the CiviCRM Licensing Exception along                  |
+ | with this program; if not, contact CiviCRM LLC                     |
+ | at info[AT]civicrm[DOT]org. If you have questions about the        |
+ | GNU Affero General Public License or the licensing of CiviCRM,     |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
+ +--------------------------------------------------------------------+
+*/
+
+require_once 'CiviTest/CiviUnitTestCase.php';
+//FIXME:This existed in ContributionTest,  don't think it's necessary
+//require_once 'CiviTest/CiviMailUtils.php';
+
+
+/**
+ *  Test APIv3 civicrm_contribute_* functions
+ *
+ *  @package CiviCRM_APIv3
+ *  @subpackage API_ContributionSoft
+ */
+
+class api_v3_ContributionSoftTest extends CiviUnitTestCase {
+
+  /**
+   * Assume empty database with just civicrm_data
+   */
+  protected $_individualId; //the hard credit contact
+  protected $_softIndividual1Id; //the first soft credit contact
+  protected $_softIndividual2Id; //the second soft credit contact
+  protected $_contributionId;
+  protected $_contributionTypeId = 1;
+  protected $_apiversion;
+  protected $_entity = 'Contribution';
+  public $debug = 0;
+  protected $_params;
+  public $_eNoticeCompliant = TRUE;
+  
+  function setUp() {
+    parent::setUp();
+
+    $this->_apiversion = 3;
+    $this->_individualId = $this->individualCreate();
+    $this->_softIndividual1Id = $this->individualCreate();
+    $this->_softIndividual2Id = $this->individualCreate();
+    $this->_contributionId = $this->contributionCreate($this->_individualId);
+    
+    $paymentProcessor = $this->processorCreate();
+    $this->_params = array(
+      'contact_id' => $this->_individualId,
+      'receive_date' => '20120511',
+      'total_amount' => 100.00,
+      'financial_type_id'   => $this->_contributionTypeId,
+      'non_deductible_amount' => 10.00,
+      'fee_amount' => 5.00,
+      'net_amount' => 95.00,
+      'source' => 'SSF',
+      'contribution_status_id' => 1,
+      'version' => $this->_apiversion,
+    );
+    $this->_processorParams = array(
+      'domain_id' => 1,
+      'name' => 'Dummy',
+      'payment_processor_type_id' => 10,
+      'financial_account_id' => 12,
+      'is_active' => 1,
+      'user_name' => '',
+      'url_site' => 'http://dummy.com',
+      'url_recur' => 'http://dummy.com',
+      'billing_mode' => 1,
+    );
+//    $this->_pageParams = array(
+//      'version' => 3,
+//      'title' => 'Test Contribution Page',
+//      'financial_type_id' => 1,
+//      'currency' => 'USD',
+//      'financial_account_id' => 1,
+//      'payment_processor' => $paymentProcessor->id,
+//      'is_active' => 1,
+//      'is_allow_other_amount' => 1,
+//      'min_amount' => 10,
+//      'max_amount' => 1000,
+//     );
+  }
+
+  function tearDown() {
+
+    $this->contributionTypeDelete();
+    $this->quickCleanup(array(
+      'civicrm_contribution',
+      'civicrm_event',
+      'civicrm_contribution_page',
+      'civicrm_participant',
+      'civicrm_participant_payment',
+      'civicrm_line_item',
+      'civicrm_financial_trxn',
+      'civicrm_financial_item',
+      'civicrm_entity_financial_trxn',
+      'civicrm_contact',
+      'civicrm_contribution_soft'
+    ));
+  }
+
+  function testGetEmptyParamsContributionSoft() {
+    $params = array();
+    $contribution = civicrm_api('contribution_soft', 'get', $params);
+    $this->assertEquals($contribution['is_error'], 1);
+    $this->assertEquals($contribution['error_message'], 'Mandatory key(s) missing from params array: version');
+  }
+
+  function testGetParamsNotArrayContributionSoft() {
+    $params = 'contact_id= 1';
+    $contribution = civicrm_api('contribution', 'get', $params);
+    $this->assertEquals($contribution['is_error'], 1);
+    $this->assertEquals($contribution['error_message'], 'Input variable `params` is not an array');
+  }
+
+  function testGetContributionSoft() {
+    //We don't test for PCP fields because there's no PCP API, so we can't create campaigns.
+    $p = array(
+      'contribution_id' => $this->_contributionId,
+      'contact_id' => $this->_softIndividual1Id,
+      'amount' => 10.00,
+      'currency' => 'USD',
+      'version' => $this->_apiversion,
+    );
+    
+    $this->_softcontribution = civicrm_api('contribution_soft', 'create', $p);
+    $this->assertEquals($this->_softcontribution['is_error'], 0, 'In line ' . __LINE__);
+    $params = array(
+      'id' => $this->_softcontribution['id'],
+      'version' => $this->_apiversion,
+    );
+    $softcontribution = civicrm_api('contribution_soft', 'get', $params);
+    $this->assertAPISuccess($softcontribution, 'In line ' . __LINE__);
+    $this->assertEquals(1,$softcontribution['count']);
+    
+    $this->documentMe($params, $softcontribution, __FUNCTION__, __FILE__);
+    $this->assertEquals($softcontribution['values'][$this->_softcontribution['id']]['contribution_id'], $this->_contributionId, 'In line ' . __LINE__);
+    $this->assertEquals($softcontribution['values'][$this->_softcontribution['id']]['contact_id'], $this->_softIndividual1Id, 'In line ' . __LINE__);
+    $this->assertEquals($softcontribution['values'][$this->_softcontribution['id']]['amount'], '10.00', 'In line ' . __LINE__);
+    $this->assertEquals($softcontribution['values'][$this->_softcontribution['id']]['currency'], 'USD', 'In line ' . __LINE__);
+
+    //create a second soft contribution on the same hard contribution - we are testing that 'id' gets the right soft contribution id (not the contribution id)
+    $p['contact_id'] = $this->_softIndividual2Id;
+    $this->_softcontribution2 = civicrm_api('contribution_soft', 'create', $p);
+    $this->assertAPISuccess($this->_softcontribution2, 'In line ' . __LINE__);
+
+    $params = array(
+      'version' => $this->_apiversion,
+    );
+    // now we have 2 - test getcount
+    $softcontribution = civicrm_api('contribution_soft', 'getcount', array(
+      'version' => $this->_apiversion,
+    ));
+    
+    $this->assertEquals(2, $softcontribution);
+   //test id only format
+    $softcontribution = civicrm_api('contribution_soft', 'get', array
+      ('version' => $this->_apiversion,
+        'id' => $this->_softcontribution['id'],
+        'format.only_id' => 1,
+      )
+    );
+    $this->assertEquals($this->_softcontribution['id'], $softcontribution, print_r($softcontribution,true) . " in line " . __LINE__);
+    //test id only format - second soft credit
+    $softcontribution = civicrm_api('contribution_soft', 'get', array
+      ('version' => $this->_apiversion,
+        'id' => $this->_softcontribution2['id'],
+        'format.only_id' => 1,
+      )
+    );
+    $this->assertEquals($this->_softcontribution2['id'], $softcontribution);
+    $softcontribution = civicrm_api('contribution_soft', 'get', array(
+      'version' => $this->_apiversion,
+        'id' => $this->_softcontribution['id'],
+      ));
+    //test id as field
+    $this->assertAPISuccess($softcontribution, 'In line ' . __LINE__);
+    $this->assertEquals(1, $softcontribution['count'], 'In line ' . __LINE__);
+    $this->assertEquals($this->_softcontribution['id'], $softcontribution['id'] )  ;
+    //test get by contact id works
+    $softcontribution = civicrm_api('contribution_soft', 'get', array('version' => $this->_apiversion, 'contact_id' => $this->_softIndividual2Id));
+    $this->assertAPISuccess($softcontribution, 'In line ' . __LINE__ . "get with contact_id" . print_r(array('version' => $this->_apiversion, 'contact_id' => $this->_softIndividual2Id), TRUE));
+
+    $this->assertEquals(1, $softcontribution['count'], 'In line ' . __LINE__);
+    civicrm_api('contribution_soft', 'Delete', array(
+      'id' => $this->_softcontribution['id'],
+        'version' => $this->_apiversion,
+      ));
+    civicrm_api('Contribution', 'Delete', array(
+      'id' => $this->_softcontribution2['id'],
+        'version' => $this->_apiversion,
+      ));
+  }
+
+
+  ///////////////// civicrm_contribution_soft
+  function testCreateEmptyParamsContributionSoft() {
+
+
+    $params = array('version' => $this->_apiversion);
+    $softcontribution = civicrm_api('contribution_soft', 'create', $params);
+    $this->assertEquals($softcontribution['is_error'], 1, 'In line ' . __LINE__);
+    $this->assertEquals($softcontribution['error_message'], 'Mandatory key(s) missing from params array: contribution_id, amount, contact_id', 'In line ' . __LINE__);
+  }
+
+  function testCreateParamsNotArrayContributionSoft() {
+
+    $params = 'contact_id= 1';
+    $softcontribution = civicrm_api('contribution_soft', 'create', $params);
+    $this->assertEquals($softcontribution['is_error'], 1);
+    $this->assertEquals($softcontribution['error_message'], 'Input variable `params` is not an array');
+  }
+
+  function testCreateParamsWithoutRequiredKeysContributionSoft() {
+    $params = array('version' => 3);
+    $softcontribution = civicrm_api('contribution_soft', 'create', $params);
+    $this->assertEquals($softcontribution['is_error'], 1);
+    $this->assertEquals($softcontribution['error_message'], 'Mandatory key(s) missing from params array: contribution_id, amount, contact_id');
+  }
+  
+  function testCreateContributionSoftInvalidContact() {
+
+    $params = array(
+      'contact_id' => 999,
+      'contribution_id' => $this->_contributionId,
+      'amount' => 10.00,
+      'currency' => 'USD',
+      'version' => $this->_apiversion,
+    );
+
+    $softcontribution = civicrm_api('contribution_soft', 'create', $params);
+    $this->assertEquals($softcontribution['error_message'], 'contact_id is not valid : 999', 'In line ' . __LINE__);
+  }
+  
+  function testCreateContributionSoftInvalidContributionId() {
+
+    $params = array(
+      'contribution_id' => 999999,
+      'contact_id' => $this->_softIndividual1Id,
+      'amount' => 10.00,
+      'currency' => 'USD',
+      'version' => $this->_apiversion,
+    );
+
+    $softcontribution = civicrm_api('contribution_soft', 'create', $params);
+    $this->assertEquals($softcontribution['error_message'], 'contribution_id is not valid : 999999', 'In line ' . __LINE__);
+  }
+
+  /*
+   * Function tests that additional financial records are created when fee amount is recorded
+   */
+  function testCreateContributionSoft() {
+    $params = array(
+      'contribution_id' => $this->_contributionId,
+      'contact_id' => $this->_softIndividual1Id,
+      'amount' => 10.00,
+      'currency' => 'USD',
+      'version' => $this->_apiversion,
+    );
+
+    $softcontribution = civicrm_api('contribution_soft', 'create', $params);
+    $this->documentMe($params, $softcontribution, __FUNCTION__, __FILE__);
+    $this->assertEquals($softcontribution['values'][$softcontribution['id']]['contribution_id'], $this->_contributionId, 'In line ' . __LINE__);
+    $this->assertEquals($softcontribution['values'][$softcontribution['id']]['contact_id'], $this->_softIndividual1Id, 'In line ' . __LINE__);
+    $this->assertEquals($softcontribution['values'][$softcontribution['id']]['amount'], '10.00', 'In line ' . __LINE__);
+    $this->assertEquals($softcontribution['values'][$softcontribution['id']]['currency'], 'USD', 'In line ' . __LINE__);
+  }
+  
+  /**
+   *  Test  using example code
+   */
+//  function testContributionSoftCreateExample() {
+//    //make sure at least one page exists since there is a truncate in tear down
+//    $page = civicrm_api('contribution_page', 'create', $this->_pageParams);
+//    $this->assertAPISuccess($page);
+//    //FIXME: Can't written until ContributionSoftDelete is written
+//    require_once 'api/v3/examples/ContributionSoftCreate.php';
+//    $result         = contribution_soft_create_example();
+//    $this->assertAPISuccess($result);
+//    $contributionId = $result['id'];
+//    $expectedResult = contribution_soft_create_expectedresult();
+//    $this->checkArrayEquals($result, $expectedResult);
+//    $this->contributionDelete($contributionId);
+//  }
+//
+  //To Update Soft Contribution
+  function testCreateUpdateContributionSoft() {
+    //create a soft credit
+    $params = array(
+      'contribution_id' => $this->_contributionId,
+      'contact_id' => $this->_softIndividual1Id,
+      'amount' => 10.00,
+      'currency' => 'USD',
+      'version' => $this->_apiversion,
+    );
+
+    $softcontribution = civicrm_api('contribution_soft', 'create', $params);
+    $softcontributionID = $softcontribution['id'];
+    
+    $old_params = array(
+      'contribution_soft_id' => $softcontributionID,
+      'version' => $this->_apiversion,
+    );
+    $original = civicrm_api('contribution_soft', 'get', $old_params);
+    //Make sure it came back
+    $this->assertTrue(empty($original['is_error']), 'In line ' . __LINE__);
+    $this->assertEquals($original['id'], $softcontributionID, 'In line ' . __LINE__);
+    //set up list of old params, verify
+    $old_contribution_id = $original['values'][$softcontributionID]['contribution_id'];
+    $old_contact_id = $original['values'][$softcontributionID]['contact_id'];
+    $old_amount = $original['values'][$softcontributionID]['amount'];
+    $old_currency = $original['values'][$softcontributionID]['currency'];
+
+    //check against original values
+    $this->assertEquals($old_contribution_id, $this->_contributionId, 'In line ' . __LINE__);
+    $this->assertEquals($old_contact_id, $this->_softIndividual1Id, 'In line ' . __LINE__);
+    $this->assertEquals($old_amount, 10.00, 'In line ' . __LINE__);
+    $this->assertEquals($old_currency, 'USD', 'In line ' . __LINE__);
+    $params = array(
+      'id' => $softcontributionID,
+      'contribution_id' => $this->_contributionId,
+      'contact_id' => $this->_softIndividual1Id,
+      'amount' => 7.00,
+      'currency' => 'CAD',
+      'version' => $this->_apiversion,
+    );
+
+    $softcontribution = civicrm_api('contribution_soft', 'create', $params);
+
+    $new_params = array(
+      'id' => $softcontribution['id'],
+      'version' => $this->_apiversion,
+    );
+    $softcontribution = civicrm_api('contribution_soft', 'get', $new_params);
+    //check against original values
+    $this->assertEquals($softcontribution['values'][$softcontributionID]['contribution_id'], $this->_contributionId, 'In line ' . __LINE__);
+    $this->assertEquals($softcontribution['values'][$softcontributionID]['contact_id'], $this->_softIndividual1Id, 'In line ' . __LINE__);
+    $this->assertEquals($softcontribution['values'][$softcontributionID]['amount'], 7.00, 'In line ' . __LINE__);
+    $this->assertEquals($softcontribution['values'][$softcontributionID]['currency'], 'CAD', 'In line ' . __LINE__);
+   
+    $params = array(
+      'id' => $softcontributionID,
+      'version' => $this->_apiversion,
+    );
+    $result = civicrm_api('contribution_soft', 'delete', $params);
+    $this->assertEquals($result['is_error'], 0, 'in line' . __LINE__);
+  }
+
+  ///////////////// civicrm_contribution_soft_delete methods
+  function testDeleteEmptyParamsContributionSoft() {
+    $params = array('version' => $this->_apiversion);
+    $softcontribution = civicrm_api('contribution_soft', 'delete', $params);
+    $this->assertEquals($softcontribution['is_error'], 1);
+  }
+
+  function testDeleteParamsNotArrayContributionSoft() {
+    $params = 'id= 1';
+    $softcontribution = civicrm_api('contribution_soft', 'delete', $params);
+    $this->assertEquals($softcontribution['is_error'], 1);
+    $this->assertEquals($softcontribution['error_message'], 'Input variable `params` is not an array');
+  }
+
+  function testDeleteWrongParamContributionSoft() {
+    $params = array(
+      'contribution_source' => 'SSF',
+      'version' => $this->_apiversion,
+    );
+    $softcontribution = civicrm_api('contribution_soft', 'delete', $params);
+    $this->assertEquals($softcontribution['is_error'], 1);
+  }
+
+  function testDeleteContributionSoft() {
+    //create a soft credit
+    $params = array(
+      'contribution_id' => $this->_contributionId,
+      'contact_id' => $this->_softIndividual1Id,
+      'amount' => 10.00,
+      'currency' => 'USD',
+      'version' => $this->_apiversion,
+    );
+
+    $softcontribution = civicrm_api('contribution_soft', 'create', $params);
+    $softcontributionID = $softcontribution['id'];
+    $params = array(
+      'id' => $softcontributionID,
+      'version' => $this->_apiversion,
+    );
+    $result = civicrm_api('contribution_soft', 'delete', $params);
+    $this->documentMe($params, $result, __FUNCTION__, __FILE__);
+    $this->assertEquals($result['is_error'], 0, 'In line ' . __LINE__);
+  }
+
+  ///////////////// civicrm_contribution_search methods
+
+  /**
+   *  Test civicrm_contribution_soft_search with wrong params type
+   */
+  function testSearchWrongParamsType() {
+    $params = 'a string';
+    $result = civicrm_api('contribution_soft', 'get', $params);
+
+    $this->assertEquals($result['is_error'], 1, 'In line ' . __LINE__);
+    $this->assertEquals($result['error_message'], 'Input variable `params` is not an array', 'In line ' . __LINE__);
+  }
+
+  /**
+   *  Test civicrm_contribution_search with empty params.
+   *  All available contributions expected.
+   */
+  function testSearchEmptyParams() {
+    $params = array('version' => $this->_apiversion);
+
+    $p = array(
+      'contribution_id' => $this->_contributionId,
+      'contact_id' => $this->_softIndividual1Id,
+      'amount' => 10.00,
+      'currency' => 'USD',
+      'version' => $this->_apiversion,
+    );
+    $softcontribution = civicrm_api('contribution_soft', 'create', $p);
+
+    $result = civicrm_api('contribution_soft', 'get', $params);
+    // We're taking the first element.
+    $res = $result['values'][$softcontribution['id']];
+
+    $this->assertEquals($p['contribution_id'], $res['contribution_id'], 'In line ' . __LINE__);
+    $this->assertEquals($p['contact_id'], $res['contact_id'], 'In line ' . __LINE__);
+    $this->assertEquals($p['amount'], $res['amount'], 'In line ' . __LINE__);
+    $this->assertEquals($p['currency'], $res['currency'], 'In line ' . __LINE__);
+  }
+
+  /**
+   *  Test civicrm_contribution_soft_search. Success expected.
+   */
+  function testSearch() {
+    $p1 = array(
+      'contribution_id' => $this->_contributionId,
+      'contact_id' => $this->_softIndividual1Id,
+      'amount' => 10.00,
+      'currency' => 'USD',
+      'version' => $this->_apiversion,
+    );
+    $softcontribution1 = civicrm_api('contribution_soft', 'create', $p1);
+
+    $p2 = array(
+      'contribution_id' => $this->_contributionId,
+      'contact_id' => $this->_softIndividual2Id,
+      'amount' => 25.00,
+      'currency' => 'CAD',
+      'version' => $this->_apiversion,
+    );
+    $softcontribution2 = civicrm_api('contribution_soft', 'create', $p2);
+
+    $params = array(
+      'id' => $softcontribution2['id'],
+      'version' => $this->_apiversion,
+    );
+    $result = civicrm_api('contribution_soft', 'get', $params);
+    $res = $result['values'][$softcontribution2['id']];
+
+    $this->assertEquals($p2['contribution_id'], $res['contribution_id'], 'In line ' . __LINE__);
+    $this->assertEquals($p2['contact_id'], $res['contact_id'], 'In line ' . __LINE__);
+    $this->assertEquals($p2['amount'], $res['amount'], 'In line ' . __LINE__);
+    $this->assertEquals($p2['currency'], $res['currency'], 'In line ' . __LINE__ );
+  }
+}
+