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 commitd1335a766d) Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> (cherry picked from commit74e46b7467) Signed-off-by: Liz Rea <wizzyrea@gmail.com>
This commit is contained in:
parent
f4ba93afd2
commit
1016ba0f75
|
|
@ -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' );
|
||||
Loading…
Reference in New Issue