Bugzilla – Attachment 84093 Details for
Bug 22144
Add method metadata() to Koha::Biblio
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22144: Add method marc() to Koha::Biblio
Bug-22144-Add-method-marc-to-KohaBiblio.patch (text/plain), 3.35 KB, created by
terahuitunua
on 2019-01-16 21:02:30 UTC
(
hide
)
Description:
Bug 22144: Add method marc() to Koha::Biblio
Filename:
MIME Type:
Creator:
terahuitunua
Created:
2019-01-16 21:02:30 UTC
Size:
3.35 KB
patch
obsolete
>From bec981da9be8704085299f575556218899f00b70 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Wed, 16 Jan 2019 14:25:07 -0500 >Subject: [PATCH] Bug 22144: Add method marc() to Koha::Biblio > >It would be very convenient to be able to retrieve a bib's MARC::Record object directly from biblio object. This would be very useful for Template Toolkit syntax in slips and notices where a library would like to use arbitrary MARC fields that aren't stored in the database. > >Test Plan: >1) Apply this patch >2) prove t/db_dependent/Koha/Biblio.t > >Signed-off-by: Te Rahui Tunua <terahuitunua@catalyst.net.nz> >--- > Koha/Biblio.pm | 21 ++++++++++++++++ > t/db_dependent/Koha/Biblio.t | 57 ++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 78 insertions(+) > create mode 100755 t/db_dependent/Koha/Biblio.t > >diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm >index 1dca4d9cf6..8ce19ef02d 100644 >--- a/Koha/Biblio.pm >+++ b/Koha/Biblio.pm >@@ -61,6 +61,27 @@ sub store { > return $self->SUPER::store; > } > >+=head3 marc >+ >+my @marc = $biblio->marc($params); >+ >+Returns a MARC::Record object for a record. >+ >+This method accepts the same paramters as C4::Biblio::GetMarcBiblio, >+but does not require the 'biblionumber' parameter. >+ >+=cut >+ >+sub marc { >+ my ( $self, $params ) = @_; >+ >+ $params->{biblionumber} = $self->id; >+ >+ my $marc = C4::Biblio::GetMarcBiblio($params); >+ >+ return $marc; >+} >+ > =head3 subtitles > > my @subtitles = $biblio->subtitles(); >diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t >new file mode 100755 >index 0000000000..9834bbe503 >--- /dev/null >+++ b/t/db_dependent/Koha/Biblio.t >@@ -0,0 +1,57 @@ >+#!/usr/bin/perl >+ >+# 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 => 3; >+use Test::MockModule; >+use MARC::Record; >+ >+use t::lib::TestBuilder; >+ >+use C4::Biblio; >+use Koha::Database; >+ >+BEGIN { >+ use_ok('Koha::Biblio'); >+ use_ok('Koha::Biblios'); >+} >+ >+my $schema = Koha::Database->new->schema; >+$schema->storage->txn_begin; >+my $dbh = C4::Context->dbh; >+ >+subtest 'MarcFieldForCreatorAndModifier' => sub { >+ plan tests => 3; >+ >+ my $title = 'Oranges and Peaches'; >+ >+ my $record = MARC::Record->new(); >+ my $field = MARC::Field->new('245','','','a' => $title); >+ $record->append_fields( $field ); >+ my ($biblionumber) = C4::Biblio::AddBiblio($record, ''); >+ >+ my $biblio = Koha::Biblios->find( $biblionumber ); >+ is( ref $biblio, 'Koha::Biblio', 'Found a Koha::Biblio object' ); >+ >+ my $marc = $biblio->marc(); >+ is( ref $marc, 'MARC::Record', 'Method marc() returned a MARC::Record object' ); >+ >+ is( $marc->field('245')->subfield("a"), $title, 'Title in 245$a matches title from original record object' ); >+}; >+ >+$schema->storage->txn_rollback; >-- >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 22144
:
84076
|
84093
|
84137
|
84205
|
84343
|
84344
|
84345
|
84346
|
84350
|
84351