2 require_once('include/SugarFields/Fields/Relate/SugarFieldRelate.php');
4 class SugarFieldRelateTest extends Sugar_PHPUnit_Framework_TestCase
6 public function setUp()
8 $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
11 public function tearDown()
13 SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
14 unset($GLOBALS['current_user']);
17 public function testFormatContactNameWithFirstName()
19 $GLOBALS['current_user']->setPreference('default_locale_name_format','l f');
21 $vardef = array('name' => 'contact_name');
22 $value = 'John Mertic';
24 $sfr = new SugarFieldRelate('relate');
27 $sfr->formatField($value,$vardef),
35 public function testFormatContactNameWithoutFirstName()
37 $GLOBALS['current_user']->setPreference('default_locale_name_format','l f');
39 $vardef = array('name' => 'contact_name');
42 $sfr = new SugarFieldRelate('relate');
45 trim($sfr->formatField($value,$vardef)),
53 public function testFormatContactNameThatIsEmpty()
55 $GLOBALS['current_user']->setPreference('default_locale_name_format','l f');
57 $vardef = array('name' => 'contact_name');
60 $sfr = new SugarFieldRelate('relate');
63 trim($sfr->formatField($value,$vardef)),
68 public function testFormatOtherField()
70 $GLOBALS['current_user']->setPreference('default_locale_name_format','l f');
72 $vardef = array('name' => 'account_name');
73 $value = 'John Mertic';
75 $sfr = new SugarFieldRelate('relate');
78 $sfr->formatField($value,$vardef),
86 public function testGetSearchViewSmarty(){
88 'name' => 'assigned_user_id',
89 'rname' => 'user_name',
90 'id_name' => 'assigned_user_id',
91 'vname' => 'LBL_ASSIGNED_TO_ID',
92 'group'=>'assigned_user_name',
100 'comment' => 'User ID assigned to record',
101 'duplicate_merge'=>'disabled'
103 $displayParams = array();
104 $sfr = new SugarFieldRelate('relate');
105 $output = $sfr->getSearchViewSmarty(array(), $vardef, $displayParams, 0);
106 $this->assertContains('name="{$Array.assigned_user_id', $output, 'Testing that the name property is in the form for thr assigned_user_id field');
109 'name' => 'account_name',
111 'id_name' => 'account_id',
112 'vname' => 'LBL_ACCOUNT_NAME',
114 'table' => 'accounts',
115 'join_name'=>'accounts',
117 'module' => 'Accounts',
118 'dbType' => 'varchar',
122 'unified_search' => true,
124 'importable' => 'required',
127 $displayParams = array();
128 $sfr = new SugarFieldRelate('relate');
129 $output = $sfr->getSearchViewSmarty(array(), $vardef, $displayParams, 0);
130 $this->assertNotContains('name="{$Array.account_id', $output, 'Testing that the name property for account_id is not in the form.');