test and fix join_subfields_with
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 9 Jul 2006 12:18:44 +0000 (12:18 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 9 Jul 2006 12:18:44 +0000 (12:18 +0000)
git-svn-id: file:///home/dpavlin/svn/Biblio-Isis/trunk@58 4670fa4d-42ec-0310-ab5b-a66af6943492

lib/Biblio/Isis.pm
t/2_isis.t

index e4de0f6..54523df 100644 (file)
@@ -544,7 +544,7 @@ have original record subfield order and index to that subfield like this:
 =item join_subfields_with
 
 Define delimiter which will be used to join repeatable subfields. You can
-specify option here instead in L</new> if you want to have per-record controll.
+specify option here instead in L</new> if you want to have per-record control.
 
 =back
 
@@ -567,8 +567,8 @@ sub to_hash {
 
        my $row = $self->fetch($mfn) || return;
 
-       my $j_rs = $arg->{join_repeatable_subfields};
-       $j_rs = $self->{join_repeatable_subfields} unless(defined($j_rs));
+       my $j_rs = $arg->{join_subfields_with};
+       $j_rs = $self->{join_subfields_with} unless(defined($j_rs));
        my $i_sf = $arg->{include_subfields};
 
        foreach my $f_nr (keys %{$row}) {
index 239bbe7..83508d1 100755 (executable)
@@ -3,7 +3,7 @@
 use strict;
 use blib;
 
-use Test::More tests => 132;
+use Test::More tests => 134;
 use File::Spec;
 
 BEGIN {
@@ -18,8 +18,7 @@ BEGIN {
 }
 
 
-my $debug = shift @ARGV;
-$debug = length( $debug ) if ($debug);
+my $debug = length( shift(@ARGV) || '' );
 my $isis;
 
 my $path_winisis = File::Spec->catfile('data', 'winisis', 'BIBL');
@@ -260,3 +259,15 @@ is_deeply( $hash, {
   ],
 }, 'hash is_deeply');
 
+ok($hash = $isis->to_hash({ mfn => $isis->mfn, join_subfields_with => ' ; ' }), 'to_hash(mfn,join_subfields_with)');
+diag "to_hash = ",Dumper( $hash ) if ($debug);
+is_deeply( $hash, {
+   "000" => [42],
+   900   => [{ a => "900a", b => "900b", c => "900c" }],
+   901   => [
+              { a => "901a-1", b => "901b-1", c => "901c-1" },
+              { a => "901a-2", b => "901b-2" },
+              { a => "901a-3" },
+            ],
+   902   => [{ a => "a1 ; a2 ; a3 ; a4 ; a5", b => "b1 ; b2", c => "c1" }],
+}, 'hash is_deeply');