Bugzilla – Attachment 57332 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: Add the Koha::Patron->is_expired
Bug-17579-Add-the-KohaPatron-isexpired.patch (text/plain), 2.75 KB, created by
Jonathan Druart
on 2016-11-08 15:41:02 UTC
(
hide
)
Description:
Bug 17579: Add the Koha::Patron->is_expired
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-11-08 15:41:02 UTC
Size:
2.75 KB
patch
obsolete
>From c60a82ec70c9eb5a438694fd6611eab2c078eb8f Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 7 Nov 2016 17:12:58 +0000 >Subject: [PATCH] Bug 17579: Add the Koha::Patron->is_expired > >This new method will be handy for further uses > >Test plan: > prove t/db_dependent/Koha/Patrons.t >should return green > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >--- > Koha/Patron.pm | 16 ++++++++++++++++ > t/db_dependent/Koha/Patrons.t | 20 +++++++++++++++++++- > 2 files changed, 35 insertions(+), 1 deletion(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 27a7af8..ca78d96 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -266,6 +266,22 @@ sub is_debarred { > return; > } > >+=head2 is_expired >+ >+my $is_expired = $patron->is_expired; >+ >+Returns 1 if the patron is expired or 0; >+ >+=cut >+ >+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 0; >+} >+ > =head2 update_password > > my $updated = $patron->update_password( $userid, $password ); >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index d15e351..45387d6 100644 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 13; >+use Test::More tests => 14; > use Test::Warn; > use DateTime; > >@@ -169,6 +169,24 @@ subtest 'update_password' => sub { > is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->update_password should not have logged' ); > }; > >+subtest 'is_expired' => sub { >+ plan tests => 5; >+ my $patron = $builder->build({ source => 'Borrower' }); >+ $patron = Koha::Patrons->find( $patron->{borrowernumber} ); >+ $patron->dateexpiry( undef )->store; >+ is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is not set'); >+ $patron->dateexpiry( '0000-00-00' )->store; >+ is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is not 0000-00-00'); >+ $patron->dateexpiry( dt_from_string )->store; >+ is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is today'); >+ $patron->dateexpiry( dt_from_string->add( days => 1 ) )->store; >+ is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is tomorrow'); >+ $patron->dateexpiry( dt_from_string->add( days => -1 ) )->store; >+ is( $patron->is_expired, 1, 'Patron should be considered expired if dateexpiry is yesterday'); >+ >+ $patron->delete; >+}; >+ > subtest 'renew_account' => sub { > plan tests => 10; > my $a_month_ago = dt_from_string->add( months => -1 )->truncate( to => 'day' ); >-- >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