Action schedule API modifications
[civicrm-core.git] / tests / phpunit / api / v3 / CampaignTest.php
index 2328886c921c835eafb30a07d85083c2b32ef386..7e68ba68cb41c8d7b81e139d13febe3a822617a6 100644 (file)
@@ -1,8 +1,7 @@
 <?php
-
 /*
  +--------------------------------------------------------------------+
-| CiviCRM version 4.3                                                |
+| CiviCRM version 4.4                                                |
 +--------------------------------------------------------------------+
 | Copyright CiviCRM LLC (c) 2004-2013                                |
 +--------------------------------------------------------------------+
@@ -38,7 +37,6 @@ class api_v3_CampaignTest extends CiviUnitTestCase {
   function setUp() {
     $this->_apiversion = 3;
     $this->params = array(
-      'version' => 3,
       'title' => "campaign title",
       'description' => "Call people, ask for money",
       'created_date' => 'first sat of July 2008',
@@ -50,34 +48,25 @@ class api_v3_CampaignTest extends CiviUnitTestCase {
 
   public function testCreateCampaign() {
     $description = "Create a campaign - Note use of relative dates here http://www.php.net/manual/en/datetime.formats.relative.php";
-    $result = civicrm_api('campaign', 'create', $this->params);
-    $this->documentMe($this->params, $result, __FUNCTION__, __FILE__, $description);
-    $this->assertEquals(0, $result['is_error'], 'In line ' . __LINE__);
+    $result = $this->callAPIAndDocument('campaign', 'create', $this->params, __FUNCTION__, __FILE__, $description);
     $this->assertEquals(1, $result['count'], 'In line ' . __LINE__);
     $this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__);
     $this->getAndCheck(array_merge($this->params, array('created_date' => '2008-07-05 00:00:00')), $result['id'], 'campaign', TRUE);
   }
 
   public function testGetCampaign() {
-    $result = civicrm_api('campaign', 'create', $this->params);
-    $result = civicrm_api('campaign', 'get', ($this->params));
-    $this->documentMe($this->params, $result, __FUNCTION__, __FILE__);
-    $this->assertEquals(0, $result['is_error'], 'In line ' . __LINE__);
+    $result = $this->callAPISuccess('campaign', 'create', $this->params);
+    $result = $this->callAPIAndDocument('campaign', 'get', $this->params, __FUNCTION__, __FILE__);
     $this->assertEquals(1, $result['count'], 'In line ' . __LINE__);
     $this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__);
-    $this->id = $result['id'];
   }
 
   public function testDeleteCampaign() {
-    $entity = civicrm_api('campaign', 'get', ($this->params));
-    $delete = array('version' => 3, 'id' => $entity['id']);
-    $result = civicrm_api('campaign', 'delete', $delete);
-    $this->documentMe($delete, $result, __FUNCTION__, __FILE__);
-    $this->assertEquals(0, $result['is_error'], 'In line ' . __LINE__);
+    $entity = $this->callAPISuccess('campaign', 'get', ($this->params));
+    $delete = array('id' => $entity['id']);
+    $result = $this->callAPIAndDocument('campaign', 'delete', $delete, __FUNCTION__, __FILE__);
 
-    $checkDeleted = civicrm_api('campaign', 'get', array(
-      'version' => 3,
-      ));
+    $checkDeleted = $this->callAPISuccess('campaign', 'get', array());
     $this->assertEquals(0, $checkDeleted['count'], 'In line ' . __LINE__);
   }
 }