Lines 132-138
subtest 'get_elasticsearch_mappings() tests' => sub {
Link Here
|
132 |
|
132 |
|
133 |
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' => sub { |
133 |
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' => sub { |
134 |
|
134 |
|
135 |
plan tests => 53; |
135 |
plan tests => 56; |
136 |
|
136 |
|
137 |
t::lib::Mocks::mock_preference('marcflavour', 'MARC21'); |
137 |
t::lib::Mocks::mock_preference('marcflavour', 'MARC21'); |
138 |
t::lib::Mocks::mock_preference('ElasticsearchMARCFormat', 'ISO2709'); |
138 |
t::lib::Mocks::mock_preference('ElasticsearchMARCFormat', 'ISO2709'); |
Lines 298-303
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests'
Link Here
|
298 |
marc_type => 'marc21', |
298 |
marc_type => 'marc21', |
299 |
marc_field => '952l', |
299 |
marc_field => '952l', |
300 |
}, |
300 |
}, |
|
|
301 |
{ |
302 |
name => 'date-of-publication', |
303 |
type => 'year', |
304 |
facet => 0, |
305 |
suggestible => 0, |
306 |
searchable => 1, |
307 |
sort => 1, |
308 |
marc_type => 'marc21', |
309 |
marc_field => '008_/7-10', |
310 |
}, |
311 |
|
301 |
); |
312 |
); |
302 |
|
313 |
|
303 |
my $se = Test::MockModule->new('Koha::SearchEngine::Elasticsearch'); |
314 |
my $se = Test::MockModule->new('Koha::SearchEngine::Elasticsearch'); |
Lines 329-334
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests'
Link Here
|
329 |
$marc_record_1->append_fields( |
340 |
$marc_record_1->append_fields( |
330 |
MARC::Field->new('001', '123'), |
341 |
MARC::Field->new('001', '123'), |
331 |
MARC::Field->new('007', 'ku'), |
342 |
MARC::Field->new('007', 'ku'), |
|
|
343 |
MARC::Field->new('008', '901111s1962 xxk|||| |00| ||eng c'), |
332 |
MARC::Field->new('020', '', '', a => '1-56619-909-3'), |
344 |
MARC::Field->new('020', '', '', a => '1-56619-909-3'), |
333 |
MARC::Field->new('100', '', '', a => 'Author 1'), |
345 |
MARC::Field->new('100', '', '', a => 'Author 1'), |
334 |
MARC::Field->new('110', '', '', a => 'Corp Author'), |
346 |
MARC::Field->new('110', '', '', a => 'Corp Author'), |
Lines 344-349
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests'
Link Here
|
344 |
my $marc_record_2 = MARC::Record->new(); |
356 |
my $marc_record_2 = MARC::Record->new(); |
345 |
$marc_record_2->leader(' cam 22 a 4500'); |
357 |
$marc_record_2->leader(' cam 22 a 4500'); |
346 |
$marc_record_2->append_fields( |
358 |
$marc_record_2->append_fields( |
|
|
359 |
MARC::Field->new('008', '901111s19uu xxk|||| |00| ||eng c'), |
347 |
MARC::Field->new('100', '', '', a => 'Author 2'), |
360 |
MARC::Field->new('100', '', '', a => 'Author 2'), |
348 |
# MARC::Field->new('210', '', '', a => 'Title 2'), |
361 |
# MARC::Field->new('210', '', '', a => 'Title 2'), |
349 |
# MARC::Field->new('245', '', '', a => 'Title: second record'), |
362 |
# MARC::Field->new('245', '', '', a => 'Title: second record'), |
Lines 470-475
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests'
Link Here
|
470 |
'First document uniform_title__sort field should contain the title with the first four initial characters removed' |
483 |
'First document uniform_title__sort field should contain the title with the first four initial characters removed' |
471 |
); |
484 |
); |
472 |
|
485 |
|
|
|
486 |
# Tests for 'year' type and 'filter_callbacks' |
487 |
is(scalar @{$docs->[0]->{'date-of-publication'}}, 1, 'First document date-of-publication field should contain one value'); |
488 |
is_deeply($docs->[0]->{'date-of-publication'}, ['1962'], 'First document date-of-publication field should be set correctly'); |
489 |
|
473 |
# Second record: |
490 |
# Second record: |
474 |
|
491 |
|
475 |
is(scalar @{$docs->[1]->{author}}, 1, 'Second document author field should contain one value'); |
492 |
is(scalar @{$docs->[1]->{author}}, 1, 'Second document author field should contain one value'); |
Lines 494-499
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests'
Link Here
|
494 |
'Second document local_classification__sort field should be set correctly' |
511 |
'Second document local_classification__sort field should be set correctly' |
495 |
); |
512 |
); |
496 |
|
513 |
|
|
|
514 |
# Tests for 'year' type and 'filter_callbacks' |
515 |
ok(!(defined $docs->[1]->{'date-of-publication'}), "Second document invalid date-of-publication value should have been removed"); |
516 |
|
497 |
# Mappings marc_type: |
517 |
# Mappings marc_type: |
498 |
|
518 |
|
499 |
ok(!(defined $docs->[0]->{unimarc_title}), "No mapping when marc_type doesn't match marc flavour"); |
519 |
ok(!(defined $docs->[0]->{unimarc_title}), "No mapping when marc_type doesn't match marc flavour"); |
500 |
- |
|
|