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 => 53; |
121 |
plan tests => 56; |
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 284-289
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests'
Link Here
|
284 |
marc_type => 'marc21', |
284 |
marc_type => 'marc21', |
285 |
marc_field => '952l', |
285 |
marc_field => '952l', |
286 |
}, |
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 |
}, |
297 |
|
287 |
); |
298 |
); |
288 |
|
299 |
|
289 |
my $se = Test::MockModule->new('Koha::SearchEngine::Elasticsearch'); |
300 |
my $se = Test::MockModule->new('Koha::SearchEngine::Elasticsearch'); |
Lines 315-320
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests'
Link Here
|
315 |
$marc_record_1->append_fields( |
326 |
$marc_record_1->append_fields( |
316 |
MARC::Field->new('001', '123'), |
327 |
MARC::Field->new('001', '123'), |
317 |
MARC::Field->new('007', 'ku'), |
328 |
MARC::Field->new('007', 'ku'), |
|
|
329 |
MARC::Field->new('008', '901111s1962 xxk|||| |00| ||eng c'), |
318 |
MARC::Field->new('020', '', '', a => '1-56619-909-3'), |
330 |
MARC::Field->new('020', '', '', a => '1-56619-909-3'), |
319 |
MARC::Field->new('100', '', '', a => 'Author 1'), |
331 |
MARC::Field->new('100', '', '', a => 'Author 1'), |
320 |
MARC::Field->new('110', '', '', a => 'Corp Author'), |
332 |
MARC::Field->new('110', '', '', a => 'Corp Author'), |
Lines 330-335
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests'
Link Here
|
330 |
my $marc_record_2 = MARC::Record->new(); |
342 |
my $marc_record_2 = MARC::Record->new(); |
331 |
$marc_record_2->leader(' cam 22 a 4500'); |
343 |
$marc_record_2->leader(' cam 22 a 4500'); |
332 |
$marc_record_2->append_fields( |
344 |
$marc_record_2->append_fields( |
|
|
345 |
MARC::Field->new('008', '901111s19uu xxk|||| |00| ||eng c'), |
333 |
MARC::Field->new('100', '', '', a => 'Author 2'), |
346 |
MARC::Field->new('100', '', '', a => 'Author 2'), |
334 |
# MARC::Field->new('210', '', '', a => 'Title 2'), |
347 |
# MARC::Field->new('210', '', '', a => 'Title 2'), |
335 |
# MARC::Field->new('245', '', '', a => 'Title: second record'), |
348 |
# MARC::Field->new('245', '', '', a => 'Title: second record'), |
Lines 456-461
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests'
Link Here
|
456 |
'First document uniform_title__sort field should contain the title with the first four initial characters removed' |
469 |
'First document uniform_title__sort field should contain the title with the first four initial characters removed' |
457 |
); |
470 |
); |
458 |
|
471 |
|
|
|
472 |
# Tests for 'year' type and 'filter_callbacks' |
473 |
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'); |
475 |
|
459 |
# Second record: |
476 |
# Second record: |
460 |
|
477 |
|
461 |
is(scalar @{$docs->[1]->{author}}, 1, 'Second document author field should contain one value'); |
478 |
is(scalar @{$docs->[1]->{author}}, 1, 'Second document author field should contain one value'); |
Lines 480-485
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests'
Link Here
|
480 |
'Second document local_classification__sort field should be set correctly' |
497 |
'Second document local_classification__sort field should be set correctly' |
481 |
); |
498 |
); |
482 |
|
499 |
|
|
|
500 |
# Tests for 'year' type and 'filter_callbacks' |
501 |
ok(!(defined $docs->[1]->{'date-of-publication'}), "Second document invalid date-of-publication value should have been removed"); |
502 |
|
483 |
# Mappings marc_type: |
503 |
# Mappings marc_type: |
484 |
|
504 |
|
485 |
ok(!(defined $docs->[0]->{unimarc_title}), "No mapping when marc_type doesn't match marc flavour"); |
505 |
ok(!(defined $docs->[0]->{unimarc_title}), "No mapping when marc_type doesn't match marc flavour"); |
486 |
- |
|
|