Enable check on created participant payment rows
authorEileen McNaughton <emcnaughton@wikimedia.org>
Fri, 18 Jun 2021 04:10:35 +0000 (16:10 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Mon, 12 Jul 2021 06:54:22 +0000 (18:54 +1200)
Extend participant check

tests/phpunit/CiviTest/CiviUnitTestCase.php

index 1790e50ea5377cb6b50e40453d6e28768e32f8c0..75a94b52e587177877874c00435d35c29ee94325 100644 (file)
@@ -3635,7 +3635,7 @@ VALUES
     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;
@@ -3647,18 +3647,20 @@ VALUES
         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']);
     }