From: jitendrapurohit Date: Mon, 24 Feb 2014 11:21:30 +0000 (+0530) Subject: api test for CRM-13833 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=bcc03b982527b99a807e6aa2cc2834fdd7d09c03;p=civicrm-core.git api test for CRM-13833 --- diff --git a/tests/phpunit/api/v3/ContributionTest.php b/tests/phpunit/api/v3/ContributionTest.php index df1ccfac77..0f6fee93d9 100644 --- a/tests/phpunit/api/v3/ContributionTest.php +++ b/tests/phpunit/api/v3/ContributionTest.php @@ -628,19 +628,19 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $description = "Demonstrates creating contribution with SoftCredit"; $subfile = "ContributionCreateWithSoftCredit"; $contact2 = $this->callAPISuccess('Contact', 'create', array('display_name' => 'superman', 'contact_type' => 'Individual')); - $params = $this->_params + array( - 'soft_credit_to' => $contact2['id'], - + $softparams = array( + 'contact_id' => $contact2['id'], + 'amount' => 50, + 'soft_credit_type_id' => 3 ); + $params = $this->_params + array('soft_credit' => array(1 => $softparams)); $contribution = $this->callAPIAndDocument('contribution', 'create', $params, __FUNCTION__, __FILE__, $description, $subfile); - // $result = $this->callAPISuccess('contribution','get', array('return'=> 'soft_credit_to', 'sequential' => 1)); - // $this->assertEquals($contact2['id'], $result['values'][$result['id']]['soft_credit_to']) ; - // well - the above doesn't work yet so lets do SQL - $query = "SELECT count(*) FROM civicrm_contribution_soft WHERE contact_id = " . $contact2['id']; + $result = $this->callAPISuccess('contribution','get', array('return'=> 'soft_credit', 'sequential' => 1)); - $count = CRM_Core_DAO::singleValueQuery($query); - $this->assertEquals(1, $count); + $this->assertEquals($softparams['contact_id'], $result['values'][0]['soft_credit'][1]['contact_id']); + $this->assertEquals($softparams['amount'], $result['values'][0]['soft_credit'][1]['amount']); + $this->assertEquals($softparams['soft_credit_type_id'], $result['values'][0]['soft_credit'][1]['soft_credit_type']); $this->callAPISuccess('contribution', 'delete', array('id' => $contribution['id'])); $this->callAPISuccess('contact', 'delete', array('id' => $contact2['id']));