Lines 19-24
use Modern::Perl;
Link Here
|
19 |
|
19 |
|
20 |
use Test::More; |
20 |
use Test::More; |
21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
|
|
22 |
use Test::Warn; |
22 |
|
23 |
|
23 |
use MARC::Record; |
24 |
use MARC::Record; |
24 |
|
25 |
|
Lines 86-96
is( $testmatcher->description(), 'match on ISSN', 'testing code accessor' );
Link Here
|
86 |
|
87 |
|
87 |
subtest '_get_match_keys() tests' => sub { |
88 |
subtest '_get_match_keys() tests' => sub { |
88 |
|
89 |
|
89 |
plan tests => 8; |
90 |
plan tests => 17; |
90 |
|
91 |
|
91 |
my $matchpoint = get_title_matchpoint({ |
92 |
my $matchpoint = get_title_matchpoint({ |
92 |
length => 0, |
93 |
length => 0, |
93 |
norms => [], |
94 |
norms => [ 'legacy_default' ], |
94 |
offset => 0 |
95 |
offset => 0 |
95 |
}); |
96 |
}); |
96 |
|
97 |
|
Lines 114-120
subtest '_get_match_keys() tests' => sub {
Link Here
|
114 |
|
115 |
|
115 |
$matchpoint = get_title_matchpoint({ |
116 |
$matchpoint = get_title_matchpoint({ |
116 |
length => 9, |
117 |
length => 9, |
117 |
norms => [], |
118 |
norms => [ 'legacy_default' ], |
118 |
offset => 0 |
119 |
offset => 0 |
119 |
}); |
120 |
}); |
120 |
@keys = C4::Matcher::_get_match_keys( $record, $matchpoint ); |
121 |
@keys = C4::Matcher::_get_match_keys( $record, $matchpoint ); |
Lines 123-138
subtest '_get_match_keys() tests' => sub {
Link Here
|
123 |
|
124 |
|
124 |
$matchpoint = get_title_matchpoint({ |
125 |
$matchpoint = get_title_matchpoint({ |
125 |
length => 9, |
126 |
length => 9, |
126 |
norms => [], |
127 |
norms => [ 'legacy_default' ], |
127 |
offset => 1 |
128 |
offset => 1 |
128 |
}); |
129 |
}); |
129 |
@keys = C4::Matcher::_get_match_keys( $record, $matchpoint ); |
130 |
@keys = C4::Matcher::_get_match_keys( $record, $matchpoint ); |
130 |
is( $keys[0], 'THE', |
131 |
is( $keys[0], 'THE T', |
131 |
'Match key correctly calculated with length 9 and offset 1'); |
132 |
'Match key correctly calculated with length 9 and offset 1'); |
132 |
|
133 |
|
133 |
$matchpoint = get_title_matchpoint({ |
134 |
$matchpoint = get_title_matchpoint({ |
134 |
length => 9, |
135 |
length => 9, |
135 |
norms => [], |
136 |
norms => [ 'legacy_default' ], |
136 |
offset => 2 |
137 |
offset => 2 |
137 |
}); |
138 |
}); |
138 |
@keys = C4::Matcher::_get_match_keys( $record, $matchpoint ); |
139 |
@keys = C4::Matcher::_get_match_keys( $record, $matchpoint ); |
Lines 141-147
subtest '_get_match_keys() tests' => sub {
Link Here
|
141 |
|
142 |
|
142 |
$matchpoint = get_authors_matchpoint({ |
143 |
$matchpoint = get_authors_matchpoint({ |
143 |
length => 0, |
144 |
length => 0, |
144 |
norms => [], |
145 |
norms => [ 'legacy_default' ], |
145 |
offset => 0 |
146 |
offset => 0 |
146 |
}); |
147 |
}); |
147 |
@keys = C4::Matcher::_get_match_keys( $record, $matchpoint ); |
148 |
@keys = C4::Matcher::_get_match_keys( $record, $matchpoint ); |
Lines 150-179
subtest '_get_match_keys() tests' => sub {
Link Here
|
150 |
|
151 |
|
151 |
$matchpoint = get_authors_matchpoint({ |
152 |
$matchpoint = get_authors_matchpoint({ |
152 |
length => 9, |
153 |
length => 9, |
153 |
norms => [], |
154 |
norms => [ 'legacy_default' ], |
154 |
offset => 0 |
155 |
offset => 0 |
155 |
}); |
156 |
}); |
156 |
@keys = C4::Matcher::_get_match_keys( $record, $matchpoint ); |
157 |
@keys = C4::Matcher::_get_match_keys( $record, $matchpoint ); |
157 |
is( $keys[0], 'STRAUB KING ST', |
158 |
is( $keys[0], 'STRAUB P KING STE', |
158 |
'Match key correctly calculated with multiple components, length 9'); |
159 |
'Match key correctly calculated with multiple components, length 9'); |
159 |
|
160 |
|
160 |
$matchpoint = get_authors_matchpoint({ |
161 |
$matchpoint = get_authors_matchpoint({ |
161 |
length => 10, |
162 |
length => 10, |
162 |
norms => [], |
163 |
norms => [ 'legacy_default' ], |
163 |
offset => 0 |
164 |
offset => 0 |
164 |
}); |
165 |
}); |
165 |
@keys = C4::Matcher::_get_match_keys( $record, $matchpoint ); |
166 |
@keys = C4::Matcher::_get_match_keys( $record, $matchpoint ); |
166 |
is( $keys[0], 'STRAUB P KING STE', |
167 |
is( $keys[0], 'STRAUB PE KING STEP', |
167 |
'Match key correctly calculated with multiple components, length 10'); |
168 |
'Match key correctly calculated with multiple components, length 10'); |
168 |
|
169 |
|
169 |
$matchpoint = get_authors_matchpoint({ |
170 |
$matchpoint = get_authors_matchpoint({ |
170 |
length => 10, |
171 |
length => 10, |
171 |
norms => [], |
172 |
norms => [ 'legacy_default' ], |
172 |
offset => 2 |
173 |
offset => 2 |
173 |
}); |
174 |
}); |
174 |
@keys = C4::Matcher::_get_match_keys( $record, $matchpoint ); |
175 |
@keys = C4::Matcher::_get_match_keys( $record, $matchpoint ); |
175 |
is( $keys[0], 'TRAUB PET ING STEPH', |
176 |
is( $keys[0], 'RAUB PETE NG STEPHE', |
176 |
'Match key correctly calculated with multiple components, length 10, offset 1'); |
177 |
'Match key correctly calculated with multiple components, length 10, offset 1'); |
|
|
178 |
|
179 |
$matchpoint = get_title_matchpoint({ |
180 |
length => 0, |
181 |
norms => [ 'none', 'none' ], |
182 |
offset => 0 |
183 |
}); |
184 |
@keys = C4::Matcher::_get_match_keys( $record, $matchpoint ); |
185 |
is( $keys[0], ' .; thE t[]:,aliS(m)/An\'" Stephen King, Peter Straub.', |
186 |
'Match key intact if \'none\' specified, length 0 and offset 0' ); |
187 |
|
188 |
$matchpoint = get_authors_matchpoint({ |
189 |
length => 0, |
190 |
norms => [ 'upper_case' ], |
191 |
offset => 0 |
192 |
}); |
193 |
@keys = C4::Matcher::_get_match_keys( $record, $matchpoint ); |
194 |
is( $keys[0], 'STRAUB, PETER KING, STEPHEN', |
195 |
'Match key correctly calculated with multiple components, \'upper_case\' norm'); |
196 |
|
197 |
$matchpoint = get_authors_matchpoint({ |
198 |
length => 0, |
199 |
norms => [ 'lower_case' ], |
200 |
offset => 0 |
201 |
}); |
202 |
@keys = C4::Matcher::_get_match_keys( $record, $matchpoint ); |
203 |
is( $keys[0], 'straub, peter king, stephen', |
204 |
'Match key correctly calculated with multiple components, \'lower_case\' norm'); |
205 |
|
206 |
$matchpoint = get_authors_matchpoint({ |
207 |
length => 0, |
208 |
norms => [ 'remove_spaces' ], |
209 |
offset => 0 |
210 |
}); |
211 |
@keys = C4::Matcher::_get_match_keys( $record, $matchpoint ); |
212 |
is( $keys[0], 'Straub,Peter King,Stephen', |
213 |
'Match key correctly calculated with multiple components, \'remove_spaces\' norm'); |
214 |
|
215 |
$matchpoint = get_authors_matchpoint({ |
216 |
length => 0, |
217 |
norms => [ 'remove_spaces', 'lower_case' ], |
218 |
offset => 0 |
219 |
}); |
220 |
@keys = C4::Matcher::_get_match_keys( $record, $matchpoint ); |
221 |
is( $keys[0], 'straub,peter king,stephen', |
222 |
'Match key correctly calculated with multiple components, \'remove_spaces\' and \'lower_case\' norm'); |
223 |
|
224 |
my $norm = 'unknown_norm'; |
225 |
$matchpoint = get_title_matchpoint({ |
226 |
length => 0, |
227 |
norms => [ $norm ], |
228 |
offset => 0 |
229 |
}); |
230 |
warning_is |
231 |
{ @keys = C4::Matcher::_get_match_keys( $record, $matchpoint ) } |
232 |
qq{Invalid normalization routine required ($norm)}, |
233 |
'Passing an invalid normalization routine name raises a warning'; |
234 |
|
235 |
is( $keys[0], ' .; thE t[]:,aliS(m)/An\'" Stephen King, Peter Straub.', |
236 |
'Match key intact if invalid normalization routine specified' ); |
237 |
|
238 |
$matchpoint = get_title_matchpoint({ |
239 |
length => 0, |
240 |
norms => [ $norm, 'upper_case' ], |
241 |
offset => 0 |
242 |
}); |
243 |
warning_is |
244 |
{ @keys = C4::Matcher::_get_match_keys( $record, $matchpoint ) } |
245 |
qq{Invalid normalization routine required ($norm)}, |
246 |
'Passing an invalid normalization routine name raises a warning'; |
247 |
|
248 |
is( $keys[0], ' .; THE T[]:,ALIS(M)/AN\'" STEPHEN KING, PETER STRAUB.', |
249 |
'Match key correctly normalized if invalid normalization routine specified' ); |
177 |
}; |
250 |
}; |
178 |
|
251 |
|
179 |
sub get_title_matchpoint { |
252 |
sub get_title_matchpoint { |
180 |
- |
|
|