3 require_once 'CiviTest/CiviUnitTestCase.php';
6 * Class api_v3_CustomSearchTest
8 class api_v3_CustomSearchTest
extends CiviUnitTestCase
{
9 protected $_apiversion;
12 $this->_apiversion
= 3;
16 function tearDown() {}
18 public function testCustomSearch() {
19 $result = $this->callAPISuccess('CustomSearch', 'create', array(
20 'label' => 'Invalid, overwritten',
21 'description' => 'Longish description of the example search form',
22 'class_name' => 'CRM_Contact_Form_Search_Custom_Examplez',
24 $this->assertAPISuccess($result);
25 $this->assertEquals(1, $result['count'], 'In line ' . __LINE__
);
26 $entityId = $result['id'];
27 $this->assertTrue(is_numeric($entityId), 'In line ' . __LINE__
);
28 $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value
29 WHERE name = "CRM_Contact_Form_Search_Custom_Examplez"
30 AND label = "CRM_Contact_Form_Search_Custom_Examplez"
31 AND option_group_id IN (SELECT id from civicrm_option_group WHERE name = "custom_search") ');
32 $this->assertDBQuery(1, 'SELECT is_active FROM civicrm_option_value
33 WHERE name = "CRM_Contact_Form_Search_Custom_Examplez"');
36 $result = $this->callAPISuccess('CustomSearch', 'create', array(
41 $this->assertEquals(1, $result['count'], 'In line ' . __LINE__
);
42 $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value
43 WHERE name = "CRM_Contact_Form_Search_Custom_Examplez"
44 AND label = "CRM_Contact_Form_Search_Custom_Examplez"
45 AND option_group_id IN (SELECT id from civicrm_option_group WHERE name = "custom_search") ');
46 $this->assertDBQuery(0, 'SELECT is_active FROM civicrm_option_value
47 WHERE name = "CRM_Contact_Form_Search_Custom_Examplez"');
50 $result = $this->callAPISuccess('CustomSearch', 'create', array(
55 $this->assertEquals(1, $result['count'], 'In line ' . __LINE__
);
56 $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value
57 WHERE name = "CRM_Contact_Form_Search_Custom_Examplez"
58 AND label = "CRM_Contact_Form_Search_Custom_Examplez"
59 AND option_group_id IN (SELECT id from civicrm_option_group WHERE name = "custom_search") ');
60 $this->assertDBQuery(1, 'SELECT is_active FROM civicrm_option_value
61 WHERE name = "CRM_Contact_Form_Search_Custom_Examplez"');
63 $result = $this->callAPISuccess('CustomSearch', 'delete', array(
66 $this->assertEquals(1, $result['count'], 'In line ' . __LINE__
);
67 $this->assertDBQuery(0, 'SELECT count(*) FROM civicrm_option_value
68 WHERE name = "CRM_Contact_Form_Search_Custom_Examplez"
69 OR label = "CRM_Contact_Form_Search_Custom_Examplez"