CRM-15855 - Allow mailings to be saved (but not sent) without name+subject.
[civicrm-core.git] / tests / phpunit / api / v3 / CustomSearchTest.php
index db49192c385812ecf02782b12f033dfecc518eef..b2738166372a04efeffb5f5ad79e834e8b6cbedf 100644 (file)
@@ -2,16 +2,18 @@
 
 require_once 'CiviTest/CiviUnitTestCase.php';
 
+/**
+ * Class api_v3_CustomSearchTest
+ */
 class api_v3_CustomSearchTest extends CiviUnitTestCase {
   protected $_apiversion;
 
-  function setUp() {
+  public function setUp() {
     $this->_apiversion = 3;
     parent::setUp();
+    $this->useTransaction(TRUE);
   }
 
-  function tearDown() {}
-
   public function testCustomSearch() {
     $result = $this->callAPISuccess('CustomSearch', 'create', array(
       'label' => 'Invalid, overwritten',
@@ -25,7 +27,7 @@ class api_v3_CustomSearchTest extends CiviUnitTestCase {
     $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value
       WHERE name = "CRM_Contact_Form_Search_Custom_Examplez"
       AND label = "CRM_Contact_Form_Search_Custom_Examplez"
-      AND option_group_id = 25');
+      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"');
 
@@ -39,7 +41,7 @@ class api_v3_CustomSearchTest extends CiviUnitTestCase {
     $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value
       WHERE name = "CRM_Contact_Form_Search_Custom_Examplez"
       AND label = "CRM_Contact_Form_Search_Custom_Examplez"
-      AND option_group_id = 25');
+      AND option_group_id IN (SELECT id from civicrm_option_group WHERE name = "custom_search") ');
     $this->assertDBQuery(0, 'SELECT is_active FROM civicrm_option_value
       WHERE name = "CRM_Contact_Form_Search_Custom_Examplez"');
 
@@ -53,7 +55,7 @@ class api_v3_CustomSearchTest extends CiviUnitTestCase {
     $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value
       WHERE name = "CRM_Contact_Form_Search_Custom_Examplez"
       AND label = "CRM_Contact_Form_Search_Custom_Examplez"
-      AND option_group_id = 25');
+      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"');
 
@@ -66,4 +68,5 @@ class api_v3_CustomSearchTest extends CiviUnitTestCase {
       OR label = "CRM_Contact_Form_Search_Custom_Examplez"
       ');
   }
+
 }