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 => 56; |
121 |
plan tests => 58; |
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 283-290
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests'
Link Here
|
283 |
sort => 1, |
283 |
sort => 1, |
284 |
marc_type => 'marc21', |
284 |
marc_type => 'marc21', |
285 |
marc_field => '952l', |
285 |
marc_field => '952l', |
286 |
}, |
286 |
}, |
287 |
{ |
287 |
{ |
|
|
288 |
name => 'copydate', |
289 |
type => 'year', |
290 |
facet => 0, |
291 |
suggestible => 0, |
292 |
searchable => 1, |
293 |
sort => 1, |
294 |
marc_type => 'marc21', |
295 |
marc_field => '260c', |
296 |
}, |
297 |
{ |
288 |
name => 'date-of-publication', |
298 |
name => 'date-of-publication', |
289 |
type => 'year', |
299 |
type => 'year', |
290 |
facet => 0, |
300 |
facet => 0, |
Lines 333-338
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests'
Link Here
|
333 |
MARC::Field->new('210', '', '', a => 'Title 1'), |
343 |
MARC::Field->new('210', '', '', a => 'Title 1'), |
334 |
MARC::Field->new('240', '', '4', a => 'The uniform title with nonfiling indicator'), |
344 |
MARC::Field->new('240', '', '4', a => 'The uniform title with nonfiling indicator'), |
335 |
MARC::Field->new('245', '', '', a => 'Title:', b => 'first record'), |
345 |
MARC::Field->new('245', '', '', a => 'Title:', b => 'first record'), |
|
|
346 |
MARC::Field->new('260', '', '', a => 'New York :', b => 'Ace ,', c => 'c1962'), |
336 |
MARC::Field->new('999', '', '', c => '1234567'), |
347 |
MARC::Field->new('999', '', '', c => '1234567'), |
337 |
# ' ' for testing trimming of white space in boolean value callback: |
348 |
# ' ' for testing trimming of white space in boolean value callback: |
338 |
MARC::Field->new('952', '', '', 0 => ' ', g => '123.30', o => $callno, l => 3), |
349 |
MARC::Field->new('952', '', '', 0 => ' ', g => '123.30', o => $callno, l => 3), |
Lines 469-478
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests'
Link Here
|
469 |
'First document uniform_title__sort field should contain the title with the first four initial characters removed' |
480 |
'First document uniform_title__sort field should contain the title with the first four initial characters removed' |
470 |
); |
481 |
); |
471 |
|
482 |
|
472 |
# Tests for 'year' type and 'filter_callbacks' |
483 |
# Tests for 'year' type |
473 |
is(scalar @{$docs->[0]->{'date-of-publication'}}, 1, 'First document date-of-publication field should contain one value'); |
484 |
is(scalar @{$docs->[0]->{'date-of-publication'}}, 1, 'First document date-of-publication field should contain one value'); |
474 |
is_deeply($docs->[0]->{'date-of-publication'}, ['1962'], 'First document date-of-publication field should be set correctly'); |
485 |
is_deeply($docs->[0]->{'date-of-publication'}, ['1962'], 'First document date-of-publication field should be set correctly'); |
475 |
|
486 |
|
|
|
487 |
is_deeply( |
488 |
$docs->[0]->{'copydate'}, |
489 |
['1962'], |
490 |
'First document copydate field should be set correctly' |
491 |
); |
492 |
|
476 |
# Second record: |
493 |
# Second record: |
477 |
|
494 |
|
478 |
is(scalar @{$docs->[1]->{author}}, 1, 'Second document author field should contain one value'); |
495 |
is(scalar @{$docs->[1]->{author}}, 1, 'Second document author field should contain one value'); |
Lines 497-504
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests'
Link Here
|
497 |
'Second document local_classification__sort field should be set correctly' |
514 |
'Second document local_classification__sort field should be set correctly' |
498 |
); |
515 |
); |
499 |
|
516 |
|
500 |
# Tests for 'year' type and 'filter_callbacks' |
517 |
# Tests for 'year' type |
501 |
ok(!(defined $docs->[1]->{'date-of-publication'}), "Second document invalid date-of-publication value should have been removed"); |
518 |
is_deeply( |
|
|
519 |
$docs->[1]->{'copydate'}, |
520 |
['1963','2003'], |
521 |
'Second document copydate field should be set correctly' |
522 |
); |
523 |
is_deeply( |
524 |
$docs->[1]->{'date-of-publication'}, |
525 |
['1900'], |
526 |
'Second document date-of-publication field should be set correctly' |
527 |
); |
502 |
|
528 |
|
503 |
# Mappings marc_type: |
529 |
# Mappings marc_type: |
504 |
|
530 |
|
Lines 633-638
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents_array () t
Link Here
|
633 |
MARC::Field->new('100', '', '', a => 'Author 2'), |
659 |
MARC::Field->new('100', '', '', a => 'Author 2'), |
634 |
# MARC::Field->new('210', '', '', a => 'Title 2'), |
660 |
# MARC::Field->new('210', '', '', a => 'Title 2'), |
635 |
# MARC::Field->new('245', '', '', a => 'Title: second record'), |
661 |
# MARC::Field->new('245', '', '', a => 'Title: second record'), |
|
|
662 |
MARC::Field->new('260', '', '', a => 'New York :', b => 'Ace ,', c => '1963-2003'), |
636 |
MARC::Field->new('999', '', '', c => '1234568'), |
663 |
MARC::Field->new('999', '', '', c => '1234568'), |
637 |
MARC::Field->new('952', '', '', 0 => 1, g => 'string where should be numeric'), |
664 |
MARC::Field->new('952', '', '', 0 => 1, g => 'string where should be numeric'), |
638 |
); |
665 |
); |
639 |
- |
|
|