Bugzilla – Attachment 58014 Details for
Bug 17740
Add the Koha::Patron->holds method
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17740: Add the Koha::Patron->holds method
Bug-17740-Add-the-KohaPatron-holds-method.patch (text/plain), 3.63 KB, created by
Jonathan Druart
on 2016-12-07 16:12:39 UTC
(
hide
)
Description:
Bug 17740: Add the Koha::Patron->holds method
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-12-07 16:12:39 UTC
Size:
3.63 KB
patch
obsolete
>From 3fbc9a81e87610807c99ac12d96e7919abd80bce Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 7 Dec 2016 14:42:41 +0100 >Subject: [PATCH] Bug 17740: Add the Koha::Patron->holds method > >The goal of this method is to replace >C4::Reserves::GetReservesFromBorrowernumber but could be reused for >something else, that's why it has its own bug report. > >Test plan: > prove t/db_dependent/Koha/Patrons.t >should return green >--- > Koha/Patron.pm | 14 ++++++++++ > t/db_dependent/Koha/Patrons.t | 64 ++++++++++++++++++++++++++++++++++++++++++- > 2 files changed, 77 insertions(+), 1 deletion(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index a40d6f0..fe7fca5 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -519,6 +519,20 @@ sub get_overdues { > return $issues; > } > >+=head3 holds >+ >+my $holds = $patron->holds >+ >+Return all the holds placed by this patron >+ >+=cut >+ >+sub holds { >+ my ($self) = @_; >+ my $holds_rs = $self->_result->reserves->search( {}, { order_by => 'reservedate' } ); >+ return Koha::Holds->_new_from_dbic($holds_rs); >+} >+ > =head3 type > > =cut >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index a96cdc1..010bf79 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 => 15; >+use Test::More tests => 16; > use Test::Warn; > use DateTime; > >@@ -471,6 +471,68 @@ subtest 'get_overdues' => sub { > $patron->delete; > }; > >+subtest 'holds' => sub { >+ plan tests => 3; >+ >+ my $library = $builder->build( { source => 'Branch' } ); >+ my ($biblionumber_1) = AddBiblio( MARC::Record->new, '' ); >+ my $item_1 = $builder->build( >+ { >+ source => 'Item', >+ value => { >+ homebranch => $library->{branchcode}, >+ holdingbranch => $library->{branchcode}, >+ biblionumber => $biblionumber_1 >+ } >+ } >+ ); >+ my $item_2 = $builder->build( >+ { >+ source => 'Item', >+ value => { >+ homebranch => $library->{branchcode}, >+ holdingbranch => $library->{branchcode}, >+ biblionumber => $biblionumber_1 >+ } >+ } >+ ); >+ my ($biblionumber_2) = AddBiblio( MARC::Record->new, '' ); >+ my $item_3 = $builder->build( >+ { >+ source => 'Item', >+ value => { >+ homebranch => $library->{branchcode}, >+ holdingbranch => $library->{branchcode}, >+ biblionumber => $biblionumber_2 >+ } >+ } >+ ); >+ my $patron = $builder->build( >+ { >+ source => 'Borrower', >+ value => { branchcode => $library->{branchcode} } >+ } >+ ); >+ >+ $patron = Koha::Patrons->find( $patron->{borrowernumber} ); >+ my $holds = $patron->holds; >+ is( ref($holds), 'Koha::Holds', >+ 'Koha::Patron->holds should return a Koha::Holds objects' ); >+ is( $holds->count, 0, 'There should not have holds placed by this patron yet' ); >+ >+ C4::Reserves::AddReserve( $library->{branchcode}, >+ $patron->borrowernumber, $biblionumber_1 ); >+ # In the future >+ C4::Reserves::AddReserve( $library->{branchcode}, >+ $patron->borrowernumber, $biblionumber_2, undef, undef, dt_from_string->add( days => 2 ) ); >+ >+ $holds = $patron->holds; >+ is( $holds->count, 2, 'There should have 2 holds placed by this patron' ); >+ >+ $holds->delete; >+ $patron->delete; >+}; >+ > $retrieved_patron_1->delete; > is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); > >-- >2.9.3
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 17740
:
58014
|
58035
|
58626