X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=blobdiff_plain;f=Equinox-Migration%2Ft%2F02-SubfieldMapper.t;h=5fcf10f43ddeee1cd8fcafbb537c22afd6e8fded;hp=568c3c070bc4976e956b27928d68d901a241bc05;hb=266413d893952d1e74c85538044393aa48f0ce3e;hpb=70d10b65e4a572bc65044c1d798c1bd4164e1ddf diff --git a/Equinox-Migration/t/02-SubfieldMapper.t b/Equinox-Migration/t/02-SubfieldMapper.t index 568c3c0..5fcf10f 100644 --- a/Equinox-Migration/t/02-SubfieldMapper.t +++ b/Equinox-Migration/t/02-SubfieldMapper.t @@ -1,7 +1,7 @@ #!perl -T -#use Test::More tests => 33; -use Test::More qw(no_plan); +use Test::More tests => 40; +#use Test::More qw(no_plan); use Equinox::Migration::SubfieldMapper; # baseline object creation @@ -46,10 +46,6 @@ $tokens = { field => 'foo', tag => 650, sub => 'qq' }; eval { $sm->validate($tokens) }; is ($@, "Invalid subfield code (line 1)\n", 'over-length subfield'); -$tokens = { field => 'foo', tag => 650, sub => 'a', mod => 'bar' }; -eval { $sm->validate($tokens) }; -is ($@, "Unknown chunk (line 1)\n", 'Extra, non-comment content'); - # and some which should have no problems $tokens = { field => 'foo', tag => 650, sub => 'a' }; eval { $sm->validate($tokens) }; @@ -66,7 +62,7 @@ is ($@, "Fieldnames must be unique (line 1)\n", 'dupe fieldname'); $sm->{tags}{650}{a} = 1; $tokens = { field => 'bar', tag => 650, sub => 'a', mod => '#', 'this', 'is', 'a', 'comment' }; eval { $sm->validate($tokens) }; -is ($@, "Subfields cannot be multimapped (line 1)\n", 'dupe fieldname'); +is ($@, "Subfields cannot be mapped twice (line 1)\n", 'dupe fieldname'); # test load from file $sm = Equinox::Migration::SubfieldMapper->new( file => "./t/corpus/sm0.txt" ); @@ -94,7 +90,10 @@ is ($sm->field(650,'z'), undef, 'tag+code not mapped'); is ($sm->field(949,'a'), 'call_number', 'mapping returned'); # mod method tests -is ($sm->{fields}{type}{mod}, 0); -is ($sm->{fields}{note}{mod}, 'multi'); -is ($sm->mod('zzz'), undef, 'nonexistant field'); -is ($sm->mod('note'), 'multi', 'multi'); +is ($sm->{fields}{note}{mods}[0], 'multi'); +is ($sm->mods('zzz'), undef, 'nonexistant field'); +is_deeply ($sm->mods('note'), ['multi'], 'multi'); +is_deeply ($sm->mods('note_alt'), ['multi', 'req'], 'multi, req'); +is_deeply ($sm->mods('date_a'), ['foo', 'bar', 'quux']); +is_deeply ($sm->filters('date_a'), ['one two three']); +