@@ -, +, @@ --- t/Koha/SearchEngine/Elasticsearch.t | 16 ++++++++----- .../Koha_SearchEngine_Elasticsearch_Search.t | 26 +--------------------- 2 files changed, 11 insertions(+), 31 deletions(-) --- a/t/Koha/SearchEngine/Elasticsearch.t +++ a/t/Koha/SearchEngine/Elasticsearch.t @@ -145,7 +145,7 @@ subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' suggestible => 1, sort => 1, marc_type => 'marc21', - marc_field => '245a', + marc_field => '245(ab)ab', }, { name => 'unimarc_title', @@ -228,7 +228,7 @@ subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' MARC::Field->new('100', '', '', a => 'Author 1'), MARC::Field->new('110', '', '', a => 'Corp Author'), MARC::Field->new('210', '', '', a => 'Title 1'), - MARC::Field->new('245', '', '', a => 'Title: first record'), + MARC::Field->new('245', '', '', a => 'Title:', b => 'first record'), MARC::Field->new('999', '', '', c => '1234567'), # ' ' for testing trimming of white space in boolean value callback: MARC::Field->new('952', '', '', 0 => ' ', g => '123.30'), @@ -261,8 +261,8 @@ subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' is(scalar @{$docs->[0][1]->{author__sort}}, 2, 'First document author__sort field should have two values'); is_deeply($docs->[0][1]->{author__sort}, ['Author 1', 'Corp Author'], 'First document author__sort field should be set correctly'); - is(scalar @{$docs->[0][1]->{title__sort}}, 1, 'First document title__sort field should have one value'); - is_deeply($docs->[0][1]->{title__sort}, ['Title: first record'], 'First document title__sort field should be set correctly'); + is(scalar @{$docs->[0][1]->{title__sort}}, 3, 'First document title__sort field should have three values'); + is_deeply($docs->[0][1]->{title__sort}, ['Title:', 'first record', 'Title: first record'], 'First document title__sort field should be set correctly'); is(scalar @{$docs->[0][1]->{author__suggestion}}, 2, 'First document author__suggestion field should contain two values'); is_deeply( @@ -278,10 +278,14 @@ subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' 'First document author__suggestion field should be set correctly' ); - is(scalar @{$docs->[0][1]->{title__suggestion}}, 1, 'First document title__suggestion field should contain one value'); + is(scalar @{$docs->[0][1]->{title__suggestion}}, 3, 'First document title__suggestion field should contain three values'); is_deeply( $docs->[0][1]->{title__suggestion}, - [{ 'input' => 'Title: first record' }], + [ + { 'input' => 'Title:' }, + { 'input' => 'first record' }, + { 'input' => 'Title: first record' } + ], 'First document title__suggestion field should be set correctly' ); --- a/t/db_dependent/Koha_SearchEngine_Elasticsearch_Search.t +++ a/t/db_dependent/Koha_SearchEngine_Elasticsearch_Search.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 15; +use Test::More tests => 13; use t::lib::Mocks; use Koha::SearchEngine::Elasticsearch::QueryBuilder; @@ -50,8 +50,6 @@ SKIP: { ok( my $results = $searcher->search( $query) , 'Do a search ' ); - ok( my $marc = $searcher->json2marc( $results->first ), 'Convert JSON to MARC'); - is (my $count = $searcher->count( $query ), 0 , 'Get a count of the results, without returning results '); ok ($results = $searcher->search_compat( $query ), 'Test search_compat' ); @@ -69,28 +67,6 @@ SKIP: { is ($searcher->max_result_window, 12000, 'max_result_window returns the correct value'); } -subtest 'json2marc' => sub { - plan tests => 4; - my $leader = '00626nam a2200193 4500'; - my $_001 = 42; - my $_010a = '123456789'; - my $_010d = 145; - my $_200a = 'a title'; - my $json = [ # It's not a JSON, see the POD of json2marc - [ 'LDR', undef, undef, '_', $leader ], - [ '001', undef, undef, '_', $_001 ], - [ '010', ' ', ' ', 'a', $_010a, 'd', $_010d ], - [ '200', '1', ' ', 'a', $_200a, ], # Yes UNIMARC but we don't mind here - ]; - - my $marc = $searcher->json2marc( $json ); - is( $marc->leader, $leader, ); - is( $marc->field('001')->data, $_001, ); - is( $marc->subfield('010', 'a'), $_010a, ); - is( $marc->subfield('200', 'a'), $_200a, ); - -}; - subtest 'build_query tests' => sub { plan tests => 24; --