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
60 public function localisedDateDataProvider() {
62 array(1227455558, '', 'Nov 23, 2008 at 03:52 PM'),
63 array(1227455558, '%Y-%m-%d %H:%M:%S %a', '2008-11-23 15:52:38 Sun')
68 * localised date test, globals are defined
69 * @dataProvider localisedDateDataProvider
71 public function testLocalisedDate($a, $b, $e) {
72 $this->assertEquals($e, PMA_localisedDate($a, $b));
76 * data provider for localised timestamp test
80 public function timespanFormatDataProvider() {
82 array(1258, '0 days, 0 hours, 20 minutes and 58 seconds'),
83 array(821958, '9 days, 12 hours, 19 minutes and 18 seconds')
88 * localised timestamp test, globals are defined
89 * @dataProvider timespanFormatDataProvider
91 public function testTimespanFormat($a, $e) {
92 $GLOBALS['timespanfmt'] = '%s days, %s hours, %s minutes and %s seconds';
94 $this->assertEquals($e, PMA_timespanFormat($a));