Bugzilla – Attachment 57499 Details for
Bug 17579
Add the Koha::Patron->is_expired method
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17579: Make sure we are testing the real life
Bug-17579-Make-sure-we-are-testing-the-real-life.patch (text/plain), 2.95 KB, created by
Kyle M Hall (khall)
on 2016-11-15 15:27:50 UTC
(
hide
)
Description:
Bug 17579: Make sure we are testing the real life
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2016-11-15 15:27:50 UTC
Size:
2.95 KB
patch
obsolete
>From ea3704203e88382024837c5caa2c264a153a3cf0 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 9 Nov 2016 13:23:54 +0000 >Subject: [PATCH] Bug 17579: Make sure we are testing the real life > >Without this patch, the tests are not testing the same things as what >happens on the interface. >We need to refresh the object to make sure the date set into dateexpiry >is the one in DB. >Without this patch, ->is_expired test a datetime object, with this patch >it compares with a date oject > >Without the changes made in Koha::Patron->is_expired, a patron which has >a dateexpiry set to today was marked as expired on the interface. This >is a change in the behavior, what this refactoring does not want to do. > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > Koha/Patron.pm | 2 +- > t/db_dependent/Koha/Patrons.t | 10 +++++----- > 2 files changed, 6 insertions(+), 6 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 478a0cd..c05dbd2 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -291,7 +291,7 @@ sub is_expired { > my ($self) = @_; > return 0 unless $self->dateexpiry; > return 0 if $self->dateexpiry eq '0000-00-00'; >- return 1 if dt_from_string( $self->dateexpiry ) < dt_from_string; >+ return 1 if dt_from_string( $self->dateexpiry ) < dt_from_string->truncate( to => 'day' ); > return 0; > } > >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index 692cd20..9108f1a 100644 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -176,15 +176,15 @@ subtest 'is_expired' => sub { > plan tests => 5; > my $patron = $builder->build({ source => 'Borrower' }); > $patron = Koha::Patrons->find( $patron->{borrowernumber} ); >- $patron->dateexpiry( undef )->store; >+ $patron->dateexpiry( undef )->store->discard_changes; > is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is not set'); >- $patron->dateexpiry( '0000-00-00' )->store; >+ $patron->dateexpiry( '0000-00-00' )->store->discard_changes; > is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is not 0000-00-00'); >- $patron->dateexpiry( dt_from_string )->store; >+ $patron->dateexpiry( dt_from_string )->store->discard_changes; > is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is today'); >- $patron->dateexpiry( dt_from_string->add( days => 1 ) )->store; >+ $patron->dateexpiry( dt_from_string->add( days => 1 ) )->store->discard_changes; > is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is tomorrow'); >- $patron->dateexpiry( dt_from_string->add( days => -1 ) )->store; >+ $patron->dateexpiry( dt_from_string->add( days => -1 ) )->store->discard_changes; > is( $patron->is_expired, 1, 'Patron should be considered expired if dateexpiry is yesterday'); > > $patron->delete; >-- >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 17579
:
57297
|
57320
|
57332
|
57386
|
57411
|
57412
|
57475
|
57476
|
57498
| 57499 |
57500