2 /* vim: set expandtab sw=4 ts=4 sts=4: */
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
14 require_once 'PHPUnit/Framework.php';
19 require_once './libraries/common.lib.php';
22 * Test localised date or timespan expression.
25 class PMA_localisedDateTimespan_test
extends PHPUnit_Framework_TestCase
29 * temporary variable for globals array
32 protected $tmpGlobals;
35 * temporary variable for session array
38 protected $tmpSession;
41 * temporary variable for timezone info
44 protected $tmpTimezone;
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');
58 * recovering globals and session
60 public function tearDown() {
62 $GLOBALS = $this->tmpGlobals
;
63 $_SESSION = $this->tmpSession
;
64 date_default_timezone_set($this->tmpTimezone
);
69 * data provider for localised date test
72 public function localisedDateDataProvider() {
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')
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));
93 * data provider for localised timestamp test
96 public function timespanFormatDataProvider() {
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));