CRM-19110: Fix delete pledge payments
authorjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Fri, 22 Jul 2016 07:03:02 +0000 (12:33 +0530)
committerjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Fri, 22 Jul 2016 07:03:02 +0000 (12:33 +0530)
CRM/Pledge/BAO/PledgePayment.php
tests/phpunit/CRM/Pledge/BAO/PledgePaymentTest.php

index 87da53ba1e9245b75c53c9dcf5e5dec1374b3f99..08752df6966c57e6b72e55f8dbda8bfc10fd8316 100644 (file)
@@ -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);
       }
     }
 
index 96eb69a672986a15f32829c168de53f5e324d88a..b53c10d994c470e6ccb6fdd8dfb74514689d46f7 100644 (file)
@@ -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.
    */