--CRM-16188, added changes suggested by Eileen
authorPradeep Nayak <pradpnayak@gmail.com>
Fri, 29 Jan 2016 14:03:45 +0000 (19:33 +0530)
committerPradeep Nayak <pradpnayak@gmail.com>
Mon, 8 Feb 2016 09:54:28 +0000 (15:24 +0530)
api/v3/Order.php
tests/phpunit/api/v3/OrderTest.php

index f53144329037e774f73c7c8cdb2891ede117865a..36b093d2ac09686dd84d0ee501efcb35bfce8c9a 100644 (file)
@@ -137,15 +137,15 @@ function civicrm_api3_order_create(&$params) {
 function civicrm_api3_order_delete($params) {
   $contribution = civicrm_api3('Contribution', 'get', array(
     'return' => array('is_test'),
-    'id' => CRM_Utils_Array::value('contribution_id', $params, $params['id']),
+    'id' => $params['id'],
   ));
   if ($contribution['id'] && $contribution['values'][$contribution['id']]['is_test'] == TRUE) {
     $result = civicrm_api3('Contribution', 'delete', $params);
   }
   else {
-    throw new API_Exception('Could not delete Order.');
+    throw new API_Exception('Only test orders can be deleted.');
   }
-  return civicrm_api3_create_success(CRM_Utils_Array::value('values', $result), $params, 'Order', 'delete');
+  return civicrm_api3_create_success($result['values'], $params, 'Order', 'delete');
 }
 
 /**
index ed18a1914bf36259359b824e0215786f45631424..1aa5e3a6eb8716d1fe1c0fb40f22b0df5f4cf27e 100644 (file)
@@ -446,7 +446,7 @@ class api_v3_OrderTest extends CiviUnitTestCase {
       $this->fail("Missed expected exception");
     }
     catch (Exception $expected) {
-      $this->callAPISuccess('contribution', 'create', array(
+      $this->callAPISuccess('Contribution', 'create', array(
         'contribution_id' => $order['id'],
         'is_test' => TRUE,
       ));