2 class Bug43395Test extends Sugar_PHPUnit_Framework_OutputTestCase
4 private static $quickSearch;
5 private static $contact;
7 static function setUpBeforeClass()
9 global $app_strings, $app_list_strings;
10 $app_strings = return_application_language($GLOBALS['current_language']);
11 $app_list_strings = return_app_list_strings_language($GLOBALS['current_language']);
14 $GLOBALS['current_user'] = $user;
15 self::$contact = SugarTestContactUtilities::createContact();
16 self::$contact->first_name = 'Bug43395';
17 self::$contact->last_name = 'Test';
18 self::$contact->salutation = 'Mr.';
19 self::$contact->save();
22 public static function tearDownAfterClass()
24 unset($_REQUEST['data']);
25 unset($_REQUEST['query']);
26 SugarTestContactUtilities::removeAllCreatedContacts();
29 public function testFormatResults()
32 $_REQUEST['data'] = '{"form":"search_form","method":"query","modules":["Contacts"],"group":"or","field_list":["name","id"],"populate_list":["contact_c_basic","contact_id_c_basic"],"required_list":["parent_id"],"conditions":[{"name":"name","op":"like_custom","end":"%","value":""}],"order":"name","limit":"30","no_match_text":"No Match"}';
33 $_REQUEST['query'] = self::$contact->first_name;
34 require_once 'modules/Home/quicksearchQuery.php';
37 $data = $json->decode(html_entity_decode($_REQUEST['data']));
38 if(isset($_REQUEST['query']) && !empty($_REQUEST['query'])){
39 foreach($data['conditions'] as $k=>$v){
40 if(empty($data['conditions'][$k]['value'])){
41 $data['conditions'][$k]['value']=$_REQUEST['query'];
45 self::$quickSearch = new quicksearchQuery();
46 $result = self::$quickSearch->query($data);
47 $resultBean = $json->decodeReal($result);
48 $this->assertEquals($resultBean['fields'][0]['name'], self::$contact->first_name . ' ' . self::$contact->last_name, 'Assert that the quicksearch returns a contact name without salutation');
51 public function testPersonLocaleNameFormattting()
53 $GLOBALS['current_user']->setPreference('default_locale_name_format', 's f l');
55 self::$contact->createLocaleFormattedName = true;
56 self::$contact->_create_proper_name_field();
57 $this->assertEquals(self::$contact->name, 'Mr. Bug43395 Test', 'Assert that _create_proper_name_field with createLocaleFormattedName set to true returns salutation');
59 self::$contact->createLocaleFormattedName = false;
60 self::$contact->_create_proper_name_field();
61 $this->assertEquals(self::$contact->name, 'Bug43395 Test', 'Assert that _create_proper_name_field with createLocaleFormattedName set to false does not return salutation');