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 = $this->callAPISuccess('CustomSearch', 'create', array(
17 'label' => 'Invalid, overwritten',
18 'description' => 'Longish description of the example search form',
19 'class_name' => 'CRM_Contact_Form_Search_Custom_Examplez',
21 $this->assertAPISuccess($result);
22 $this->assertEquals(1, $result['count'], 'In line ' . __LINE__
);
23 $entityId = $result['id'];
24 $this->assertTrue(is_numeric($entityId), 'In line ' . __LINE__
);
25 $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value
26 WHERE name = "CRM_Contact_Form_Search_Custom_Examplez"
27 AND label = "CRM_Contact_Form_Search_Custom_Examplez"
28 AND option_group_id = 25');
29 $this->assertDBQuery(1, 'SELECT is_active FROM civicrm_option_value
30 WHERE name = "CRM_Contact_Form_Search_Custom_Examplez"');
33 $result = $this->callAPISuccess('CustomSearch', 'create', array(
38 $this->assertEquals(1, $result['count'], 'In line ' . __LINE__
);
39 $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value
40 WHERE name = "CRM_Contact_Form_Search_Custom_Examplez"
41 AND label = "CRM_Contact_Form_Search_Custom_Examplez"
42 AND option_group_id = 25');
43 $this->assertDBQuery(0, 'SELECT is_active FROM civicrm_option_value
44 WHERE name = "CRM_Contact_Form_Search_Custom_Examplez"');
47 $result = $this->callAPISuccess('CustomSearch', 'create', array(
52 $this->assertEquals(1, $result['count'], 'In line ' . __LINE__
);
53 $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value
54 WHERE name = "CRM_Contact_Form_Search_Custom_Examplez"
55 AND label = "CRM_Contact_Form_Search_Custom_Examplez"
56 AND option_group_id = 25');
57 $this->assertDBQuery(1, 'SELECT is_active FROM civicrm_option_value
58 WHERE name = "CRM_Contact_Form_Search_Custom_Examplez"');
60 $result = $this->callAPISuccess('CustomSearch', 'delete', array(
63 $this->assertEquals(1, $result['count'], 'In line ' . __LINE__
);
64 $this->assertDBQuery(0, 'SELECT count(*) FROM civicrm_option_value
65 WHERE name = "CRM_Contact_Form_Search_Custom_Examplez"
66 OR label = "CRM_Contact_Form_Search_Custom_Examplez"