Debian Codegraph @

t/Catmandu/Importer/MARC/XML.t

raw
1 #!perl
2
3 use strict;
4 use warnings;
5 use Test::More;
6 use Test::Exception;
7 use Catmandu::Importer::MARC;
8 use utf8;
9
10 my $pkg;
11
12 BEGIN {
13 $pkg = 'Catmandu::Importer::MARC::XML';
14 use_ok $pkg;
15 }
16
17 require_ok $pkg;
18
19 my $importer = Catmandu::Importer::MARC->new(file => 't/marc.xml', type => 'XML');
20
21 ok $importer , 'got an MARC/XML importer';
22
23 my $records = $importer->to_array;
24
25 ok(@$records == 1);
26
27 is($records->[0]->{record}->[1]->[0] , '920');
28
29 is($records->[0]->{record}->[8]->[4] , 'TEEM (한국전기전자재료학회)');
30
31 # Test broken records
32 $importer = Catmandu::Importer::MARC->new(
33 file => 't/broken.xml',
34 type => "XML",
35 skip_errors => 1,
36 );
37
38 ok $importer , 'got an MARC/XML importer';
39
40 $records = $importer->to_array();
41
42 ok (@$records == 9, 'skipped one record');
43
44 done_testing;