Test tidy-ups. Bring set up functions more in line with other tests
authoreileen <emcnaughton@wikimedia.org>
Wed, 27 Apr 2016 03:51:41 +0000 (15:51 +1200)
committereileen <emcnaughton@wikimedia.org>
Tue, 17 May 2016 11:45:37 +0000 (23:45 +1200)
tests/phpunit/CRM/Dedupe/DedupeFinderTest.php
tests/phpunit/CRM/Dedupe/MergerTest.php

index 7f2be57ed3df42a54758c25228530d91bc509ae5..4799a4f4a0456bac031929f3fb81ca94a8b9af82 100644 (file)
@@ -26,10 +26,9 @@ class CRM_Dedupe_DedupeFinderTest extends CiviUnitTestCase {
       'domain_id' => 1,
       'is_active' => 1,
       'visibility' => 'Public Pages',
-      'version' => 3,
     );
-    // TODO: This is not an API test!!
-    $result = civicrm_api('group', 'create', $params);
+
+    $result = $this->callAPISuccess('group', 'create', $params);
     $groupId = $result['id'];
 
     // contact data set
@@ -80,18 +79,15 @@ class CRM_Dedupe_DedupeFinderTest extends CiviUnitTestCase {
     );
 
     $count = 1;
-    // TODO: This is not an API test!!
     foreach ($params as $param) {
-      $param['version'] = 3;
-      $contact = civicrm_api('contact', 'create', $param);
+      $contact = $this->callAPISuccess('contact', 'create', $param);
       $contactIds[$count++] = $contact['id'];
 
       $grpParams = array(
         'contact_id' => $contact['id'],
         'group_id' => $groupId,
-        'version' => 3,
       );
-      $res = civicrm_api('group_contact', 'create', $grpParams);
+      $this->callAPISuccess('group_contact', 'create', $grpParams);
     }
 
     // verify that all contacts have been created separately
@@ -181,17 +177,15 @@ class CRM_Dedupe_DedupeFinderTest extends CiviUnitTestCase {
     );
 
     $count = 1;
-    // TODO: This is not an API test!!
+
     foreach ($params as $param) {
-      $param['version'] = 3;
-      $contact = civicrm_api('contact', 'create', $param);
+      $contact = $this->callAPISuccess('contact', 'create', $param);
       $params = array(
         'contact_id' => $contact['id'],
         'street_address' => 'Ambachtstraat 23',
         'location_type_id' => 1,
-        'version' => 3,
       );
-      $result = civicrm_api('address', 'create', $params);
+      $this->callAPISuccess('address', 'create', $params);
       $contactIds[$count++] = $contact['id'];
     }
 
@@ -210,7 +204,7 @@ class CRM_Dedupe_DedupeFinderTest extends CiviUnitTestCase {
       'email' => 'hood@example.com',
       'street_address' => 'Ambachtstraat 23',
     );
-    $errorScope = CRM_Core_TemporaryErrorScope::useException();
+    CRM_Core_TemporaryErrorScope::useException();
     $dedupeParams = CRM_Dedupe_Finder::formatParams($fields, 'Individual');
     $ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, 'Individual', 'General');
 
index a48b0fda910d3da69439064bfa46b1c9ae48178c..73b9bab41192e3f284885da7c4b55b9da26ae208 100644 (file)
@@ -22,10 +22,9 @@ class CRM_Dedupe_MergerTest extends CiviUnitTestCase {
       'domain_id'  => 1,
       'is_active'  => 1,
       'visibility' => 'Public Pages',
-      'version'    => 3,
     );
-    // TODO: This is not an API test!!
-    $result = civicrm_api('group', 'create', $params);
+
+    $result = $this->callAPISuccess('group', 'create', $params);
     $this->_groupId = $result['id'];
 
     // contact data set
@@ -110,7 +109,7 @@ class CRM_Dedupe_MergerTest extends CiviUnitTestCase {
         'group_id'   => $this->_groupId,
         'version'    => 3,
       );
-      $res = civicrm_api('group_contact', 'create', $grpParams);
+      $this->callAPISuccess('group_contact', 'create', $grpParams);
     }
   }
 
@@ -121,10 +120,7 @@ class CRM_Dedupe_MergerTest extends CiviUnitTestCase {
     foreach ($this->_contactIds as $contactId) {
       $this->contactDelete($contactId);
     }
-
-    // delete dupe group
-    $params = array('id' => $this->_groupId, 'version' => 3);
-    civicrm_api('group', 'delete', $params);
+    $this->groupDelete($this->_groupId);
   }
 
   /**