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;
27 my $schema = Koha::Database->schema;
28 my $builder = t::lib::TestBuilder->new;
30 subtest 'get_facetable_fields() tests' => sub {
34 $schema->storage->txn_begin;
36 Koha::SearchFields->search()->delete;
39 source => 'SearchField',
48 source => 'SearchField',
50 name => 'holdingbranch',
51 label => 'holdingbranch',
57 source => 'SearchField',
60 label => 'homebranch',
66 source => 'SearchField',
75 source => 'SearchField',
84 source => 'SearchField',
93 source => 'SearchField',
102 source => 'SearchField',
104 name => 'not_facetable_field',
105 label => 'not_facetable_field',
111 my @faceted_fields = Koha::SearchEngine::Elasticsearch->get_facetable_fields();
112 is(scalar(@faceted_fields), 7);
114 is($faceted_fields[0]->name, 'holdingbranch');
115 is($faceted_fields[0]->facet_order, 1);
116 is($faceted_fields[1]->name, 'homebranch');
117 is($faceted_fields[1]->facet_order, 2);
118 is($faceted_fields[2]->name, 'itype');
119 is($faceted_fields[2]->facet_order, 3);
120 is($faceted_fields[3]->name, 'se');
121 is($faceted_fields[3]->facet_order, 4);
122 is($faceted_fields[4]->name, 'su-geo');
123 is($faceted_fields[4]->facet_order, 5);
124 is($faceted_fields[5]->name, 'subject');
125 is($faceted_fields[5]->facet_order, 6);
126 is($faceted_fields[6]->name, 'author');
127 ok(!$faceted_fields[6]->facet_order);
130 $schema->storage->txn_rollback;