From cfb9aa9a4c813b48db07e38ff1492510d0748e9f Mon Sep 17 00:00:00 2001 From: demeritcowboy Date: Thu, 9 Feb 2023 13:01:57 -0500 Subject: [PATCH] use correct id --- CRM/Contribute/BAO/Contribution.php | 2 +- tests/phpunit/CRM/Event/BAO/AdditionalPaymentTest.php | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 941f594678..19c66ed3d0 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -3607,7 +3607,7 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac $info['transaction'] = self::getContributionTransactionInformation($contributionId, $contribution['financial_type_id']); } - $info['payment_links'] = self::getContributionPaymentLinks($id, $info['contribution_status']); + $info['payment_links'] = self::getContributionPaymentLinks($contributionId, $info['contribution_status']); return $info; } diff --git a/tests/phpunit/CRM/Event/BAO/AdditionalPaymentTest.php b/tests/phpunit/CRM/Event/BAO/AdditionalPaymentTest.php index e4ac8c2d20..c776f5f6cb 100644 --- a/tests/phpunit/CRM/Event/BAO/AdditionalPaymentTest.php +++ b/tests/phpunit/CRM/Event/BAO/AdditionalPaymentTest.php @@ -199,6 +199,10 @@ class CRM_Event_BAO_AdditionalPaymentTest extends CiviUnitTestCase { * @throws \CRM_Core_Exception */ public function testAddPartialPayment() { + // First add an unrelated contribution since otherwise the contribution and + // participant ids are all 1 so they might match by accident. + $this->contributionCreate(['contact_id' => $this->individualCreate([], 0, TRUE)]); + $feeAmt = 100; $amtPaid = (float) 60; $balance = (float) 40; @@ -212,6 +216,13 @@ class CRM_Event_BAO_AdditionalPaymentTest extends CiviUnitTestCase { $this->assertEquals('Partially paid', $result['contribution']['contribution_status']); $this->assertEquals('Partially paid', $result['participant']['participant_status']); + + // Check the record payment link has the right id and that it doesn't + // match by accident. + $this->assertNotEquals($result['contribution']['id'], $result['participant']['id']); + $paymentInfo = CRM_Contribute_BAO_Contribution::getPaymentInfo($result['participant']['id'], 'event'); + $this->assertEquals('Record Payment', $paymentInfo['payment_links'][0]['title']); + $this->assertEquals($result['contribution']['id'], $paymentInfo['payment_links'][0]['qs']['id']); } /** -- 2.25.1