From 615cfb88c1aae1f8372b323e9c53a84d8c9146fe Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Wed, 27 Aug 2008 07:32:11 +0000 Subject: Bug 182238: Allow users to choose what time zone to display times in - Patch by Frédéric Buclin r/a=mkanat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- t/007util.t | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 't') diff --git a/t/007util.t b/t/007util.t index 18d58148b..5fc02d52c 100644 --- a/t/007util.t +++ b/t/007util.t @@ -33,11 +33,13 @@ BEGIN { use_ok(Bugzilla::Util); } -# We need to override Bugzilla->params so we can get an expected value when -# Bugzilla::Util::format_time() calls ask for the 'timezone' parameter. -# This will also prevent the tests from failing on site that do not have a -# data/params file containing 'timezone' yet. -Bugzilla->params->{'timezone'} = "TEST"; +# We need to override user preferences so we can get an expected value when +# Bugzilla::Util::format_time() calls ask for the 'timezone' user preference. +Bugzilla->user->settings->{'timezone'}->{'value'} = "local"; + +# We need to know the local timezone for the date chosen in our tests. +# Below, tests are run against Nov. 24, 2002. +my $tz = Bugzilla->local_timezone->short_name_for_datetime(DateTime->new(year => 2002, month => 11, day => 24)); # we don't test the taint functions since that's going to take some more work. # XXX: test taint functions @@ -58,7 +60,7 @@ is(lsearch(\@list,'kiwi'),-1,'lsearch 3 (missing item)'); is(trim(" fg<*\$%>+=~~ "),'fg<*$%>+=~~','trim()'); #format_time(); -is(format_time("2002.11.24 00:05"),'2002-11-24 00:05 TEST','format_time("2002.11.24 00:05")'); -is(format_time("2002.11.24 00:05:56"),'2002-11-24 00:05:56 TEST','format_time("2002.11.24 00:05:56")'); +is(format_time("2002.11.24 00:05"), "2002-11-24 00:05 $tz",'format_time("2002.11.24 00:05") is ' . format_time("2002.11.24 00:05")); +is(format_time("2002.11.24 00:05:56"), "2002-11-24 00:05:56 $tz",'format_time("2002.11.24 00:05:56")'); is(format_time("2002.11.24 00:05:56", "%Y-%m-%d %R"), '2002-11-24 00:05', 'format_time("2002.11.24 00:05:56", "%Y-%m-%d %R") (with no timezone)'); -is(format_time("2002.11.24 00:05:56", "%Y-%m-%d %R %Z"), '2002-11-24 00:05 TEST', 'format_time("2002.11.24 00:05:56", "%Y-%m-%d %R %Z") (with timezone)'); +is(format_time("2002.11.24 00:05:56", "%Y-%m-%d %R %Z"), "2002-11-24 00:05 $tz", 'format_time("2002.11.24 00:05:56", "%Y-%m-%d %R %Z") (with timezone)'); -- cgit v1.2.3-24-g4f1b