Merge remote branch 'origin/MAINT_3_3_3' into QA_3_3
[phpmyadmin/dkf.git] / test / PMA_localisedDateTimespan_test.php
blob6c9884f0a643d5d04e27d006e6043b1b95c082b5
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Test for generating localised date or timespan expression
6 * @author Michal Biniek <michal@bystrzyca.pl>
7 * @package phpMyAdmin-test
8 * @version $Id: PMA_localisedDateTimespan_test.php
9 */
11 /**
12 * Tests core.
14 require_once 'PHPUnit/Framework.php';
16 /**
17 * Include to test.
19 require_once './libraries/common.lib.php';
21 /**
22 * Test localised date or timespan expression.
25 class PMA_localisedDateTimespan_test extends PHPUnit_Framework_TestCase
28 /**
29 * temporary variable for globals array
32 protected $tmpGlobals;
34 /**
35 * temporary variable for session array
38 protected $tmpSession;
40 /**
41 * temporary variable for timezone info
44 protected $tmpTimezone;
46 /**
47 * storing globals and session
49 public function setUp() {
51 $this->tmpGlobals = $GLOBALS;
52 $this->tmpSession = $_SESSION;
53 $this->tmpTimezone = date_default_timezone_get();
54 date_default_timezone_set('Europe/London');
57 /**
58 * recovering globals and session
60 public function tearDown() {
62 $GLOBALS = $this->tmpGlobals;
63 $_SESSION = $this->tmpSession;
64 date_default_timezone_set($this->tmpTimezone);
68 /**
69 * data provider for localised date test
72 public function localisedDateDataProvider() {
73 return array(
74 array(1227455558, '', 'Nov 23, 2008 at 03:52 PM'),
75 array(1227455558, '%Y-%m-%d %H:%M:%S %a', '2008-11-23 15:52:38 Sun')
79 /**
80 * localised date test, globals are defined
81 * @dataProvider localisedDateDataProvider
84 public function testLocalisedDate($a, $b, $e) {
85 $GLOBALS['day_of_week'] = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
86 $GLOBALS['month'] = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
87 $GLOBALS['datefmt'] = '%B %d, %Y at %I:%M %p';
89 $this->assertEquals($e, PMA_localisedDate($a, $b));
92 /**
93 * data provider for localised timestamp test
96 public function timespanFormatDataProvider() {
97 return array(
98 array(1258, '0 days, 0 hours, 20 minutes and 58 seconds'),
99 array(821958, '9 days, 12 hours, 19 minutes and 18 seconds')
104 * localised timestamp test, globals are defined
105 * @dataProvider timespanFormatDataProvider
108 public function testTimespanFormat($a, $e) {
109 $GLOBALS['timespanfmt'] = '%s days, %s hours, %s minutes and %s seconds';
111 $this->assertEquals($e, PMA_timespanFormat($a));