Bug 19441: Fix t/db_dependent/Biblio/Isbd.t
[koha.git] / t / db_dependent / Biblio / Isbd.t
1 #!/usr/bin/perl
2
3 # This file is part of Koha.
4 #
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18 use Modern::Perl;
19
20 use Test::More tests => 3;
21 use Test::MockModule;
22 use MARC::Record;
23 use t::lib::Mocks qw( mock_preference );
24
25 use Koha::Database;
26
27 BEGIN {
28         use_ok('C4::Biblio');
29 }
30
31 my $schema  = Koha::Database->new->schema;
32 $schema->storage->txn_begin;
33
34 my $template = '#200|<h2>Title : |{200a}{ by 200f}|</h2>';
35 my $opac_template = '#200|<h2>Title : |{200a}{ (200f)}|</h2>';
36 t::lib::Mocks::mock_preference('isbd', $template);
37 t::lib::Mocks::mock_preference('opacisbd', $opac_template);
38
39 my $record = MARC::Record->new();
40 $record->append_fields(
41     MARC::Field->new('200', '', '', 'a' => 'Mountains'),
42     MARC::Field->new('200', '', '', 'f' => 'Keith Lye'),
43 );
44
45 my ($bibnum, $title, $bibitemnum) = AddBiblio($record, '');
46 my $isbd = GetISBDView($bibnum);
47 is($isbd, '<h2>Title : Mountains by Keith Lye</h2>', 'ISBD is correct');
48
49 my $opacisbd = GetISBDView($bibnum, 'opac');
50 is($opacisbd, '<h2>Title : Mountains (Keith Lye)</h2>', 'OPAC ISBD is correct');
51
52 $schema->storage->txn_rollback;