Browse Source

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 dd9f456ab7
    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

Signed-off-by: Nicolas Legrand <nicolas.legrand@bulac.fr>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
3.20.x
Jonathan Druart 9 years ago
committed by Tomas Cohen Arazi
parent
commit
85a0f6a42f
  1. 8
      t/DateUtils.t

8
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 {

Loading…
Cancel
Save