Lines 118-124
subtest 'get_elasticsearch_mappings() tests' => sub {
Link Here
|
118 |
|
118 |
|
119 |
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' => sub { |
119 |
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' => sub { |
120 |
|
120 |
|
121 |
plan tests => 51; |
121 |
plan tests => 55; |
122 |
|
122 |
|
123 |
t::lib::Mocks::mock_preference('marcflavour', 'MARC21'); |
123 |
t::lib::Mocks::mock_preference('marcflavour', 'MARC21'); |
124 |
t::lib::Mocks::mock_preference('ElasticsearchMARCFormat', 'ISO2709'); |
124 |
t::lib::Mocks::mock_preference('ElasticsearchMARCFormat', 'ISO2709'); |
Lines 274-279
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests'
Link Here
|
274 |
marc_type => 'marc21', |
274 |
marc_type => 'marc21', |
275 |
marc_field => '952l', |
275 |
marc_field => '952l', |
276 |
}, |
276 |
}, |
|
|
277 |
{ |
278 |
name => 'copydate', |
279 |
type => 'year', |
280 |
facet => 0, |
281 |
suggestible => 0, |
282 |
searchable => 1, |
283 |
sort => 1, |
284 |
marc_type => 'marc21', |
285 |
marc_field => '260c', |
286 |
}, |
287 |
{ |
288 |
name => 'date-of-publication', |
289 |
type => 'year', |
290 |
facet => 0, |
291 |
suggestible => 0, |
292 |
searchable => 1, |
293 |
sort => 1, |
294 |
marc_type => 'marc21', |
295 |
marc_field => '008_/7-10', |
296 |
}, |
277 |
); |
297 |
); |
278 |
|
298 |
|
279 |
my $se = Test::MockModule->new('Koha::SearchEngine::Elasticsearch'); |
299 |
my $se = Test::MockModule->new('Koha::SearchEngine::Elasticsearch'); |
Lines 305-315
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests'
Link Here
|
305 |
$marc_record_1->append_fields( |
325 |
$marc_record_1->append_fields( |
306 |
MARC::Field->new('001', '123'), |
326 |
MARC::Field->new('001', '123'), |
307 |
MARC::Field->new('007', 'ku'), |
327 |
MARC::Field->new('007', 'ku'), |
|
|
328 |
MARC::Field->new('008', '980514s19uu gw 000 0 lat '), |
308 |
MARC::Field->new('020', '', '', a => '1-56619-909-3'), |
329 |
MARC::Field->new('020', '', '', a => '1-56619-909-3'), |
309 |
MARC::Field->new('100', '', '', a => 'Author 1'), |
330 |
MARC::Field->new('100', '', '', a => 'Author 1'), |
310 |
MARC::Field->new('110', '', '', a => 'Corp Author'), |
331 |
MARC::Field->new('110', '', '', a => 'Corp Author'), |
311 |
MARC::Field->new('210', '', '', a => 'Title 1'), |
332 |
MARC::Field->new('210', '', '', a => 'Title 1'), |
312 |
MARC::Field->new('245', '', '', a => 'Title:', b => 'first record'), |
333 |
MARC::Field->new('245', '', '', a => 'Title:', b => 'first record'), |
|
|
334 |
MARC::Field->new('260', '', '', a => 'New York :', b => 'Ace ,', 'c' => 'c1962'), |
313 |
MARC::Field->new('999', '', '', c => '1234567'), |
335 |
MARC::Field->new('999', '', '', c => '1234567'), |
314 |
# ' ' for testing trimming of white space in boolean value callback: |
336 |
# ' ' for testing trimming of white space in boolean value callback: |
315 |
MARC::Field->new('952', '', '', 0 => ' ', g => '123.30', o => $callno, l => 3), |
337 |
MARC::Field->new('952', '', '', 0 => ' ', g => '123.30', o => $callno, l => 3), |
Lines 319-327
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests'
Link Here
|
319 |
my $marc_record_2 = MARC::Record->new(); |
341 |
my $marc_record_2 = MARC::Record->new(); |
320 |
$marc_record_2->leader(' cam 22 a 4500'); |
342 |
$marc_record_2->leader(' cam 22 a 4500'); |
321 |
$marc_record_2->append_fields( |
343 |
$marc_record_2->append_fields( |
|
|
344 |
MARC::Field->new('008', '980514s195u gw 000 0 lat '), |
322 |
MARC::Field->new('100', '', '', a => 'Author 2'), |
345 |
MARC::Field->new('100', '', '', a => 'Author 2'), |
323 |
# MARC::Field->new('210', '', '', a => 'Title 2'), |
346 |
# MARC::Field->new('210', '', '', a => 'Title 2'), |
324 |
# MARC::Field->new('245', '', '', a => 'Title: second record'), |
347 |
# MARC::Field->new('245', '', '', a => 'Title: second record'), |
|
|
348 |
MARC::Field->new('260', '', '', a => 'New York :', b => 'Ace ,', 'c' => '1963-2003'), |
325 |
MARC::Field->new('999', '', '', c => '1234568'), |
349 |
MARC::Field->new('999', '', '', c => '1234568'), |
326 |
MARC::Field->new('952', '', '', 0 => 1, g => 'string where should be numeric', o => $long_callno), |
350 |
MARC::Field->new('952', '', '', 0 => 1, g => 'string where should be numeric', o => $long_callno), |
327 |
); |
351 |
); |
Lines 433-438
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests'
Link Here
|
433 |
'First document local_classification field should be set correctly' |
457 |
'First document local_classification field should be set correctly' |
434 |
); |
458 |
); |
435 |
|
459 |
|
|
|
460 |
# Test year type |
461 |
is_deeply( |
462 |
$docs->[0]->{'copydate'}, |
463 |
['1962'], |
464 |
'First document copydate field should be set correctly' |
465 |
); |
466 |
is_deeply( |
467 |
$docs->[0]->{'date-of-publication'}, |
468 |
['1900'], |
469 |
'First document date-of-publication field should be set correctly' |
470 |
); |
471 |
|
436 |
# Second record: |
472 |
# Second record: |
437 |
|
473 |
|
438 |
is(scalar @{$docs->[1]->{author}}, 1, 'Second document author field should contain one value'); |
474 |
is(scalar @{$docs->[1]->{author}}, 1, 'Second document author field should contain one value'); |
Lines 457-462
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests'
Link Here
|
457 |
'Second document local_classification__sort field should be set correctly' |
493 |
'Second document local_classification__sort field should be set correctly' |
458 |
); |
494 |
); |
459 |
|
495 |
|
|
|
496 |
# Test year type |
497 |
is_deeply( |
498 |
$docs->[1]->{'copydate'}, |
499 |
['1963','2003'], |
500 |
'Second document copydate field should be set correctly' |
501 |
); |
502 |
is_deeply( |
503 |
$docs->[1]->{'date-of-publication'}, |
504 |
['1950'], |
505 |
'Second document date-of-publication field should be set correctly' |
506 |
); |
507 |
|
508 |
|
460 |
# Mappings marc_type: |
509 |
# Mappings marc_type: |
461 |
|
510 |
|
462 |
ok(!(defined $docs->[0]->{unimarc_title}), "No mapping when marc_type doesn't match marc flavour"); |
511 |
ok(!(defined $docs->[0]->{unimarc_title}), "No mapping when marc_type doesn't match marc flavour"); |
463 |
- |
|
|