Lines 184-190
subtest 'get_elasticsearch_mappings() tests' => sub {
Link Here
|
184 |
|
184 |
|
185 |
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' => sub { |
185 |
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' => sub { |
186 |
|
186 |
|
187 |
plan tests => 63; |
187 |
plan tests => 65; |
188 |
|
188 |
|
189 |
t::lib::Mocks::mock_preference('marcflavour', 'MARC21'); |
189 |
t::lib::Mocks::mock_preference('marcflavour', 'MARC21'); |
190 |
t::lib::Mocks::mock_preference('ElasticsearchMARCFormat', 'ISO2709'); |
190 |
t::lib::Mocks::mock_preference('ElasticsearchMARCFormat', 'ISO2709'); |
Lines 450-463
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests'
Link Here
|
450 |
MARC::Field->new('999', '', '', c => '1234568'), |
450 |
MARC::Field->new('999', '', '', c => '1234568'), |
451 |
MARC::Field->new('952', '', '', 0 => 1, g => 'string where should be numeric', o => $long_callno), |
451 |
MARC::Field->new('952', '', '', 0 => 1, g => 'string where should be numeric', o => $long_callno), |
452 |
); |
452 |
); |
453 |
my $records = [$marc_record_1, $marc_record_2, $marc_record_3]; |
453 |
|
|
|
454 |
my $marc_record_4 = MARC::Record->new(); |
455 |
$marc_record_4->leader(' cam 22 a 4500'); |
456 |
$marc_record_4->append_fields( |
457 |
MARC::Field->new('008', '901111s19uu xxk|||| |00| ||eng c'), |
458 |
MARC::Field->new('100', '', '', a => 'Author 2'), |
459 |
MARC::Field->new('245', '', '4', a => 'The Title :', b => 'fourth record'), |
460 |
MARC::Field->new('260', '', '', a => 'New York :', b => 'Ace ,', c => ' 89 '), |
461 |
MARC::Field->new('999', '', '', c => '1234568'), |
462 |
); |
463 |
|
464 |
my $records = [$marc_record_1, $marc_record_2, $marc_record_3, $marc_record_4]; |
454 |
|
465 |
|
455 |
$see->get_elasticsearch_mappings(); #sort_fields will call this and use the actual db values unless we call it first |
466 |
$see->get_elasticsearch_mappings(); #sort_fields will call this and use the actual db values unless we call it first |
456 |
|
467 |
|
457 |
my $docs = $see->marc_records_to_documents($records); |
468 |
my $docs = $see->marc_records_to_documents($records); |
458 |
|
469 |
|
459 |
# First record: |
470 |
# First record: |
460 |
is(scalar @{$docs}, 3, 'Two records converted to documents'); |
471 |
is(scalar @{$docs}, 4, 'Four records converted to documents'); |
461 |
|
472 |
|
462 |
is_deeply($docs->[0]->{control_number}, ['123'], 'First record control number should be set correctly'); |
473 |
is_deeply($docs->[0]->{control_number}, ['123'], 'First record control number should be set correctly'); |
463 |
|
474 |
|
Lines 475-480
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests'
Link Here
|
475 |
is(scalar @{$docs->[0]->{title__sort}}, 1, 'First document title__sort field should have a single'); |
486 |
is(scalar @{$docs->[0]->{title__sort}}, 1, 'First document title__sort field should have a single'); |
476 |
is_deeply($docs->[0]->{title__sort}, ['Title: first record Title: first record'], 'First document title__sort field should be set correctly'); |
487 |
is_deeply($docs->[0]->{title__sort}, ['Title: first record Title: first record'], 'First document title__sort field should be set correctly'); |
477 |
|
488 |
|
|
|
489 |
is(scalar @{$docs->[3]->{title__sort}}, 1, 'First document title__sort field should have a single'); |
490 |
is_deeply($docs->[3]->{title__sort}, ['Title : fourth record The Title : fourth record'], 'Fourth document title__sort field should be set correctly'); |
491 |
|
478 |
is($docs->[0]->{issues}, 6, 'Issues field should be sum of the issues for each item'); |
492 |
is($docs->[0]->{issues}, 6, 'Issues field should be sum of the issues for each item'); |
479 |
is($docs->[0]->{issues__sort}, 6, 'Issues sort field should also be a sum of the issues'); |
493 |
is($docs->[0]->{issues__sort}, 6, 'Issues sort field should also be a sum of the issues'); |
480 |
|
494 |
|
481 |
- |
|
|