|
Lines 102-108
subtest 'AddBiblio' => sub {
Link Here
|
| 102 |
}; |
102 |
}; |
| 103 |
|
103 |
|
| 104 |
subtest 'GetMarcSubfieldStructureFromKohaField' => sub { |
104 |
subtest 'GetMarcSubfieldStructureFromKohaField' => sub { |
| 105 |
plan tests => 25; |
105 |
plan tests => 27; |
| 106 |
|
106 |
|
| 107 |
my @columns = qw( |
107 |
my @columns = qw( |
| 108 |
tagfield tagsubfield liblibrarian libopac repeatable mandatory kohafield tab |
108 |
tagfield tagsubfield liblibrarian libopac repeatable mandatory kohafield tab |
|
Lines 113-135
subtest 'GetMarcSubfieldStructureFromKohaField' => sub {
Link Here
|
| 113 |
# biblio.biblionumber must be mapped so this should return something |
113 |
# biblio.biblionumber must be mapped so this should return something |
| 114 |
my $marc_subfield_structure = GetMarcSubfieldStructureFromKohaField('biblio.biblionumber'); |
114 |
my $marc_subfield_structure = GetMarcSubfieldStructureFromKohaField('biblio.biblionumber'); |
| 115 |
|
115 |
|
| 116 |
ok(defined $marc_subfield_structure, "There is a result"); |
116 |
is( ref $marc_subfield_structure, "ARRAY", "Result is an arrayref" ); |
| 117 |
is(ref $marc_subfield_structure, "HASH", "Result is a hashref"); |
117 |
is( @$marc_subfield_structure, 1, 'Expecting one hit only' ); |
| 118 |
foreach my $col (@columns) { |
118 |
foreach my $col (@columns) { |
| 119 |
ok(exists $marc_subfield_structure->{$col}, "Hashref contains key '$col'"); |
119 |
ok( exists $marc_subfield_structure->[0]->{$col}, "Hashref contains key '$col'" ); |
| 120 |
} |
120 |
} |
| 121 |
is($marc_subfield_structure->{kohafield}, 'biblio.biblionumber', "Result is the good result"); |
121 |
is( $marc_subfield_structure->[0]->{kohafield}, 'biblio.biblionumber', "Result is the good result" ); |
| 122 |
like($marc_subfield_structure->{tagfield}, qr/^\d{3}$/, "tagfield is a valid tagfield"); |
122 |
like( $marc_subfield_structure->[0]->{tagfield}, qr/^\d{3}$/, "tagfield is a valid tagfield" ); |
| 123 |
|
123 |
|
| 124 |
# Add a test for list context (BZ 10306) |
124 |
# Multiple mappings expected for kohafield biblio.copyrightdate (in 260, 264) |
| 125 |
my @results = GetMarcSubfieldStructureFromKohaField('biblio.biblionumber'); |
125 |
$marc_subfield_structure = GetMarcSubfieldStructureFromKohaField('biblio.copyrightdate'); |
| 126 |
is( @results, 1, 'We expect only one mapping' ); |
126 |
is( ref $marc_subfield_structure, "ARRAY", "Result is again an arrayref" ); |
| 127 |
is_deeply( $results[0], $marc_subfield_structure, |
127 |
is( @$marc_subfield_structure, 2, 'We expect two hits' ); |
| 128 |
'The first entry should be the same hashref as we had before' ); |
128 |
ok( exists $marc_subfield_structure->[0]->{tagsubfield}, 'Testing a random column for existence in 1st hash' ); |
|
|
129 |
ok( exists $marc_subfield_structure->[1]->{hidden}, 'Testing a random column for existence in 2nd hash' ); |
| 129 |
|
130 |
|
| 130 |
# foo.bar does not exist so this should return undef |
131 |
# foo.bar does not exist so this should return [] |
| 131 |
$marc_subfield_structure = GetMarcSubfieldStructureFromKohaField('foo.bar'); |
132 |
$marc_subfield_structure = GetMarcSubfieldStructureFromKohaField('foo.bar'); |
| 132 |
is($marc_subfield_structure, undef, "invalid kohafield returns undef"); |
133 |
is_deeply( $marc_subfield_structure, [], "invalid kohafield returns empty arrayref" ); |
| 133 |
|
134 |
|
| 134 |
}; |
135 |
}; |
| 135 |
|
136 |
|
| 136 |
- |
|
|