3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 use Test::More tests => 4;
44 my $yaml = Test::MockModule->new('YAML::Syck');
45 $yaml->mock( 'LoadFile', sub { return $indexes; } );
47 use_ok('Koha::SearchEngine::Elasticsearch');
49 my $schema = Koha::Database->new->schema;
51 Koha::SearchFields->search->delete;
52 Koha::SearchMarcMaps->search->delete;
53 $schema->resultset('SearchMarcToField')->search->delete;
55 Koha::SearchEngine::Elasticsearch->reset_elasticsearch_mappings;
57 my $search_fields = Koha::SearchFields->search({});
58 is($search_fields->count, 2, 'There is 2 search fields after reset');
60 my $match_sf = Koha::SearchFields->search({ name => 'Match' })->next;
61 is($match_sf->weight, '15.00', 'Match search field is weighted with 15');
63 my $title_sf = Koha::SearchFields->search({ name => 'title' })->next;
64 is($title_sf->weight, '20.00', 'Title search field is weighted with 20');
66 $schema->storage->txn_begin;