/**
* Test create method (create and update modes).
+ *
+ * @throws \CRM_Core_Exception
*/
public function testCreate() {
$contactId = $this->individualCreate();
$this->assertEquals(2, $financialTrxn->N, 'Mismatch count for is payment flag.');
}
- /**
- * addPayments() method (add and edit modes of participant)
- */
- public function testAddPayments() {
- list($lineItems, $contribution) = $this->addParticipantWithContribution();
- CRM_Contribute_BAO_Contribution::addPayments([$contribution]);
- $this->checkItemValues($contribution);
- }
-
/**
* checks db values for financial item
*/
/**
* assignProportionalLineItems() method (add and edit modes of participant)
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
public function testAssignProportionalLineItems() {
- list($lineItems, $contribution) = $this->addParticipantWithContribution();
+ $contribution = $this->addParticipantWithContribution();
+ // Delete existing financial_trxns. This is because we are testing a code flow we
+ // want to deprecate & remove & the test relies on bad data asa starting point.
+ // End goal is the Order.create->Payment.create flow.
+ CRM_Core_DAO::executeQuery('DELETE FROM civicrm_entity_financial_trxn WHERE entity_table = "civicrm_financial_item"');
$params = [
'contribution_id' => $contribution->id,
'total_amount' => 150.00,
* Add participant with contribution
*
* @return array
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
public function addParticipantWithContribution() {
// creating price set, price field
$this->_contactId = $this->individualCreate();
- $event = $this->eventCreate();
+ $event = $this->eventCreatePaid([]);
$this->_eventId = $event['id'];
- $paramsSet['title'] = 'Price Set' . substr(sha1(rand()), 0, 4);
- $paramsSet['name'] = CRM_Utils_String::titleToVar($paramsSet['title']);
- $paramsSet['is_active'] = TRUE;
- $paramsSet['financial_type_id'] = 4;
- $paramsSet['extends'] = 1;
-
- $priceset = CRM_Price_BAO_PriceSet::create($paramsSet);
- $priceSetId = $priceset->id;
-
- //Checking for priceset added in the table.
- $this->assertDBCompareValue('CRM_Price_BAO_PriceSet', $priceSetId, 'title',
- 'id', $paramsSet['title'], 'Check DB for created priceset'
- );
+ $priceSetId = $this->priceSetID;
$paramsField = [
'label' => 'Price Field',
'name' => CRM_Utils_String::titleToVar('Price Field'),
'weight' => 1,
'options_per_line' => 1,
'is_active' => ['1' => 1, '2' => 1],
- 'price_set_id' => $priceset->id,
+ 'price_set_id' => $this->priceSetID,
'is_enter_qty' => 1,
'financial_type_id' => CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', 'Event Fee', 'id', 'name'),
];
];
$participant = CRM_Event_BAO_Participant::add($participantParams);
$contributionParams = [
- 'total_amount' => 150,
+ 'total_amount' => 300,
'currency' => 'USD',
'contact_id' => $this->_contactId,
'financial_type_id' => 4,
- 'contribution_status_id' => 1,
- 'partial_payment_total' => 300.00,
- 'partial_amount_to_pay' => 150,
+ 'contribution_status_id' => 'Pending',
'contribution_mode' => 'participant',
'participant_id' => $participant->id,
'sequential' => TRUE,
+ 'api.Payment.create' => ['total_amount' => 150],
];
foreach ($priceFields['values'] as $key => $priceField) {
$contributionObject->id = $contribution['id'];
$contributionObject->find(TRUE);
- return [$lineItems, $contributionObject];
+ return $contributionObject;
}
/**