Bugzilla – Attachment 77098 Details for
Bug 21086
Wrong mock of DateTime->now in tests
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21086: Fix wrong mock of DateTime->now
Bug-21086-Fix-wrong-mock-of-DateTime-now.patch (text/plain), 2.60 KB, created by
Katrin Fischer
on 2018-07-19 06:04:40 UTC
(
hide
)
Description:
Bug 21086: Fix wrong mock of DateTime->now
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2018-07-19 06:04:40 UTC
Size:
2.60 KB
patch
obsolete
>From b0db2d7dc6d2343eb14740bcb81829ca0cc750cb Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 18 Jul 2018 18:12:17 -0300 >Subject: [PATCH] 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> >--- > t/db_dependent/DecreaseLoanHighHolds.t | 2 +- > t/db_dependent/Sitemapper.t | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/DecreaseLoanHighHolds.t b/t/db_dependent/DecreaseLoanHighHolds.t >index b35dbfd..a85048f 100755 >--- a/t/db_dependent/DecreaseLoanHighHolds.t >+++ b/t/db_dependent/DecreaseLoanHighHolds.t >@@ -45,7 +45,7 @@ $dbh->do('DELETE FROM items'); > > my $now_value = DateTime->now(); > my $mocked_datetime = Test::MockModule->new('DateTime'); >-$mocked_datetime->mock( 'now', sub { return $now_value; } ); >+$mocked_datetime->mock( 'now', sub { return $now_value->clone; } ); > > my $library = $builder->build( { source => 'Branch' } ); > my $category = $builder->build( { source => 'Category' } ); >diff --git a/t/db_dependent/Sitemapper.t b/t/db_dependent/Sitemapper.t >index bf2576b..a4cbcac 100755 >--- a/t/db_dependent/Sitemapper.t >+++ b/t/db_dependent/Sitemapper.t >@@ -34,7 +34,7 @@ BEGIN { > > my $now_value = DateTime->now(); > my $mocked_datetime = Test::MockModule->new('DateTime'); >-$mocked_datetime->mock( 'now', sub { return $now_value; } ); >+$mocked_datetime->mock( 'now', sub { return $now_value->clone; } ); > > sub slurp { > my $file = shift; >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 21086
:
77093
|
77098
|
77101