<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.7 |
+ | CiviCRM version 5 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2018 |
+--------------------------------------------------------------------+
$params['total_amount'] = $this->formatMoneyInput(5000.77);
$params['fee_amount'] = $this->formatMoneyInput(.77);
+ $params['skipCleanMoney'] = FALSE;
$contribution = $this->callAPISuccess('contribution', 'create', $params);
$contribution = $this->callAPISuccessGetSingle('contribution', array('id' => $contribution['id']));
* Test if renewal activity is create after changing Pending contribution to Completed via offline
*/
public function testPendingToCompleteContribution() {
- $contributionPage = $this->createPriceSetWithPage('membership');
- $stateOfGrace = $this->callAPISuccess('MembershipStatus', 'getvalue', array(
- 'name' => 'Grace',
- 'return' => 'id')
- );
+ $this->createPriceSetWithPage('membership');
$this->setUpPendingContribution($this->_ids['price_field_value'][0]);
$this->callAPISuccess('membership', 'getsingle', array('id' => $this->_ids['membership']));
// Case 1: Assert that Membership Signup Activity is created on Pending to Completed Contribution via backoffice
// change pending contribution to completed
$form = new CRM_Contribute_Form_Contribution();
- $error = FALSE;
+
$form->_params = array(
'id' => $this->_ids['contribution'],
'total_amount' => 20,
'contribution_mode' => 'membership',
'source' => 'Membership Signup and Renewal',
);
- try {
- $form->testSubmit($form->_params, CRM_Core_Action::UPDATE);
- }
- catch (Civi\Payment\Exception\PaymentProcessorException $e) {
- $error = TRUE;
- }
+
+ $form->testSubmit($form->_params, CRM_Core_Action::UPDATE);
+
// Case 2: After successful payment for Pending backoffice there are three activities created
// 2.a Update status of existing Scheduled Membership Signup (created in step 1) to Completed
$activity = $this->callAPISuccess('Activity', 'get', array(
'source' => 'SSF',
'contribution_status_id' => 2,
'contribution_page_id' => $this->_ids['contribution_page'],
+ // We can't rely on contribution api to link line items correctly to membership
+ 'skipLineItem' => TRUE,
'api.membership_payment.create' => array('membership_id' => $this->_ids['membership']),
));
'unit_price' => 20,
'line_total' => 20,
'financial_type_id' => 1,
+ 'price_field_value_id' => $this->_ids['price_field_value']['cont'],
+ ));
+ $this->callAPISuccess('line_item', 'create', array(
+ 'entity_id' => $this->_ids['membership'],
+ 'entity_table' => 'civicrm_membership',
+ 'contribution_id' => $contribution['id'],
+ 'price_field_id' => $this->_ids['price_field'][0],
+ 'qty' => 1,
+ 'unit_price' => 20,
+ 'line_total' => 20,
+ 'financial_type_id' => 1,
'price_field_value_id' => $this->_ids['price_field_value'][0],
+ 'membership_type_id' => $this->_ids['membership_type'],
));
//Update it to Failed.
$form->_params['id'] = $contribution['id'];
$form->_params['contribution_status_id'] = 4;
- try {
- $form->testSubmit($form->_params, CRM_Core_Action::UPDATE);
- }
- catch (Civi\Payment\Exception\PaymentProcessorException $e) {
- $error = TRUE;
- }
+
+ $form->testSubmit($form->_params, CRM_Core_Action::UPDATE);
//Existing membership should not get updated to expired.
$membership = $this->callAPISuccess('membership', 'getsingle', array('id' => $this->_ids['membership']));
$this->assertNotEquals($membership['status_id'], 4);
return array_merge(CRM_Financial_BAO_FinancialItem::retrieveEntityFinancialTrxn($trxnParams, FALSE, array()));
}
+ /**
+ * Test getunique api call for Contribution entity
+ */
+ public function testContributionGetUnique() {
+ $result = $this->callAPIAndDocument($this->_entity, 'getunique', array(), __FUNCTION__, __FILE__);
+ $this->assertEquals(2, $result['count']);
+ $this->assertEquals(array('trxn_id'), $result['values']['UI_contrib_trxn_id']);
+ $this->assertEquals(array('invoice_id'), $result['values']['UI_contrib_invoice_id']);
+ }
+
}