Bug 11247: Add a simple unit test for TransformHtmlToXml

The unit test is db dependent (as Jonathan correctly remarked),
since the sub checks a preference.

Test plan:
Run t/db_dependent/Biblio/TransformHtmlToXml.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit d1335a766d)
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
(cherry picked from commit 74e46b7467)
Signed-off-by: Liz Rea <wizzyrea@gmail.com>
This commit is contained in:
Marcel de Rooy 2015-08-26 14:09:53 +02:00 committed by Mason James
parent f4ba93afd2
commit 1016ba0f75
1 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,25 @@
#!/usr/bin/perl
use Modern::Perl;
use Test::More tests => 4;
use XML::Simple;
use C4::Biblio qw/TransformHtmlToXml/;
my $tags= [ '001', '100', '245', '245' ];
my $subfields = [ '', 'a', 'a', 'c' ];
my $values = [ '12345', 'author', 'title', 'resp' ];
my $ind = [ ' ', '00', ' 9', ' ' ];
my $xml = TransformHtmlToXml( $tags, $subfields, $values, $ind, undef, 'MARC21' );
my $xmlh = XML::Simple->new->XMLin( $xml );
# check number of controlfields
is( ref $xmlh->{record}->{controlfield}, 'HASH', 'One controlfield' );
# check datafields
my $cnt = @{$xmlh->{record}->{datafield}};
is( $cnt, 2, 'Two datafields' );
# check value of 245c
is( $xmlh->{record}->{datafield}->[1]->{subfield}->[1]->{content}, 'resp', 'Check value' );
# check second indicator of 245
is( $xmlh->{record}->{datafield}->[1]->{ind2}, '9', 'Check indicator' );