Fixed: Not selecting a datalabel used to issue a notice(undefined offset)
[phpmyadmin/ammaryasirr.git] / test / libraries / common / PMA_localisedDateTimespan_test.php
blob4ed29093e31150dbcc8a0499509dfa991a5820d0
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 * @group common.lib-tests
9 */
12 * Include to test.
14 require_once 'libraries/common.lib.php';
16 class PMA_localisedDateTimespan_test extends PHPUnit_Framework_TestCase
18 /**
19 * temporary variable for globals array
21 protected $tmpGlobals;
23 /**
24 * temporary variable for session array
26 protected $tmpSession;
28 /**
29 * temporary variable for timezone info
31 protected $tmpTimezone;
33 /**
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');
44 /**
45 * recovering globals and session
47 public function tearDown() {
49 $GLOBALS = $this->tmpGlobals;
50 $_SESSION = $this->tmpSession;
51 date_default_timezone_set($this->tmpTimezone);
55 /**
56 * data provider for localised date test
58 * @return array
60 public function localisedDateDataProvider() {
61 return array(
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')
67 /**
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));
75 /**
76 * data provider for localised timestamp test
78 * @return array
80 public function timespanFormatDataProvider() {
81 return array(
82 array(1258, '0 days, 0 hours, 20 minutes and 58 seconds'),
83 array(821958, '9 days, 12 hours, 19 minutes and 18 seconds')
87 /**
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));