@@ -, +, @@ --- C4/Biblio.pm | 3 ++- t/Biblio/Isbd.t | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 t/Biblio/Isbd.t --- a/C4/Biblio.pm +++ a/C4/Biblio.pm @@ -924,12 +924,13 @@ Return the ISBD view which can be included in opac and intranet sub GetISBDView { my ( $biblionumber, $template ) = @_; my $record = GetMarcBiblio($biblionumber, 1); + my $sysprefname = $template eq 'opac' ? 'opacisbd' : 'isbd'; return unless defined $record; my $itemtype = &GetFrameworkCode($biblionumber); my ( $holdingbrtagf, $holdingbrtagsubf ) = &GetMarcFromKohaField( "items.holdingbranch", $itemtype ); my $tagslib = &GetMarcStructure( 1, $itemtype ); - my $ISBD = C4::Context->preference('isbd'); + my $ISBD = C4::Context->preference($sysprefname); my $bloc = $ISBD; my $res; my $blocres; --- a/t/Biblio/Isbd.t +++ a/t/Biblio/Isbd.t @@ -0,0 +1,50 @@ +#!/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 . + +use Modern::Perl; + +use Test::More tests => 3; +use Test::MockModule; +use MARC::Record; +use t::lib::Mocks qw( mock_preference ); + +BEGIN { + use_ok('C4::Biblio'); +} + +my $dbh = C4::Context->dbh; +# Start transaction +$dbh->{AutoCommit} = 0; +$dbh->{RaiseError} = 1; + +my $template = '#200|

Title : |{200a}{ by 200f}|

'; +my $opac_template = '#200|

Title : |{200a}{ (200f)}|

'; +t::lib::Mocks::mock_preference('isbd', $template); +t::lib::Mocks::mock_preference('opacisbd', $opac_template); + +my $record = MARC::Record->new(); +$record->append_fields( + MARC::Field->new('200', '', '', 'a' => 'Montains'), + MARC::Field->new('200', '', '', 'f' => 'Keith Lye'), +); +my ($bibnum, $title, $bibitemnum) = AddBiblio($record, ''); + +my $isbd = GetISBDView($bibnum); +is($isbd, '

Title : Montains by Keith Lye

', 'ISBD is correct'); + +my $opacisbd = GetISBDView($bibnum, 'opac'); +is($opacisbd, '

Title : Montains (Keith Lye)

', 'OPAC ISBD is correct'); --