Debian Codegraph @

t/Catmandu/Fix/Condition/marc_spec_has.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 Catmandu::Fix;
9 use utf8;
10
11 my $pkg;
12
13 BEGIN {
14 $pkg = 'Catmandu::Fix::Condition::marc_spec_has';
15 use_ok $pkg;
16 }
17
18 require_ok $pkg;
19
20
21 my $fixes = <<EOF;
22 if marc_spec_has('LDR{/6=\\a}{/7=\\a|/7=\\c|/7=\\d|/7=\\m}')
23 add_field(type,'Book')
24 end
25
26 if marc_spec_has('LDR{/6=\\a}{/7=\\b}')
27 set_field(type,'Other')
28 end
29
30 EOF
31
32 my $fixer = Catmandu::Fix->new(fixes => [$fixes]);
33 my $importer = Catmandu::Importer::MARC->new( file => 't/camel9.mrc' );
34 my $records = $fixer->fix($importer)->to_array;
35
36 is $records->[0]->{type}, 'Book';
37
38 done_testing;