From d7d5e42c342651045462fbf2ccda9826de4dbb49 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 31 Mar 2015 09:56:56 +0200 Subject: [PATCH] Bug 13933: Fix t/DateUtils.t without DB If the mysql server is not running, the DateUtils.t tests failed. This is caused by commit dd9f456ab7c2f0e66173a6feb7df2a38604c82cd Bug 13601: Add tests to highlight the problems with DateTime::Format::DateParse The pref dateformat and TimeFormat were retrieved before the mock. Before bug 13601, the complete preference method was mocked, that's why the error did not appear. Test plan: sudo service mysql stop prove t/DateUtils.t should be happy --- t/DateUtils.t | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/t/DateUtils.t b/t/DateUtils.t index 1af4268..4f7c773 100755 --- a/t/DateUtils.t +++ b/t/DateUtils.t @@ -10,6 +10,9 @@ use t::lib::Mocks; BEGIN { use_ok('Koha::DateUtils'); } +t::lib::Mocks::mock_preference('dateformat', 'us'); +t::lib::Mocks::mock_preference('TimeFormat', 'This_is_not_used_but_called'); + my $tz = C4::Context->tz; isa_ok( $tz, 'DateTime::TimeZone', 'Context returns timezone object' ); @@ -26,10 +29,6 @@ $dt->set_minute(0); my $date_string; -my $module_context = new Test::MockModule('C4::Context'); - -t::lib::Mocks::mock_preference('dateformat', 'us'); - my $dateformat = C4::Context->preference('dateformat'); cmp_ok output_pref({ dt => $dt, dateformat => $dateformat }), 'eq', @@ -160,6 +159,7 @@ cmp_ok $date_string, 'eq', '12/11/2013 06:35 PM', 'as_due_date with hours and ti my $now = DateTime->now; is( dt_from_string, $now, "Without parameter, dt_from_string should return today" ); +my $module_context = new Test::MockModule('C4::Context'); $module_context->mock( 'tz', sub { -- 2.1.0