Bugzilla – Attachment 92128 Details for
Bug 23413
Add a holds routine to Koha::Items to fetch related holds
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23413: Add a holds method to Koha::Items
Bug-23413-Add-a-holds-method-to-KohaItems.patch (text/plain), 2.76 KB, created by
Katrin Fischer
on 2019-08-10 12:17:34 UTC
(
hide
)
Description:
Bug 23413: Add a holds method to Koha::Items
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2019-08-10 12:17:34 UTC
Size:
2.76 KB
patch
obsolete
>From 1a992b5ea068f14d7b7409858b6c55ab08d095da Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Thu, 1 Aug 2019 18:11:19 +0000 >Subject: [PATCH] Bug 23413: Add a holds method to Koha::Items > >To test; >1 - prove -v t/db_dependent/Koha/Items.t > >Signed-off-by: Maryse Simard <maryse.simard@inlibro.com> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > Koha/Item.pm | 17 +++++++++++++++++ > t/db_dependent/Koha/Items.t | 21 ++++++++++++++++++++- > 2 files changed, 37 insertions(+), 1 deletion(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 4bd3ba2d1c..5b270aee41 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -126,6 +126,23 @@ sub checkout { > return Koha::Checkout->_new_from_dbic( $checkout_rs ); > } > >+=head3 holds >+ >+my $transfer = $item->holds(); >+my $transfer = $item->holds($params); >+my $transfer = $item->holds({ found => 'W'}); >+ >+Return reserves attached to an item, optionally accept a hashref of params to pass to search >+ >+=cut >+ >+sub holds { >+ my ( $self,$params ) = @_; >+ my $transfer_rs = $self->_result->reserves->search($params); >+ return unless $transfer_rs->count; >+ return Koha::Holds->_new_from_dbic( $transfer_rs ); >+} >+ > =head3 get_transfer > > my $transfer = $item->get_transfer; >diff --git a/t/db_dependent/Koha/Items.t b/t/db_dependent/Koha/Items.t >index 98e51b3fec..6c1bedc1f9 100644 >--- a/t/db_dependent/Koha/Items.t >+++ b/t/db_dependent/Koha/Items.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 9; >+use Test::More tests => 10; > use Test::Exception; > > use C4::Circulation; >@@ -81,6 +81,25 @@ subtest 'get_transfer' => sub { > is( $transfer->itemnumber, $new_item_1->itemnumber, 'Koha::Item->get_transfer should return a valid Koha::Item::Transfers object' ); > }; > >+subtest 'holds' => sub { >+ plan tests => 5; >+ >+ my $biblio = $builder->build_sample_biblio(); >+ my $item = $builder->build_sample_item({ >+ biblionumber => $biblio->biblionumber, >+ }); >+ $nb_of_items++; >+ is($item->holds(), undef, "Nothing returned if no holds"); >+ my $hold1 = $builder->build({ source => 'Reserve', value => { itemnumber=>$item->itemnumber, found => 'T' }}); >+ my $hold2 = $builder->build({ source => 'Reserve', value => { itemnumber=>$item->itemnumber, found => 'W' }}); >+ my $hold3 = $builder->build({ source => 'Reserve', value => { itemnumber=>$item->itemnumber, found => 'W' }}); >+ >+ is($item->holds()->count,3,"Three holds found"); >+ is($item->holds({found => 'W'})->count,2,"Two waiting holds found"); >+ is_deeply($item->holds({found => 'T'})->next->unblessed,$hold1,"Found transit holds matches the hold"); >+ is($item->holds({found => undef}),undef,"Nothing returned if no matching holds"); >+}; >+ > subtest 'biblio' => sub { > plan tests => 2; > >-- >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 23413
:
91912
|
92123
| 92128 |
92129
|
92542
|
92543
|
92544
|
94686
|
94722