From ef14fdb18b6ef981285f17c009784c8e2d44ea8d Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 14 Apr 2022 10:19:47 +0100 Subject: [PATCH] Bug 30540: Unit test This patch adds tests for checking the output_pref method against a timezone and datetime that would cause an Invalid local time failure To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/DateUtils.t => FAIL: The feature is not implemented, tests fail to complete Signed-off-by: Nick Clemens Signed-off-by: Marcel de Rooy Signed-off-by: Fridolin Somers Signed-off-by: Kyle M Hall (cherry picked from commit 052dd948af6eaaaeeb0e83a6950543b4832aeefe) Signed-off-by: Andrew Fuerste-Henry (cherry picked from commit 3e42ca76c28e8d4a043fbf4af1e60ad14e4fae73) Signed-off-by: Victor Grousset/tuxayo --- t/DateUtils.t | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/t/DateUtils.t b/t/DateUtils.t index 5b00c77124..580c8805ef 100755 --- a/t/DateUtils.t +++ b/t/DateUtils.t @@ -4,7 +4,7 @@ use DateTime::TimeZone; use C4::Context; -use Test::More tests => 79; +use Test::More tests => 80; use Test::MockModule; use Test::Warn; @@ -209,6 +209,22 @@ $module_context->mock( $dt = dt_from_string('2014-03-30 02:00:00'); isa_ok( $dt, 'DateTime', 'dt_from_string should return a DateTime object if a DST is given' ); +# Test output_pref for invalid local time explosion +$dt = DateTime->new( + year => 2017, + month => 03, + day => 26, + hour => 01, + minute => 35, +); +$module_context->mock( + 'tz', + sub { + return DateTime::TimeZone->new( name => 'Europe/London' ); + } +); +is( output_pref( { dt => $dt, dateonly => 0 } ), '03/26/2017 01:35', 'output_pref should return even if an invalid DST time is passed' ); + # Test dt_from_string t::lib::Mocks::mock_preference('dateformat', 'metric'); t::lib::Mocks::mock_preference('TimeFormat', '24hr'); -- 2.20.1