]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/include/SugarObjects/PersonTemplateTest.php
Added unit tests.
[Github/sugarcrm.git] / tests / include / SugarObjects / PersonTemplateTest.php
1 <?php
2 require_once 'include/SugarObjects/templates/person/Person.php';
3
4 class PersonTemplateTest extends Sugar_PHPUnit_Framework_TestCase
5 {
6     private $_bean;
7     private $_user;
8     
9     public function setUp()
10     {
11         $this->_bean = new Person;
12         $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
13     }
14     
15     public function tearDown()
16     {
17         unset($this->_bean);
18         unset($GLOBALS['current_user']);
19         SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
20     }
21     
22     public function testNameIsReturnedAsSummaryText()
23     {
24         $GLOBALS['current_user']->setPreference('default_locale_name_format', 'l f');
25         
26         $this->_bean->first_name = 'Test';
27         $this->_bean->last_name = 'Contact';
28         $this->_bean->title = '';
29         $this->_bean->salutation = '';
30         $this->assertEquals($this->_bean->get_summary_text(),'Contact Test');
31     }
32     
33     /**
34      * @group bug38648
35      */
36     public function testNameIsReturnedAsSummaryTextWhenSalutationIsInvalid()
37     {
38         $GLOBALS['current_user']->setPreference('default_locale_name_format', 's l f');
39         
40         $this->_bean->salutation = 'Tester';
41         $this->_bean->first_name = 'Test';
42         $this->_bean->last_name = 'Contact';
43         $this->_bean->title = '';
44         $this->assertEquals($this->_bean->get_summary_text(),'Contact Test');
45     }
46 }