Skip to content

Commit

Permalink
Merge pull request #16218 from seamuslee001/nfc_add_more_asserts_chan…
Browse files Browse the repository at this point in the history
…ge_fee_selection

[NFC] Add in more assertions around the content of line items and tot…
  • Loading branch information
seamuslee001 authored Jan 7, 2020
2 parents 77b503d + 052a9c3 commit 012171b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/phpunit/CRM/Event/BAO/ChangeFeeSelectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -484,18 +484,32 @@ public function testCRM17151() {
$partiallyPaidStatusId = array_search('Partially paid', $contributionStatuses);
$pendingRefundStatusId = array_search('Pending refund', $contributionStatuses);
$completedStatusId = array_search('Completed', $contributionStatuses);
$this->assertDBCompareValue('CRM_Contribute_BAO_Contribution', $this->_contributionId, 'total_amount', 'id', $this->_expensiveFee, "Total Amount equals " . $this->_expensiveFee);
$this->assertDBCompareValue('CRM_Contribute_BAO_Contribution', $this->_contributionId, 'contribution_status_id', 'id', $completedStatusId, 'Payment be completed');
$priceSetParams['price_' . $this->priceSetFieldID] = $this->cheapFeeValueID;
$lineItem = CRM_Price_BAO_LineItem::getLineItems($this->_participantId, 'participant');
$this->assertEquals($this->_expensiveFee, $lineItem[1]['line_total']);
CRM_Price_BAO_LineItem::changeFeeSelections($priceSetParams, $this->_participantId, 'participant', $this->_contributionId, $this->_feeBlock, $lineItem);
$this->assertDBCompareValue('CRM_Contribute_BAO_Contribution', $this->_contributionId, 'total_amount', 'id', $this->_cheapFee, "Total Amount equals " . $this->_expensiveFee);
$this->assertDBCompareValue('CRM_Contribute_BAO_Contribution', $this->_contributionId, 'contribution_status_id', 'id', $pendingRefundStatusId, 'Contribution must be refunding');
$priceSetParams['price_' . $this->priceSetFieldID] = $this->expensiveFeeValueID;
$lineItem = CRM_Price_BAO_LineItem::getLineItems($this->_participantId, 'participant');
$this->assertEquals('0.00', $lineItem[1]['line_total']);
$this->assertEquals($this->_cheapFee, $lineItem[2]['line_total']);
CRM_Price_BAO_LineItem::changeFeeSelections($priceSetParams, $this->_participantId, 'participant', $this->_contributionId, $this->_feeBlock, $lineItem);
$this->assertDBCompareValue('CRM_Contribute_BAO_Contribution', $this->_contributionId, 'contribution_status_id', 'id', $completedStatusId, 'Contribution must, after complete payment be in state completed');
$priceSetParams['price_' . $this->priceSetFieldID] = $this->veryExpensiveFeeValueID;
$lineItem = CRM_Price_BAO_LineItem::getLineItems($this->_participantId, 'participant');
$this->assertEquals($this->_expensiveFee, $lineItem[1]['line_total']);
$this->assertEquals('0.00', $lineItem[2]['line_total']);
// @todo this doesn't seem to work right even tho it should
//$this->assertDBCompareValue('CRM_Contribute_BAO_Contribution', $this->_contributionId, 'total_amount', 'id', $this->_expensiveFee, "Total Amount equals " . $this->_expensiveFee);
CRM_Price_BAO_LineItem::changeFeeSelections($priceSetParams, $this->_participantId, 'participant', $this->_contributionId, $this->_feeBlock, $lineItem);
$lineItem = CRM_Price_BAO_LineItem::getLineItems($this->_participantId, 'participant');
$this->assertEquals('0.00', $lineItem[1]['line_total']);
$this->assertEquals('0.00', $lineItem[2]['line_total']);
$this->assertEquals($this->_veryExpensive, $lineItem[3]['line_total']);
$this->assertDBCompareValue('CRM_Contribute_BAO_Contribution', $this->_contributionId, 'total_amount', 'id', $this->_veryExpensive, "Total Amount equals " . $this->_veryExpensive);
$this->assertDBCompareValue('CRM_Contribute_BAO_Contribution', $this->_contributionId, 'contribution_status_id', 'id', $partiallyPaidStatusId, 'Partial Paid');
}

Expand Down

0 comments on commit 012171b

Please sign in to comment.