From 9455b95b21de7158167f8ea0ae5b25ddef488345 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 8 Jul 2020 17:29:45 +0000 Subject: [PATCH] Bug 25957: Unit test --- t/Koha/SearchEngine/Elasticsearch.t | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/t/Koha/SearchEngine/Elasticsearch.t b/t/Koha/SearchEngine/Elasticsearch.t index fede84ca34..bf6ade9d58 100644 --- a/t/Koha/SearchEngine/Elasticsearch.t +++ b/t/Koha/SearchEngine/Elasticsearch.t @@ -118,7 +118,7 @@ subtest 'get_elasticsearch_mappings() tests' => sub { subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' => sub { - plan tests => 53; + plan tests => 55; t::lib::Mocks::mock_preference('marcflavour', 'MARC21'); t::lib::Mocks::mock_preference('ElasticsearchMARCFormat', 'ISO2709'); @@ -554,6 +554,21 @@ subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' ok(defined $exception, "Exception has been thrown when processing mapping with unmatched closing parenthesis"); ok($exception->isa("Koha::Exceptions::Elasticsearch::MARCFieldExprParseError"), "Exception is of correct class"); ok($exception->message =~ /Unmatched closing parenthesis/, "Exception has the correct message"); + + pop @mappings; + my $marc_record_with_blank_field = MARC::Record->new(); + $marc_record_with_blank_field->leader(' cam 22 a 4500'); + + $marc_record_with_blank_field->append_fields( + MARC::Field->new('100', '', '', a => ''), + MARC::Field->new('210', '', '', a => 'Title 1'), + MARC::Field->new('245', '', '', a => 'Title:', b => 'large record'), + MARC::Field->new('999', '', '', c => '1234567'), + ); + $docs = $see->marc_records_to_documents([$marc_record_with_blank_field]); + is_deeply( $docs->[0]->{author},[],'No value placed into field if mapped marc field is blank'); + is_deeply( $docs->[0]->{author__suggestion},[],'No value placed into suggestion if mapped marc field is blank'); + }; subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents_array () tests' => sub { -- 2.11.0