aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorNils Adermann <naderman@naderman.de>2012-07-19 08:46:25 -0700
committerNils Adermann <naderman@naderman.de>2012-07-19 08:46:25 -0700
commit737828f00911ba145697ef4060401e50e5b711af (patch)
tree4ec7097ac7c5ffeb3b00c62d09ce9d5955a5c5d8 /tests
parentc896cd06dd8fba023e2ab6f9cd3f8293d382fb70 (diff)
parent7df1c84447903ecc97a8418339ec6933bdfc9035 (diff)
downloadforums-737828f00911ba145697ef4060401e50e5b711af.tar
forums-737828f00911ba145697ef4060401e50e5b711af.tar.gz
forums-737828f00911ba145697ef4060401e50e5b711af.tar.bz2
forums-737828f00911ba145697ef4060401e50e5b711af.tar.xz
forums-737828f00911ba145697ef4060401e50e5b711af.zip
Merge pull request #843 from nickvergessen/feature/new-tz-handling
Feature/new tz handling
Diffstat (limited to 'tests')
-rw-r--r--tests/datetime/from_format_test.php57
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/datetime/from_format_test.php b/tests/datetime/from_format_test.php
new file mode 100644
index 0000000000..c28925272e
--- /dev/null
+++ b/tests/datetime/from_format_test.php
@@ -0,0 +1,57 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+require_once dirname(__FILE__) . '/../../phpBB/includes/session.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/user.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/datetime.php';
+require_once dirname(__FILE__) . '/../mock/lang.php';
+
+class phpbb_datetime_from_format_test extends phpbb_test_case
+{
+ public function from_format_data()
+ {
+ return array(
+ array(
+ 'UTC',
+ 'Y-m-d',
+ '2012-06-08',
+ ),
+
+ array(
+ 'Europe/Berlin',
+ 'Y-m-d H:i:s',
+ '2012-06-08 14:01:02',
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider from_format_data()
+ */
+ public function test_from_format($timezone, $format, $expected)
+ {
+ global $user;
+
+ $user = new phpbb_user();
+ $user->timezone = new DateTimeZone($timezone);
+ $user->lang['datetime'] = array(
+ 'TODAY' => 'Today',
+ 'TOMORROW' => 'Tomorrow',
+ 'YESTERDAY' => 'Yesterday',
+ 'AGO' => array(
+ 0 => 'less than a minute ago',
+ 1 => '%d minute ago',
+ 2 => '%d minutes ago',
+ ),
+ );
+
+ $timestamp = $user->get_timestamp_from_format($format, $expected, new DateTimeZone($timezone));
+ $this->assertEquals($expected, $user->format_date($timestamp, $format, true));
+ }
+}