Skip to content

Commit

Permalink
Merge pull request #20650 from eileenmcnaughton/partorder
Browse files Browse the repository at this point in the history
Enable check on created participant payment rows
  • Loading branch information
eileenmcnaughton authored Jul 12, 2021
2 parents 72e1079 + 95556e1 commit db81b85
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions tests/phpunit/CiviTest/CiviUnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3635,7 +3635,7 @@ protected function validateAllContributions(): void {
foreach ($contributions as $contribution) {
$lineItems = $this->callAPISuccess('LineItem', 'get', [
'contribution_id' => $contribution['id'],
'return' => ['tax_amount', 'line_total', 'entity_table', 'entity_id'],
'return' => ['tax_amount', 'line_total', 'entity_table', 'entity_id', 'qty'],
])['values'];
$total = 0;
$taxTotal = 0;
Expand All @@ -3647,18 +3647,20 @@ protected function validateAllContributions(): void {
if ($lineItem['entity_table'] === 'civicrm_membership') {
$memberships[] = $lineItem['entity_id'];
}
if ($lineItem['entity_table'] === 'civicrm_participant') {
$participants[] = $lineItem['entity_id'];
if ($lineItem['entity_table'] === 'civicrm_participant' && $lineItem['qty'] > 0) {
$participants[$lineItem['entity_id']] = $lineItem['entity_id'];
}
}
$membershipPayments = $this->callAPISuccess('MembershipPayment', 'get', ['contribution_id' => $contribution['id'], 'return' => 'membership_id'])['values'];
$participantPayments = $this->callAPISuccess('ParticipantPayment', 'get', ['contribution_id' => $contribution['id'], 'return' => 'participant_id'])['values'];
$this->assertCount(count($memberships), $membershipPayments);
// @todo not working yet.
// $this->assertCount(count($participants), $participantPayments);
$this->assertCount(count($participants), $participantPayments);
foreach ($membershipPayments as $payment) {
$this->assertContains($payment['membership_id'], $memberships);
}
foreach ($participantPayments as $payment) {
$this->assertContains($payment['participant_id'], $participants);
}
$this->assertEquals($taxTotal, (float) ($contribution['tax_amount'] ?? 0));
$this->assertEquals($total + $taxTotal, $contribution['total_amount']);
}
Expand Down

0 comments on commit db81b85

Please sign in to comment.