Bug 27205: Check valid pickup location on PUT /holds/:hold_id
[koha.git] / t / Biblio / GetMarcNotes.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 => 2;
21 use t::lib::Mocks;
22
23 use MARC::Field;
24 use MARC::Record;
25
26 use C4::Biblio;
27
28 subtest 'GetMarcNotes MARC21' => sub {
29     plan tests => 11;
30     t::lib::Mocks::mock_preference( 'NotesToHide', '520' );
31
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' ),
39     );
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' );
53
54 };
55
56 subtest 'GetMarcNotes UNIMARC' => sub {
57     plan tests => 3;
58     t::lib::Mocks::mock_preference( 'NotesToHide', '310' );
59
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' ),
65     );
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' );
70 };