+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
protected $_ids = array();
protected $_pageParams = array();
+ /**
+ * Parameters to create payment processor.
+ *
+ * @var array
+ */
+ protected $_processorParams = array();
+
+ /**
+ * ID of created event.
+ *
+ * @var int
+ */
+ protected $_eventID;
+
/**
* Setup function.
*/
}
/**
- * Check with complete array + custom field
+ * Check with complete array + custom field.
+ *
* Note that the test is written on purpose without any
* variables specific to participant so it can be replicated into other entities
* and / or moved to the automated test suite
}
/**
- * Function tests that additional financial records are created when online contribution with pending option.
- * is created
+ * Function tests that additional financial records are created for online contribution with pending option.
*/
public function testCreateContributionPendingOnline() {
$paymentProcessor = CRM_Financial_BAO_PaymentProcessor::create($this->_processorParams);
}
/**
- * Function tests that line items, financial records are updated when contribution amount is changed
+ * Function tests that line items, financial records are updated when contribution amount is changed.
*/
public function testCreateUpdateContributionChangeTotal() {
$contribution = $this->callAPISuccess('contribution', 'create', $this->_params);
}
/**
- * Function tests that line items, financial records are updated when pay later contribution is received
+ * Function tests that line items, financial records are updated when pay later contribution is received.
*/
public function testCreateUpdateContributionPayLater() {
$contribParams = array(
}
/**
- * Test that update does not change status id CRM-15105
+ * Test that update does not change status id CRM-15105.
*/
public function testCreateUpdateWithoutChangingPendingStatus() {
$contribution = $this->callAPISuccess('contribution', 'create', array_merge($this->_params, array('contribution_status_id' => 2)));
/**
* Test civicrm_contribution_search with empty params.
+ *
* All available contributions expected.
*/
public function testSearchEmptyParams() {
$mut->stop();
}
+ /**
+ * Test repeat contribution successfully creates line items.
+ */
+ public function testRepeatTransaction() {
+ $paymentProcessorID = $this->paymentProcessorCreate();
+ $contributionRecur = $this->callAPISuccess('contribution_recur', 'create', array(
+ 'contact_id' => $this->_individualId,
+ 'installments' => '12',
+ 'frequency_interval' => '1',
+ 'amount' => '500',
+ 'contribution_status_id' => 1,
+ 'start_date' => '2012-01-01 00:00:00',
+ 'currency' => 'USD',
+ 'frequency_unit' => 'month',
+ 'payment_processor_id' => $paymentProcessorID,
+ ));
+ $originalContribution = $this->callAPISuccess('contribution', 'create', array_merge(
+ $this->_params,
+ array('contribution_recur_id' => $contributionRecur['id']))
+ );
+
+ $this->callAPISuccess('contribution', 'repeattransaction', array(
+ 'original_contribution_id' => $originalContribution['id'],
+ 'contribution_status_id' => 'Completed',
+ 'trxn_id' => uniqid(),
+ ));
+ $lineItemParams = array(
+ 'entity_id' => $originalContribution['id'],
+ 'sequential' => 1,
+ 'return' => array(
+ 'entity_table',
+ 'qty',
+ 'unit_price',
+ 'line_total',
+ 'label',
+ 'financial_type_id',
+ 'deductible_amount',
+ 'price_field_value_id',
+ 'price_field_id',
+ ),
+ );
+ $lineItem1 = $this->callAPISuccess('line_item', 'get', array_merge($lineItemParams, array(
+ 'entity_id' => $originalContribution['id'],
+ )));
+ $lineItem2 = $this->callAPISuccess('line_item', 'get', array_merge($lineItemParams, array(
+ 'entity_id' => $originalContribution['id'] + 1,
+ )));
+ unset($lineItem1['values'][0]['id'], $lineItem1['values'][0]['entity_id']);
+ unset($lineItem2['values'][0]['id'], $lineItem2['values'][0]['entity_id']);
+ $this->assertEquals($lineItem1['values'][0], $lineItem2['values'][0]);
+
+ $this->quickCleanUpFinancialEntities();
+ }
+
/**
* Test completing a transaction does not 'mess' with net amount (CRM-15960).
*/
}
/**
- * CRM-14151
- * Test completing a transaction via the API
- *
- * tests.
+ * CRM-14151 - Test completing a transaction via the API.
*/
public function testCompleteTransactionWithReceiptDateSet() {
$mut = new CiviMailUtils($this, TRUE);
/**
+ * Create price set with contribution test for test setup.
+ *
* This could be merged with 4.5 function setup in api_v3_ContributionPageTest::setUpContributionPage
* on parent class at some point (fn is not in 4.4).
+ *
* @param $entity
* @param array $params
*/
/**
* Set up a pending transaction with a specific price field id.
+ *
* @param int $priceFieldValueID
*/
public function setUpPendingContribution($priceFieldValueID) {
}
/**
- * This function does a GET & compares the result against the $params
- * Use as a double check on Creates
- * @param $params
- * @param $id
- * @param int $delete
+ * This function does a GET & compares the result against the $params.
+ *
+ * Use as a double check on Creates.
+ *
+ * @param array $params
+ * @param int $id
+ * @param bool $delete
*/
- public function contributionGetnCheck($params, $id, $delete = 1) {
+ public function contributionGetnCheck($params, $id, $delete = TRUE) {
$contribution = $this->callAPISuccess('Contribution', 'Get', array(
'id' => $id,
}
/**
- * Create a pending contribution & linked pending participant record
- * (along with an event)
+ * Create a pending contribution & linked pending participant record (along with an event).
*/
public function createPendingParticipantContribution() {
$event = $this->eventCreate(array('is_email_confirm' => 1, 'confirm_from_email' => 'test@civicrm.org'));
}
/**
+ * Get financial transaction amount.
+ *
* @param int $contId
*
* @return null|string