]> git.koha-community.org Git - koha.git/commit
Bug 21086: Fix wrong mock of DateTime->now
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 18 Jul 2018 21:12:17 +0000 (18:12 -0300)
committerNick Clemens <nick@bywatersolutions.com>
Thu, 19 Jul 2018 16:24:57 +0000 (16:24 +0000)
commit3c034dcc3afef792e89935a7854304d82d15c022
tree3dc538a80c630aa4c67a295da2d60608e8c20da0
parent367f47c416fa9164ccb8d9e5f50772e5a516d6b7
Bug 21086: Fix wrong mock of DateTime->now

prove t/db_dependent/DecreaseLoanHighHolds.t
t/db_dependent/DecreaseLoanHighHolds.t .. 1/17 Can't locate object method
 "truncate" via package "80" (perhaps you forgot to load "80"?) at /home/vagrant/kohaclone/C4/Circulation.pm line 3497.

What is happening:
We mock DateTime->now in the script to avoid the date comparaisons to fail on
slow servers (see bug 19705).

  my $now_value       = DateTime->now();
  my $mocked_datetime = Test::MockModule->new('DateTime');
  $mocked_datetime->mock( 'now', sub { return $now_value; } );

Since bug 20287, we have the following calls:
Koha::Patron->store => Koha::Patron::Category->get_expiry_date

which does:
221         return $date->add( months => $self->enrolmentperiod, end_of_month => 'limit' );

as enrolmentperiod is generated by t::lib::TestBuilder, it can be quite big, and so
the date change from one call to the others.

The failure is actually coming from the date becoming > 9999, which is not handled correctly,
on purpose, by Koha::DateUtils (infinite)

On the way this patch fixes the other occurrence, in Sitemapper.t (just in case)

Test plan:
Make sure the tests pass now.

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
t/db_dependent/DecreaseLoanHighHolds.t
t/db_dependent/Sitemapper.t