3 # This file is part of Koha.
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.
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.
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>.
20 use Test
::More tests
=> 2;
28 subtest
'GetMarcNotes MARC21' => sub {
30 t
::lib
::Mocks
::mock_preference
( 'NotesToHide', '520' );
32 my $record = MARC
::Record
->new;
33 $record->append_fields(
34 MARC
::Field
->new( '500', '', '', a
=> 'Note1' ),
35 MARC
::Field
->new( '505', '', '', a
=> 'Note2', u
=> 'http://someserver.com' ),
36 MARC
::Field
->new( '520', '', '', a
=> 'Note3 skipped' ),
37 MARC
::Field
->new( '541', '0', '', a
=> 'Note4 skipped on opac' ),
38 MARC
::Field
->new( '541', '', '', a
=> 'Note5' ),
40 my $notes = C4
::Biblio
::GetMarcNotes
( $record, 'MARC21' );
41 is
( $notes->[0]->{marcnote
}, 'Note1', 'First note' );
42 is
( $notes->[1]->{marcnote
}, 'Note2', 'Second note' );
43 is
( $notes->[2]->{marcnote
}, 'http://someserver.com', 'URL separated' );
44 is
( $notes->[3]->{marcnote
}, 'Note4 skipped on opac',"Not shows if not opac" );
45 is
( $notes->[4]->{marcnote
}, 'Note5', 'Fifth note' );
46 is
( @
$notes, 5, 'No more notes' );
47 $notes = C4
::Biblio
::GetMarcNotes
( $record, 'MARC21', 1 );
48 is
( $notes->[0]->{marcnote
}, 'Note1', 'First note' );
49 is
( $notes->[1]->{marcnote
}, 'Note2', 'Second note' );
50 is
( $notes->[2]->{marcnote
}, 'http://someserver.com', 'URL separated' );
51 is
( $notes->[3]->{marcnote
}, 'Note5', 'Fifth note shows after fourth skipped' );
52 is
( @
$notes, 4, 'No more notes' );
56 subtest
'GetMarcNotes UNIMARC' => sub {
58 t
::lib
::Mocks
::mock_preference
( 'NotesToHide', '310' );
60 my $record = MARC
::Record
->new;
61 $record->append_fields(
62 MARC
::Field
->new( '300', '', '', a
=> 'Note1' ),
63 MARC
::Field
->new( '300', '', '', a
=> 'Note2' ),
64 MARC
::Field
->new( '310', '', '', a
=> 'Note3 skipped' ),
66 my $notes = C4
::Biblio
::GetMarcNotes
( $record, 'UNIMARC' );
67 is
( $notes->[0]->{marcnote
}, 'Note1', 'First note' );
68 is
( $notes->[1]->{marcnote
}, 'Note2', 'Second note' );
69 is
( @
$notes, 2, 'No more notes' );