We have been moving from the create helper classes taking a range of parameters to them taking an array which
is merged with the defaults the functions provide in order to create the entity
}
/**
- * Check method create()
+ * Check method create().
*/
public function testCreate() {
$contactId = $this->individualCreate();
$financialTypeId = 1;
- $this->contributionCreate(array('contact_id' => $contactId), $financialTypeId);
+ $this->contributionCreate(array(
+ 'contact_id' => $contactId,
+ 'financial_type_id' => $financialTypeId,
+ ));
$params = array(
'contribution_id' => $financialTypeId,
'to_financial_account_id' => 1,
*
* @param array $params
* Array of parameters.
- * @param int $cTypeID
- * Id of financial type.
- * @param int $invoiceID
- * @param int $trxnID
- * @param int $paymentInstrumentID
*
* @return int
* id of created contribution
*/
- public function contributionCreate($params, $cTypeID = 1, $invoiceID = 67890, $trxnID = 12345,
- $paymentInstrumentID = 1) {
+ public function contributionCreate($params) {
$params = array_merge(array(
'domain_id' => 1,
'total_amount' => 100.00,
'fee_amount' => 5.00,
'net_ammount' => 95.00,
- 'financial_type_id' => $cTypeID,
- 'payment_instrument_id' => empty($paymentInstrumentID) ? 1 : $paymentInstrumentID,
+ 'financial_type_id' => 1,
+ 'payment_instrument_id' => 1,
'non_deductible_amount' => 10.00,
- 'trxn_id' => $trxnID,
- 'invoice_id' => $invoiceID,
+ 'trxn_id' => 12345,
+ 'invoice_id' => 67890,
'source' => 'SSF',
'contribution_status_id' => 1,
), $params);
return $result['id'];
}
- /**
- * Create online contribution.
- *
- * @param array $params
- * @param int $financialType
- * Id of financial type.
- * @param int $invoiceID
- * @param int $trxnID
- *
- * @return int
- * id of created contribution
- */
- public function onlineContributionCreate($params, $financialType, $invoiceID = 67890, $trxnID = 12345) {
- $contribParams = array(
- 'contact_id' => $params['contact_id'],
- 'receive_date' => date('Ymd'),
- 'total_amount' => 100.00,
- 'financial_type_id' => $financialType,
- 'contribution_page_id' => $params['contribution_page_id'],
- 'trxn_id' => 12345,
- 'invoice_id' => 67890,
- 'source' => 'SSF',
- );
- $contribParams = array_merge($contribParams, $params);
- $result = $this->callAPISuccess('contribution', 'create', $contribParams);
-
- return $result['id'];
- }
-
/**
* Delete contribution.
*
//create a contribution so our membership & contribution don't both have id = 1
$this->contributionCreate(array(
'contact_id' => $this->_contactID,
- 'is_test' => 1),
- 1, 'abcd', '345j');
+ 'is_test' => 1,
+ 'financial_type_id' => 1,
+ 'invoice_id' => 'abcd',
+ 'trxn_id' => 345,
+ ));
$this->setupRecurringPaymentProcessorTransaction();
$this->ids['membership'] = $this->callAPISuccess('membership', 'create', array(
class api_v3_ContributionSoftTest extends CiviUnitTestCase {
/**
- * Assume empty database with just civicrm_data.
+ * The hard credit contact.
+ *
+ * @var int
+ */
+ protected $_individualId;
+
+ /**
+ * The first soft credit contact.
+ *
+ * @var int
*/
- protected $_individualId; //the hard credit contact
- protected $_softIndividual1Id; //the first soft credit contact
- protected $_softIndividual2Id; //the second soft credit contact
+ protected $_softIndividual1Id;
+
+ /**
+ * The second soft credit contact.
+ *
+ * @var int
+ */
+ protected $_softIndividual2Id;
protected $_contributionId;
protected $_financialTypeId = 1;
protected $_apiversion = 3;
/**
* Test get methods.
+ *
* @todo - this might be better broken down into more smaller tests
*/
public function testGetContributionSoft() {
*/
public function testCreateUpdateContribution() {
- $contributionID = $this->contributionCreate(array('contact_id' => $this->_individualId), $this->_financialTypeId,
- 'idofsh', 212355);
+ $contributionID = $this->contributionCreate(array(
+ 'contact_id' => $this->_individualId,
+ 'trxn_id' => 212355,
+ 'financial_type_id' => $this->_financialTypeId,
+ 'invoice_id' => 'old_invoice',
+ ));
$old_params = array(
'contribution_id' => $contributionID,
-
);
$original = $this->callAPISuccess('contribution', 'get', $old_params);
- // Make sure it came back.
- $this->assertAPISuccess($original);
$this->assertEquals($original['id'], $contributionID);
//set up list of old params, verify
$this->assertEquals($old_fee_amount, 5.00);
$this->assertEquals($old_source, 'SSF');
$this->assertEquals($old_trxn_id, 212355);
- $this->assertEquals($old_invoice_id, 'idofsh');
+ $this->assertEquals($old_invoice_id, 'old_invoice');
$params = array(
'id' => $contributionID,
'contact_id' => $this->_individualId,
}
public function testDeleteContribution() {
-
- $contributionID = $this->contributionCreate(array('contact_id' => $this->_individualId), $this->_financialTypeId, 'dfsdf', 12389);
+ $contributionID = $this->contributionCreate(array(
+ 'contact_id' => $this->_individualId,
+ 'financial_type_id' => $this->_financialTypeId,
+ ));
$params = array(
'id' => $contributionID,
);
protected $_participantPaymentID;
protected $_financialTypeId;
+ /**
+ * Set up for tests.
+ */
public function setUp() {
parent::setUp();
$this->useTransaction(TRUE);
'contact_id' => $this->_contactID,
'contribution_page_id' => $contributionPage['id'],
'payment_processor' => $paymentProcessor->id,
+ 'financial_type_id' => 1,
);
- $contributionID = $this->onlineContributionCreate($contributionParams, 1);
+ $contributionID = $this->contributionCreate($contributionParams);
$this->_participantPaymentID = $this->participantPaymentCreate($this->_participantID, $contributionID);
$params = array(
$params = array(
'id' => $this->_participantPaymentID,
);
- $deletePayment = $this->callAPISuccess('participant_payment', 'delete', $params);
+ $this->callAPISuccess('participant_payment', 'delete', $params);
}
/**
'contribution_page_id' => $contributionPage['id'],
'contribution_status_id' => 2,
'is_pay_later' => 1,
+ 'financial_type_id' => 1,
);
- $contributionID = $this->onlineContributionCreate($contributionParams, 1);
+ $contributionID = $this->contributionCreate($contributionParams);
$this->_participantPaymentID = $this->participantPaymentCreate($this->_participantID, $contributionID);
$params = array(
$params = array(
'id' => $this->_participantPaymentID,
);
- $deletePayment = $this->callAPISuccess('participant_payment', 'delete', $params);
+ $this->callAPISuccess('participant_payment', 'delete', $params);
}
'sequential' => 1,
);
- $contributionID = $this->contributionCreate(array('contact_id' => $this->_individualId), $this->_financialTypeId,
- 45, 45);
+ $contributionID = $this->contributionCreate(array(
+ 'contact_id' => $this->_individualId,
+ 'financial_type_id' => $this->_financialTypeId,
+ 'invoice_id' => 45,
+ 'trxn_id' => 45,
+ ));
$pledge = $this->callAPISuccess('Pledge', 'Create', $pledgeParams);
//test the pledge_payment_create function
}
/**
+ * Test deleting a contribution.
*
+ * (It is unclear why this is in this class - it seems like maybe it doesn't test anything not
+ * on the contribution test class & might be copy and paste....).
*/
public function testDeleteContribution() {
- $contributionID = $this->contributionCreate(array('contact_id' => $this->_individualId), $this->financialtypeID, 'dfsdf', 12389);
- $params = array(
- 'id' => $contributionID,
- );
- $this->callAPIAndDocument('contribution', 'delete', $params, __FUNCTION__, __FILE__);
+ $contributionID = $this->contributionCreate(array(
+ 'contact_id' => $this->_individualId,
+ 'trxn_id' => 12389,
+ 'financial_type_id' => $this->financialtypeID,
+ 'invoice_id' => 'dfsdf',
+ ));
+ $this->callAPISuccess('contribution', 'delete', array('id' => $contributionID));
}
}