From 945e88e2b81305ca775e0b680fed1871d24d67fb Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 7 Apr 2020 13:09:47 +0000 Subject: [PATCH] Bug 24807: Update tests --- t/Koha/SearchEngine/Elasticsearch.t | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/t/Koha/SearchEngine/Elasticsearch.t b/t/Koha/SearchEngine/Elasticsearch.t index d2e2bed680..5c1e06f776 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 => 56; + plan tests => 57; t::lib::Mocks::mock_preference('marcflavour', 'MARC21'); t::lib::Mocks::mock_preference('ElasticsearchMARCFormat', 'ISO2709'); @@ -285,6 +285,16 @@ subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' marc_field => '952l', }, { + name => 'copydate', + type => 'year', + facet => 0, + suggestible => 0, + searchable => 1, + sort => 1, + marc_type => 'marc21', + marc_field => '260c', + }, + { name => 'date-of-publication', type => 'year', facet => 0, @@ -333,6 +343,7 @@ subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' MARC::Field->new('210', '', '', a => 'Title 1'), MARC::Field->new('240', '', '4', a => 'The uniform title with nonfiling indicator'), MARC::Field->new('245', '', '', a => 'Title:', b => 'first record'), + MARC::Field->new('260', '', '', a => 'New York :', b => 'Ace ,', c => 'c1962'), MARC::Field->new('999', '', '', c => '1234567'), # ' ' for testing trimming of white space in boolean value callback: MARC::Field->new('952', '', '', 0 => ' ', g => '123.30', o => $callno, l => 3), @@ -346,6 +357,7 @@ subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' MARC::Field->new('100', '', '', a => 'Author 2'), # MARC::Field->new('210', '', '', a => 'Title 2'), # MARC::Field->new('245', '', '', a => 'Title: second record'), + MARC::Field->new('260', '', '', a => 'New York :', b => 'Ace ,', c => '1963-2003'), MARC::Field->new('999', '', '', c => '1234568'), MARC::Field->new('952', '', '', 0 => 1, g => 'string where should be numeric', o => $long_callno), ); @@ -469,8 +481,12 @@ subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' 'First document uniform_title__sort field should contain the title with the first four initial characters removed' ); # Tests for 'year' type and 'filter_callbacks' - is(scalar @{$docs->[0]->{'date-of-publication'}}, 1, 'First document date-of-publication field should contain one value'); is_deeply($docs->[0]->{'date-of-publication'}, ['1962'], 'First document date-of-publication field should be set correctly'); + is_deeply( + $docs->[0]->{'copydate'}, + ['1962'], + 'First document copydate field should be set correctly' + ); # Second record: @@ -497,7 +513,16 @@ subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' ); # Tests for 'year' type and 'filter_callbacks' - ok(!(defined $docs->[1]->{'date-of-publication'}), "Second document invalid date-of-publication value should have been removed"); + is_deeply( + $docs->[1]->{'copydate'}, + ['1963','2003'], + 'Second document copydate field should be set correctly' + ); + is_deeply( + $docs->[1]->{'date-of-publication'}, + ['1900'], + 'Second document date-of-publication field should be set correctly' + ); # Mappings marc_type: -- 2.11.0