Bugzilla – Attachment 57884 Details for
Bug 17630
Add the Koha::Biblio->holds method
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17630: Add the Koha::Biblio->holds method
Bug-17630-Add-the-KohaBiblio-holds-method.patch (text/plain), 3.18 KB, created by
Marcel de Rooy
on 2016-12-02 08:13:38 UTC
(
hide
)
Description:
Bug 17630: Add the Koha::Biblio->holds method
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2016-12-02 08:13:38 UTC
Size:
3.18 KB
patch
obsolete
>From 47360eb450d3ac9d36504bbded826e078f65fadf Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 15 Nov 2016 11:37:30 +0000 >Subject: [PATCH] Bug 17630: Add the Koha::Biblio->holds method >Content-Type: text/plain; charset=utf-8 > >This method will be useful to get the current holds placed on a given >bibliographic record. > >Test plan: > prove t/db_dependent/Koha/Biblios.t >should return green > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > Koha/Biblio.pm | 15 ++++++++++++ > t/db_dependent/Koha/Biblios.t | 57 +++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 72 insertions(+) > create mode 100644 t/db_dependent/Koha/Biblios.t > >diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm >index 934a86a..ffded28 100644 >--- a/Koha/Biblio.pm >+++ b/Koha/Biblio.pm >@@ -249,6 +249,21 @@ sub itemtype { > return $self->_biblioitem()->itemtype(); > } > >+=head3 holds >+ >+my $holds = $biblio->holds(); >+ >+return the current holds placed on this record >+ >+=cut >+ >+sub holds { >+ my ( $self ) = @_; >+ >+ my $holds_rs = $self->_result->reserves; >+ return Koha::Holds->_new_from_dbic( $holds_rs ); >+} >+ > =head3 _biblioitem > > my $field = $self->_biblioitem()->itemtype >diff --git a/t/db_dependent/Koha/Biblios.t b/t/db_dependent/Koha/Biblios.t >new file mode 100644 >index 0000000..2498b86 >--- /dev/null >+++ b/t/db_dependent/Koha/Biblios.t >@@ -0,0 +1,57 @@ >+#!/usr/bin/perl >+ >+# Copyright 2016 Koha Development team >+# >+# This file is part of Koha >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Test::More tests => 1; >+ >+use C4::Reserves; >+ >+use Koha::Biblios; >+use Koha::Patrons; >+use t::lib::TestBuilder; >+use t::lib::Mocks; >+ >+my $schema = Koha::Database->new->schema; >+$schema->storage->txn_begin; >+ >+my $builder = t::lib::TestBuilder->new; >+my $patron = $builder->build( { source => 'Borrower' } ); >+$patron = Koha::Patrons->find( $patron->{borrowernumber} ); >+ >+my $biblio = Koha::Biblio->new()->store(); >+ >+my $biblioitem = $schema->resultset('Biblioitem')->new( >+ { >+ biblionumber => $biblio->id >+ } >+)->insert(); >+ >+subtest 'holds' => sub { >+ plan tests => 3; >+ C4::Reserves::AddReserve( $patron->branchcode, $patron->borrowernumber, $biblio->biblionumber ); >+ my $holds = $biblio->holds; >+ is( ref($holds), 'Koha::Holds', '->holds should return a Koha::Holds object' ); >+ is( $holds->count, 1, '->holds should only return 1 hold' ); >+ is( $holds->next->borrowernumber, $patron->borrowernumber, '->holds should return the correct hold' ); >+}; >+ >+$schema->storage->txn_rollback; >+ >+1; >-- >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 17630
:
57491
|
57644
|
57884
|
58012