3 require_once 'CiviTest/CiviUnitTestCase.php';
5 class api_v3_CustomSearchTest
extends CiviUnitTestCase
{
6 protected $_apiversion;
7 public $_eNoticeCompliant = TRUE;
9 $this->_apiversion
= 3;
13 function tearDown() {}
15 public function testCustomSearch() {
16 $result = civicrm_api('CustomSearch', 'create', array(
17 'version' => $this->_apiversion
,
18 'label' => 'Invalid, overwritten',
19 'description' => 'Longish description of the example search form',
20 'class_name' => 'CRM_Contact_Form_Search_Custom_Examplez',
22 $this->assertAPISuccess($result);
23 $this->assertEquals(1, $result['count'], 'In line ' . __LINE__
);
24 $entityId = $result['id'];
25 $this->assertTrue(is_numeric($entityId), 'In line ' . __LINE__
);
26 $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value
27 WHERE name = "CRM_Contact_Form_Search_Custom_Examplez"
28 AND label = "CRM_Contact_Form_Search_Custom_Examplez"
29 AND option_group_id = 25');
30 $this->assertDBQuery(1, 'SELECT is_active FROM civicrm_option_value
31 WHERE name = "CRM_Contact_Form_Search_Custom_Examplez"');
34 $result = civicrm_api('CustomSearch', 'create', array(
35 'version' => $this->_apiversion
,
39 $this->assertAPISuccess($result);
40 $this->assertEquals(1, $result['count'], 'In line ' . __LINE__
);
41 $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value
42 WHERE name = "CRM_Contact_Form_Search_Custom_Examplez"
43 AND label = "CRM_Contact_Form_Search_Custom_Examplez"
44 AND option_group_id = 25');
45 $this->assertDBQuery(0, 'SELECT is_active FROM civicrm_option_value
46 WHERE name = "CRM_Contact_Form_Search_Custom_Examplez"');
49 $result = civicrm_api('CustomSearch', 'create', array(
50 'version' => $this->_apiversion
,
54 $this->assertAPISuccess($result);
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 = 25');
60 $this->assertDBQuery(1, 'SELECT is_active FROM civicrm_option_value
61 WHERE name = "CRM_Contact_Form_Search_Custom_Examplez"');
63 $result = civicrm_api('CustomSearch', 'delete', array(
64 'version' => $this->_apiversion
,
67 $this->assertAPISuccess($result);
68 $this->assertEquals(1, $result['count'], 'In line ' . __LINE__
);
69 $this->assertDBQuery(0, 'SELECT count(*) FROM civicrm_option_value
70 WHERE name = "CRM_Contact_Form_Search_Custom_Examplez"
71 OR label = "CRM_Contact_Form_Search_Custom_Examplez"