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>.
21 use Test::More tests => 3;
26 use_ok('C4::Heading', qw( field valid_heading_subfield ));
29 subtest "MARC21 tests" => sub {
32 t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
34 ok(C4::Heading::valid_heading_subfield('100', 'a'), '100a valid for bib');
35 ok(!C4::Heading::valid_heading_subfield('100', 'e'), '100e not valid for bib');
37 ok(C4::Heading::valid_heading_subfield('100', 'a', 1), '100a valid for authority');
39 ok(C4::Heading::valid_heading_subfield('110', 'a'), '110a valid for bib');
40 ok(!C4::Heading::valid_heading_subfield('110', 'e'), '110e not valid for bib');
42 ok(C4::Heading::valid_heading_subfield('600', 'a'), '600a valid for bib');
43 ok(!C4::Heading::valid_heading_subfield('600', 'e'), '600e not valid for bib');
45 ok(!C4::Heading::valid_heading_subfield('012', 'a'), '012a invalid field for bib');
48 subtest "UNIMARC tests" => sub {
51 t::lib::Mocks::mock_preference('marcflavour', 'UNIMARC');
53 ok(C4::Heading::valid_heading_subfield('100', 'a'), '100a valid for bib');
54 ok(!C4::Heading::valid_heading_subfield('100', 'i'), '100i not valid fir bib');
56 ok(C4::Heading::valid_heading_subfield('110', 'a'), '110a valid for bib');
57 ok(!C4::Heading::valid_heading_subfield('110', 'i'), '110i not valid for bib');
59 ok(C4::Heading::valid_heading_subfield('600', 'a'), '600a valid for bib');
60 ok(!C4::Heading::valid_heading_subfield('600', 'i'), '600i not valid for bib');
62 ok(!C4::Heading::valid_heading_subfield('012', 'a'), '012a invalid field for bib');