From 95814159bbc31d63a45d3256d2efa0145baca1cd Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 30 Nov 2016 08:09:36 +0000 Subject: [PATCH] Bug 17699: Fix negative duration calculations in tests From DateTime::Duration pod: """ For positive durations, the "end_of_month" parameter defaults to wrap. For negative durations, the default is "limit". This should match how most people "intuitively" expect datetime math to work. """ Today we are Nov 30, that means $today->subtract( months => 1 ) will return Oct 31, when we usually expect Oct 30 in tests Test plan: prove t/db_dependent/Koha/Patrons.t should return green --- t/db_dependent/Koha/Patrons.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t index 7be731c..0723346 100644 --- a/t/db_dependent/Koha/Patrons.t +++ b/t/db_dependent/Koha/Patrons.t @@ -192,7 +192,7 @@ subtest 'is_expired' => sub { subtest 'renew_account' => sub { plan tests => 10; - my $a_month_ago = dt_from_string->add( months => -1 )->truncate( to => 'day' ); + my $a_month_ago = dt_from_string->subtract( months => 1, end_of_month => 'wrap' )->truncate( to => 'day' ); my $a_year_later = dt_from_string->add( months => 12 )->truncate( to => 'day' ); my $a_year_later_minus_a_month = dt_from_string->add( months => 11 )->truncate( to => 'day' ); my $a_month_later = dt_from_string->add( months => 1 )->truncate( to => 'day' ); -- 2.1.4