2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Test for generating localised date or timespan expression
6 * @package phpMyAdmin-test
7 * @version $Id: PMA_localisedDateTimespan_test.php
8 * @group common.lib-tests
14 require_once 'libraries/common.lib.php';
16 class PMA_localisedDateTimespan_test
extends PHPUnit_Framework_TestCase
19 * temporary variable for globals array
21 protected $tmpGlobals;
24 * temporary variable for session array
26 protected $tmpSession;
29 * temporary variable for timezone info
31 protected $tmpTimezone;
34 * storing globals and session
36 public function setUp() {
38 $this->tmpGlobals
= $GLOBALS;
39 $this->tmpSession
= $_SESSION;
40 $this->tmpTimezone
= date_default_timezone_get();
41 date_default_timezone_set('Europe/London');
45 * recovering globals and session
47 public function tearDown() {
49 $GLOBALS = $this->tmpGlobals
;
50 $_SESSION = $this->tmpSession
;
51 date_default_timezone_set($this->tmpTimezone
);
56 * data provider for localised date test
58 public function localisedDateDataProvider() {
60 array(1227455558, '', 'Nov 23, 2008 at 03:52 PM'),
61 array(1227455558, '%Y-%m-%d %H:%M:%S %a', '2008-11-23 15:52:38 Sun')
66 * localised date test, globals are defined
67 * @dataProvider localisedDateDataProvider
69 public function testLocalisedDate($a, $b, $e) {
70 $this->assertEquals($e, PMA_localisedDate($a, $b));
74 * data provider for localised timestamp test
77 public function timespanFormatDataProvider() {
79 array(1258, '0 days, 0 hours, 20 minutes and 58 seconds'),
80 array(821958, '9 days, 12 hours, 19 minutes and 18 seconds')
85 * localised timestamp test, globals are defined
86 * @dataProvider timespanFormatDataProvider
88 public function testTimespanFormat($a, $e) {
89 $GLOBALS['timespanfmt'] = '%s days, %s hours, %s minutes and %s seconds';
91 $this->assertEquals($e, PMA_timespanFormat($a));