Avoid notice of undefined index when cookie does not exist
[phpmyadmin-themes.git] / test / PMA_localisedDateTimespan_test.php
blobe472373f7d8950ea7ef68a042f29a30a383d2ab0
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Test for generating localised date or timespan expression
6 * @package phpMyAdmin-test
7 * @version $Id: PMA_localisedDateTimespan_test.php
8 */
10 /**
11 * Tests core.
13 require_once 'PHPUnit/Framework.php';
15 /**
16 * Include to test.
18 require_once './libraries/common.lib.php';
20 /**
21 * Test localised date or timespan expression.
24 class PMA_localisedDateTimespan_test extends PHPUnit_Framework_TestCase
27 /**
28 * temporary variable for globals array
31 protected $tmpGlobals;
33 /**
34 * temporary variable for session array
37 protected $tmpSession;
39 /**
40 * temporary variable for timezone info
43 protected $tmpTimezone;
45 /**
46 * storing globals and session
48 public function setUp() {
50 $this->tmpGlobals = $GLOBALS;
51 $this->tmpSession = $_SESSION;
52 $this->tmpTimezone = date_default_timezone_get();
53 date_default_timezone_set('Europe/London');
56 /**
57 * recovering globals and session
59 public function tearDown() {
61 $GLOBALS = $this->tmpGlobals;
62 $_SESSION = $this->tmpSession;
63 date_default_timezone_set($this->tmpTimezone);
67 /**
68 * data provider for localised date test
71 public function localisedDateDataProvider() {
72 return array(
73 array(1227455558, '', 'Nov 23, 2008 at 03:52 PM'),
74 array(1227455558, '%Y-%m-%d %H:%M:%S %a', '2008-11-23 15:52:38 Sun')
78 /**
79 * localised date test, globals are defined
80 * @dataProvider localisedDateDataProvider
83 public function testLocalisedDate($a, $b, $e) {
84 $this->assertEquals($e, PMA_localisedDate($a, $b));
87 /**
88 * data provider for localised timestamp test
91 public function timespanFormatDataProvider() {
92 return array(
93 array(1258, '0 days, 0 hours, 20 minutes and 58 seconds'),
94 array(821958, '9 days, 12 hours, 19 minutes and 18 seconds')
98 /**
99 * localised timestamp test, globals are defined
100 * @dataProvider timespanFormatDataProvider
103 public function testTimespanFormat($a, $e) {
104 $GLOBALS['timespanfmt'] = '%s days, %s hours, %s minutes and %s seconds';
106 $this->assertEquals($e, PMA_timespanFormat($a));