Lines 117-123
subtest 'get_elasticsearch_mappings() tests' => sub {
Link Here
|
117 |
|
117 |
|
118 |
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' => sub { |
118 |
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' => sub { |
119 |
|
119 |
|
120 |
plan tests => 51; |
120 |
plan tests => 54; |
121 |
|
121 |
|
122 |
t::lib::Mocks::mock_preference('marcflavour', 'MARC21'); |
122 |
t::lib::Mocks::mock_preference('marcflavour', 'MARC21'); |
123 |
t::lib::Mocks::mock_preference('ElasticsearchMARCFormat', 'ISO2709'); |
123 |
t::lib::Mocks::mock_preference('ElasticsearchMARCFormat', 'ISO2709'); |
Lines 273-278
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests'
Link Here
|
273 |
marc_type => 'marc21', |
273 |
marc_type => 'marc21', |
274 |
marc_field => '952l', |
274 |
marc_field => '952l', |
275 |
}, |
275 |
}, |
|
|
276 |
{ |
277 |
name => 'date-of-publication', |
278 |
type => 'year', |
279 |
facet => 0, |
280 |
suggestible => 0, |
281 |
searchable => 1, |
282 |
sort => 1, |
283 |
marc_type => 'marc21', |
284 |
marc_field => '008_/7-10', |
285 |
}, |
286 |
|
276 |
); |
287 |
); |
277 |
|
288 |
|
278 |
my $se = Test::MockModule->new('Koha::SearchEngine::Elasticsearch'); |
289 |
my $se = Test::MockModule->new('Koha::SearchEngine::Elasticsearch'); |
Lines 304-309
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests'
Link Here
|
304 |
$marc_record_1->append_fields( |
315 |
$marc_record_1->append_fields( |
305 |
MARC::Field->new('001', '123'), |
316 |
MARC::Field->new('001', '123'), |
306 |
MARC::Field->new('007', 'ku'), |
317 |
MARC::Field->new('007', 'ku'), |
|
|
318 |
MARC::Field->new('008', '901111s1962 xxk|||| |00| ||eng c'), |
307 |
MARC::Field->new('020', '', '', a => '1-56619-909-3'), |
319 |
MARC::Field->new('020', '', '', a => '1-56619-909-3'), |
308 |
MARC::Field->new('100', '', '', a => 'Author 1'), |
320 |
MARC::Field->new('100', '', '', a => 'Author 1'), |
309 |
MARC::Field->new('110', '', '', a => 'Corp Author'), |
321 |
MARC::Field->new('110', '', '', a => 'Corp Author'), |
Lines 318-323
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests'
Link Here
|
318 |
my $marc_record_2 = MARC::Record->new(); |
330 |
my $marc_record_2 = MARC::Record->new(); |
319 |
$marc_record_2->leader(' cam 22 a 4500'); |
331 |
$marc_record_2->leader(' cam 22 a 4500'); |
320 |
$marc_record_2->append_fields( |
332 |
$marc_record_2->append_fields( |
|
|
333 |
MARC::Field->new('008', '901111s19uu xxk|||| |00| ||eng c'), |
321 |
MARC::Field->new('100', '', '', a => 'Author 2'), |
334 |
MARC::Field->new('100', '', '', a => 'Author 2'), |
322 |
# MARC::Field->new('210', '', '', a => 'Title 2'), |
335 |
# MARC::Field->new('210', '', '', a => 'Title 2'), |
323 |
# MARC::Field->new('245', '', '', a => 'Title: second record'), |
336 |
# MARC::Field->new('245', '', '', a => 'Title: second record'), |
Lines 432-437
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests'
Link Here
|
432 |
'First document local_classification field should be set correctly' |
445 |
'First document local_classification field should be set correctly' |
433 |
); |
446 |
); |
434 |
|
447 |
|
|
|
448 |
# Tests for 'year' type and 'filter_callbacks' |
449 |
is(scalar @{$docs->[0]->{'date-of-publication'}}, 1, 'First document date-of-publication field should contain one value'); |
450 |
is_deeply($docs->[0]->{'date-of-publication'}, ['1962'], 'First document date-of-publication field should be set correctly'); |
451 |
|
435 |
# Second record: |
452 |
# Second record: |
436 |
|
453 |
|
437 |
is(scalar @{$docs->[1]->{author}}, 1, 'Second document author field should contain one value'); |
454 |
is(scalar @{$docs->[1]->{author}}, 1, 'Second document author field should contain one value'); |
Lines 456-461
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests'
Link Here
|
456 |
'Second document local_classification__sort field should be set correctly' |
473 |
'Second document local_classification__sort field should be set correctly' |
457 |
); |
474 |
); |
458 |
|
475 |
|
|
|
476 |
# Tests for 'year' type and 'filter_callbacks' |
477 |
ok(!(defined $docs->[1]->{'date-of-publication'}), "Second document invalid date-of-publication value should have been removed"); |
478 |
|
459 |
# Mappings marc_type: |
479 |
# Mappings marc_type: |
460 |
|
480 |
|
461 |
ok(!(defined $docs->[0]->{unimarc_title}), "No mapping when marc_type doesn't match marc flavour"); |
481 |
ok(!(defined $docs->[0]->{unimarc_title}), "No mapping when marc_type doesn't match marc flavour"); |
462 |
- |
|
|