]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/include/SugarFields/Fields/Datetimecombo/Bug41114Test.php
Release 6.1.5
[Github/sugarcrm.git] / tests / include / SugarFields / Fields / Datetimecombo / Bug41114Test.php
1 <?php 
2 require_once('include/SugarFields/Fields/Relate/SugarFieldRelate.php');
3
4 class Bug41114Test extends Sugar_PHPUnit_Framework_TestCase
5 {
6         public function setUp()
7     {
8         $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
9         }
10
11     public function tearDown()
12     {
13         SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
14         unset($GLOBALS['current_user']);
15     }
16     
17     public function _providerEmailTemplateFormat()
18     {
19         return array(
20             array('2010-10-10 13:00:00','2010/10/10 01:00PM', 'Y/m/d', 'h:iA' ),
21             array('2010-10-11 13:00:00','2010/10/11 13:00', 'Y/m/d', 'H:i' ),
22             
23             array('2011-03-25 01:05:22','25.03.2011 01:05AM', 'd.m.Y', 'h:iA'),
24             array('2011-04-21 01:05:22','21.04.2011 01:05', 'd.m.Y', 'H:i'),
25             
26             array('','', 'Y-m-d', 'h:iA'),
27             array('','', 'Y-m-d', 'H:i'),
28             
29         );   
30     }
31      /**
32      * @dataProvider _providerEmailTemplateFormat
33      */
34         public function testEmailTemplateFormat($unformattedValue, $expectedValue, $dateFormat, $timeFormat)
35         {
36             $GLOBALS['sugar_config']['default_date_format'] = $dateFormat;
37                 $GLOBALS['sugar_config']['default_time_format'] = $timeFormat;
38                 
39         require_once('include/SugarFields/SugarFieldHandler.php');
40                 $sfr = SugarFieldHandler::getSugarField('datetimecombo');
41         $formattedValue = $sfr->getEmailTemplateValue($unformattedValue,array());
42         
43                 $this->assertEquals($expectedValue, $formattedValue);
44     }
45 }