View | Details | Raw Unified | Return to bug 18198
Collapse All | Expand All

(-)a/t/Biblio/GetMarcNotes.t (-1 / +59 lines)
Line 0 Link Here
0
- 
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 => 4;
30
    t::lib::Mocks::mock_preference( 'NotesBlacklist', '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
    );
38
    my $notes = C4::Biblio::GetMarcNotes( $record, 'MARC21' );
39
    is( $notes->[0]->{marcnote}, 'Note1', 'First note' );
40
    is( $notes->[1]->{marcnote}, 'Note2', 'Second note' );
41
    is( $notes->[2]->{marcnote}, 'http://someserver.com', 'URL separated' );
42
    is( @$notes, 3, 'No more notes' );
43
};
44
45
subtest 'GetMarcNotes UNIMARC' => sub {
46
    plan tests => 3;
47
    t::lib::Mocks::mock_preference( 'NotesBlacklist', '310' );
48
49
    my $record = MARC::Record->new;
50
    $record->append_fields(
51
        MARC::Field->new( '300', '', '', a => 'Note1' ),
52
        MARC::Field->new( '300', '', '', a => 'Note2' ),
53
        MARC::Field->new( '310', '', '', a => 'Note3 skipped' ),
54
    );
55
    my $notes = C4::Biblio::GetMarcNotes( $record, 'UNIMARC' );
56
    is( $notes->[0]->{marcnote}, 'Note1', 'First note' );
57
    is( $notes->[1]->{marcnote}, 'Note2', 'Second note' );
58
    is( @$notes, 2, 'No more notes' );
59
};

Return to bug 18198