Add in Country and StateProvince APIv4 Entities
[civicrm-core.git] / tests / phpunit / api / v3 / CustomSearchTest.php
index 665746e3b9835ef519b9442ada2577bfb15ad275..4ac288050b1bf3839b3d21d9a1565d3d92535edb 100644 (file)
@@ -2,6 +2,7 @@
 
 /**
  * Class api_v3_CustomSearchTest
+ * @group headless
  */
 class api_v3_CustomSearchTest extends CiviUnitTestCase {
   protected $_apiversion;
@@ -13,11 +14,11 @@ class api_v3_CustomSearchTest extends CiviUnitTestCase {
   }
 
   public function testCustomSearch() {
-    $result = $this->callAPISuccess('CustomSearch', 'create', array(
+    $result = $this->callAPISuccess('CustomSearch', 'create', [
       'label' => 'Invalid, overwritten',
       'description' => 'Longish description of the example search form',
       'class_name' => 'CRM_Contact_Form_Search_Custom_Examplez',
-    ));
+    ]);
     $this->assertAPISuccess($result);
     $this->assertEquals(1, $result['count']);
     $entityId = $result['id'];
@@ -30,10 +31,10 @@ class api_v3_CustomSearchTest extends CiviUnitTestCase {
       WHERE name = "CRM_Contact_Form_Search_Custom_Examplez"');
 
     // deactivate
-    $result = $this->callAPISuccess('CustomSearch', 'create', array(
+    $result = $this->callAPISuccess('CustomSearch', 'create', [
       'id' => $entityId,
       'is_active' => 0,
-    ));
+    ]);
 
     $this->assertEquals(1, $result['count']);
     $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value
@@ -44,10 +45,10 @@ class api_v3_CustomSearchTest extends CiviUnitTestCase {
       WHERE name = "CRM_Contact_Form_Search_Custom_Examplez"');
 
     // activate
-    $result = $this->callAPISuccess('CustomSearch', 'create', array(
+    $result = $this->callAPISuccess('CustomSearch', 'create', [
       'id' => $entityId,
       'is_active' => 1,
-    ));
+    ]);
 
     $this->assertEquals(1, $result['count']);
     $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value
@@ -56,10 +57,12 @@ class api_v3_CustomSearchTest extends CiviUnitTestCase {
       AND option_group_id IN (SELECT id from civicrm_option_group WHERE name = "custom_search") ');
     $this->assertDBQuery(1, 'SELECT is_active FROM civicrm_option_value
       WHERE name = "CRM_Contact_Form_Search_Custom_Examplez"');
-
-    $result = $this->callAPISuccess('CustomSearch', 'delete', array(
-      'id' => $entityId,
-    ));
+    $check = $this->callAPISuccess('CustomSearch', 'get', ['id' => $entityId]);
+    if (!empty($check['count'])) {
+      $result = $this->callAPISuccess('CustomSearch', 'delete', [
+        'id' => $entityId,
+      ]);
+    }
     $this->assertEquals(1, $result['count']);
     $this->assertDBQuery(0, 'SELECT count(*) FROM civicrm_option_value
       WHERE name = "CRM_Contact_Form_Search_Custom_Examplez"