From 7eb6e79697efd10f47d679ba8fb0320da9c4f5aa Mon Sep 17 00:00:00 2001 From: jitendrapurohit Date: Fri, 22 Jul 2016 12:33:02 +0530 Subject: [PATCH] CRM-19110: Fix delete pledge payments --- CRM/Pledge/BAO/PledgePayment.php | 2 +- tests/phpunit/CRM/Pledge/BAO/PledgePaymentTest.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CRM/Pledge/BAO/PledgePayment.php b/CRM/Pledge/BAO/PledgePayment.php index 87da53ba1e..08752df696 100644 --- a/CRM/Pledge/BAO/PledgePayment.php +++ b/CRM/Pledge/BAO/PledgePayment.php @@ -269,7 +269,7 @@ WHERE pledge_id = %1 if ($payment->contribution_id) { CRM_Contribute_BAO_Contribution::deleteContribution($payment->contribution_id); } - $payment->delete(); + self::del($payment->id); } } diff --git a/tests/phpunit/CRM/Pledge/BAO/PledgePaymentTest.php b/tests/phpunit/CRM/Pledge/BAO/PledgePaymentTest.php index 96eb69a672..b53c10d994 100644 --- a/tests/phpunit/CRM/Pledge/BAO/PledgePaymentTest.php +++ b/tests/phpunit/CRM/Pledge/BAO/PledgePaymentTest.php @@ -138,6 +138,19 @@ class CRM_Pledge_BAO_PledgePaymentTest extends CiviUnitTestCase { $result = CRM_Pledge_BAO_Pledge::deletePledge($payment->pledge_id); } + /** + * Delete Multiple payments for one pledge. + */ + public function testDeletePledgePayments() { + $contactId = $this->individualCreate(); + $pledgeId = $this->pledgeCreate(array('contact_id' => $contactId)); + CRM_Pledge_BAO_PledgePayment::deletePayments($pledgeId); + + // No payments should be retrieved + $pledgePayment = CRM_Pledge_BAO_PledgePayment::getPledgePayments($pledgeId); + $this->assertEquals(count($pledgePayment), 0, "Checking for empty array"); + } + /** * Pass Null Id for a payment deletion for one pledge. */ -- 2.25.1