1 # This file is part of Koha.
3 # Koha is free software; you can redistribute it and/or modify it
4 # under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # Koha is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with Koha; if not, see <http://www.gnu.org/licenses>
18 use Test::More tests => 1;
22 use t::lib::TestBuilder;
25 use Koha::SearchFields;
26 use Koha::SearchEngine::Elasticsearch;
28 my $schema = Koha::Database->schema;
29 my $builder = t::lib::TestBuilder->new;
31 subtest 'get_facetable_fields() tests' => sub {
35 $schema->storage->txn_begin;
37 Koha::SearchFields->search()->delete;
40 source => 'SearchField',
49 source => 'SearchField',
51 name => 'holdingbranch',
52 label => 'holdingbranch',
58 source => 'SearchField',
61 label => 'homebranch',
67 source => 'SearchField',
76 source => 'SearchField',
78 name => 'title-series',
79 label => 'titles-series',
85 source => 'SearchField',
94 source => 'SearchField',
103 source => 'SearchField',
105 name => 'not_facetable_field',
106 label => 'not_facetable_field',
112 my @faceted_fields = Koha::SearchEngine::Elasticsearch->get_facetable_fields();
113 is(scalar(@faceted_fields), 7);
115 is($faceted_fields[0]->name, 'holdingbranch');
116 is($faceted_fields[0]->facet_order, 1);
117 is($faceted_fields[1]->name, 'homebranch');
118 is($faceted_fields[1]->facet_order, 2);
119 is($faceted_fields[2]->name, 'itype');
120 is($faceted_fields[2]->facet_order, 3);
121 is($faceted_fields[3]->name, 'title-series');
122 is($faceted_fields[3]->facet_order, 4);
123 is($faceted_fields[4]->name, 'su-geo');
124 is($faceted_fields[4]->facet_order, 5);
125 is($faceted_fields[5]->name, 'subject');
126 is($faceted_fields[5]->facet_order, 6);
127 is($faceted_fields[6]->name, 'author');
128 ok(!$faceted_fields[6]->facet_order);
131 $schema->storage->txn_rollback;