Bugzilla – Attachment 72292 Details for
Bug 20311
get_age tests can fail on February 28th
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20311: Prevent get_age tests to fail on Feb 28th
Bug-20311-Prevent-getage-tests-to-fail-on-Feb-28th.patch (text/plain), 2.64 KB, created by
Jonathan Druart
on 2018-02-28 17:02:10 UTC
(
hide
)
Description:
Bug 20311: Prevent get_age tests to fail on Feb 28th
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2018-02-28 17:02:10 UTC
Size:
2.64 KB
patch
obsolete
>From ecef25e72d23b0f4b6bbc03af38f227718bd92a4 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 28 Feb 2018 13:54:32 -0300 >Subject: [PATCH] Bug 20311: Prevent get_age tests to fail on Feb 28th > >Today Feb 28th 2018: >If we subtract 18y to this DateTime object 29/02/2000 and so the patron is not major yet > >use Koha::DateUtils qw( dt_from_string ); >say dt_from_string('28/02/2018')->add(years => -18); >say dt_from_string('28/02/2018')->add(years => -18, end_of_month => 'limit'); > >will display: >2000-02-29T00:00:00 >2000-02-28T00:00:00 >--- > t/db_dependent/Koha/Patrons.t | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index 7ad7d05674..2323d2174d 100644 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -528,17 +528,17 @@ subtest 'get_age' => sub { > > $patron->dateofbirth( undef ); > is( $patron->get_age, undef, 'get_age should return undef if no dateofbirth is defined' ); >- $patron->dateofbirth( $today->clone->add( years => -12, months => -6, days => -1 ) ); >+ $patron->dateofbirth( $today->clone->add( years => -12, months => -6, days => -1, end_of_month => 'limit' ) ); > is( $patron->get_age, 12, 'Patron should be 12' ); >- $patron->dateofbirth( $today->clone->add( years => -18, months => 0, days => 1 ) ); >+ $patron->dateofbirth( $today->clone->add( years => -18, months => 0, days => 1, end_of_month => 'limit' ) ); > is( $patron->get_age, 17, 'Patron should be 17, happy birthday tomorrow!' ); >- $patron->dateofbirth( $today->clone->add( years => -18, months => 0, days => 0 ) ); >+ $patron->dateofbirth( $today->clone->add( years => -18, months => 0, days => 0, end_of_month => 'limit' ) ); > is( $patron->get_age, 18, 'Patron should be 18' ); >- $patron->dateofbirth( $today->clone->add( years => -18, months => -12, days => -31 ) ); >+ $patron->dateofbirth( $today->clone->add( years => -18, months => -12, days => -31, end_of_month => 'limit' ) ); > is( $patron->get_age, 19, 'Patron should be 19' ); >- $patron->dateofbirth( $today->clone->add( years => -18, months => -12, days => -30 ) ); >+ $patron->dateofbirth( $today->clone->add( years => -18, months => -12, days => -30, end_of_month => 'limit' ) ); > is( $patron->get_age, 19, 'Patron should be 19 again' ); >- $patron->dateofbirth( $today->clone->add( years => 0, months => -1, days => -1 ) ); >+ $patron->dateofbirth( $today->clone->add( years => 0, months => -1, days => -1, end_of_month => 'limit' ) ); > is( $patron->get_age, 0, 'Patron is a newborn child' ); > > $patron->delete; >-- >2.11.0
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 20311
: 72292