CRM-16259, added api test for delete action
authorPradeep Nayak <pradpnayak@gmail.com>
Wed, 20 Jan 2016 11:13:29 +0000 (16:43 +0530)
committerPradeep Nayak <pradpnayak@gmail.com>
Wed, 20 Jan 2016 11:13:29 +0000 (16:43 +0530)
----------------------------------------
* CRM-16259: Create Payment API
  https://issues.civicrm.org/jira/browse/CRM-16259

tests/phpunit/api/v3/PaymentTest.php

index da05c3b20dee5e1aa25c716f64d987b24a946081..315d3929410f2172f468316919e67ef902614d76 100644 (file)
@@ -345,4 +345,30 @@ class api_v3_PaymentTest extends CiviUnitTestCase {
     ));
   }
 
+  /**
+   * Test delete payment api
+   */
+  public function testDeletePayment() {
+    list($lineItems, $contribution) = $this->createParticipantWithContribution();
+
+    $params = array(
+      'contribution_id' => $contribution['id'],
+    );
+
+    $payment = $this->callAPIAndDocument('payment', 'get', $params, __FUNCTION__, __FILE__);
+    $this->assertEquals(1, $payment['count']);
+
+    $cancelParams = array(
+      'id' => $payment['id'],
+    );
+    $this->callAPIAndDocument('payment', 'delete', $cancelParams, __FUNCTION__, __FILE__);
+
+    $payment = $this->callAPIAndDocument('payment', 'get', $params, __FUNCTION__, __FILE__);
+    $this->assertEquals(0, $payment['count']);
+
+    $this->callAPISuccess('Contribution', 'Delete', array(
+      'id' => $contribution['id'],
+    ));
+  }
+
 }