Bugzilla – Attachment 57498 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.72 KB, created by
Kyle M Hall (khall)
on 2016-11-15 15:27:42 UTC
(
hide
)
Description:
Bug 17579: Add the Koha::Patron->is_expired
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2016-11-15 15:27:42 UTC
Size:
2.72 KB
patch
obsolete
>From d892342e6f8569a4ea51a0e550b5d9c59b92e588 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> > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > Koha/Patron.pm | 16 ++++++++++++++++ > t/db_dependent/Koha/Patrons.t | 18 ++++++++++++++++++ > 2 files changed, 34 insertions(+) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 9867aeb..478a0cd 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -279,6 +279,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 1775bb5..692cd20 100644 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -172,6 +172,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