a few more tidy-ups to use callAPISuccess rather than the long-form
authoreileen <eileen@fuzion.co.nz>
Sat, 29 Jun 2013 22:57:53 +0000 (10:57 +1200)
committereileen <eileen@fuzion.co.nz>
Sat, 29 Jun 2013 22:57:53 +0000 (10:57 +1200)
tests/phpunit/CiviTest/CiviUnitTestCase.php

index 5adb952fa34f82d8f1b64f80ba0cb5e5385eb76f..6bf34bacf5b0f8dc7047e6490528b1075eb38a46 100644 (file)
@@ -1399,15 +1399,10 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
       'event_full_text' => 'Sorry! We are already full',
       'is_monetory' => 0,
       'is_active' => 1,
-      'version' => API_LATEST_VERSION,
       'is_show_location' => 0,
     ), $params);
 
-    $result = civicrm_api('Event', 'create', $params);
-    if ($result['is_error'] == 1) {
-      throw new Exception($result['error_message']);
-    }
-    return $result;
+    return $this->callAPISuccess('Event', 'create', $params);
   }
 
   /**
@@ -1418,9 +1413,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
   function eventDelete($id) {
     $params = array(
       'event_id' => $id,
-      'version' => API_LATEST_VERSION,
     );
-    civicrm_api('event', 'delete', $params);
+    return $this->callAPISuccess('event', 'delete', $params);
   }
 
   /**
@@ -1431,14 +1425,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
   function participantDelete($participantID) {
     $params = array(
       'id' => $participantID,
-      'version' => API_LATEST_VERSION,
     );
-    $result = civicrm_api('Participant', 'delete', $params);
-
-    if (CRM_Utils_Array::value('is_error', $result)) {
-      throw new Exception('Could not delete participant');
-    }
-    return;
+    return $this->callAPISuccess('Participant', 'delete', $params);
   }
 
   /**