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
=> 3;
25 use C4
::Biblio qw
/TransformHtmlToXml/;
30 my ($marc_flavour) = @_;
32 t
::lib
::Mocks
::mock_preference
('marcflavour', $marc_flavour);
34 my ( $tags, $subfields );
35 if ( $marc_flavour eq 'UNIMARC' ) {
36 $tags= [ '001', '600', '200', '200', '400' ];
37 $subfields = [ '', 'a', 'a', 'c', 'a' ];
39 $tags= [ '001', '100', '245', '245', '400' ];
40 $subfields = [ '', 'a', 'a', 'c', 'a' ];
42 my $values = [ '12345', 'author', 'title', 'resp', '' ];
43 my $ind = [ ' ', '00', ' 9', ' ', ' ' ];
45 my $xml = TransformHtmlToXml
( $tags, $subfields, $values, $ind, undef, $marc_flavour );
46 my $xmlh = XML
::Simple
->new->XMLin( $xml );
48 # check number of controlfields
49 is
( ref $xmlh->{record
}->{controlfield
}, 'HASH', 'One controlfield' );
51 my $cnt = @
{$xmlh->{record
}->{datafield
}};
52 if ( $marc_flavour eq 'UNIMARC' ) {
53 is
( $cnt, 3, 'Three datafields' ); # 100$a is automatically created
55 is
( $cnt, 2, 'Two datafields' );
58 is
( $xmlh->{record
}->{datafield
}->[1]->{subfield
}->[1]->{content
}, 'resp', 'Check value' );
59 # check second indicator of 245
60 is
( $xmlh->{record
}->{datafield
}->[1]->{ind2
}, '9', 'Check indicator' );
63 subtest
"->TransformHtmlToXml (MARC21) tests" => sub {
69 subtest
"->TransformHtmlToXml (UNIMARC) tests" => sub {
75 subtest
"->TransformHtmlToXml (NORMARC) tests" => sub {