From a36fac0f5ff450c16885a831d8f71163c11b5c45 Mon Sep 17 00:00:00 2001 From: David Gustafsson Date: Fri, 10 Sep 2021 15:07:47 +0200 Subject: [PATCH] Bug 24720: Add test Signed-off-by: Shi Yao Wang --- .../Koha/SearchEngine/Elasticsearch.t | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/SearchEngine/Elasticsearch.t b/t/db_dependent/Koha/SearchEngine/Elasticsearch.t index 5f0564d9fee..6d71d1ad7b8 100755 --- a/t/db_dependent/Koha/SearchEngine/Elasticsearch.t +++ b/t/db_dependent/Koha/SearchEngine/Elasticsearch.t @@ -318,6 +318,16 @@ subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' marc_type => 'marc21', marc_field => '245', }, + { + name => 'title_sort', + type => 'string', + facet => 0, + suggestible => 0, + searchable => 0, + sort => 1, + marc_type => 'marc21', + marc_field => '246a', + }, { name => 'sum_item_price', type => 'sum', @@ -475,6 +485,7 @@ subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' MARC::Field->new( '650', '', '', a => 'Heading', z => 'Geohead', v => 'Formhead' ), MARC::Field->new( '650', '', '', a => 'Heading', x => 'Gensubhead', z => 'Geohead' ), MARC::Field->new( '999', '', '', c => '1234567' ), + MARC::Field->new( '246', '', '', a => '#$[Title!' ), # ' ' for testing trimming of white space in boolean value callback: MARC::Field->new( '952', '', '', 0 => ' ', g => '123.30', o => $callno, l => 3 ), @@ -695,9 +706,14 @@ subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' 'First document copydate field should be set correctly' ); + is( + $docs->[0]->{title_sort__sort}[0], + 'Title!', + 'First document title_sort should have initial non word characters stripped', + ); + # Second record: - is( scalar @{ $docs->[1]->{author} }, 1, 'Second document author field should contain one value' ); is_deeply( $docs->[1]->{author}, ['Author 2'], 'Second document author field should be set correctly' ); is( -- 2.51.2