View | Details | Raw Unified | Return to bug 18235
Collapse All | Expand All

(-)a/t/db_dependent/Koha_Elasticsearch.t (-2 / +108 lines)
Lines 17-29 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 2;
20
use Test::More tests => 3;
21
use Test::MockModule;
21
use Test::MockModule;
22
22
23
use t::lib::Mocks;
23
use t::lib::Mocks;
24
use t::lib::TestBuilder;
24
use MARC::Record;
25
use MARC::Record;
25
26
27
use Koha::SearchFields;
28
26
my $schema = Koha::Database->schema;
29
my $schema = Koha::Database->schema;
30
my $builder = t::lib::TestBuilder->new;
27
31
28
use_ok('Koha::SearchEngine::Elasticsearch');
32
use_ok('Koha::SearchEngine::Elasticsearch');
29
33
Lines 162-164 subtest 'get_fixer_rules() tests' => sub { Link Here
162
    $schema->storage->txn_rollback;
166
    $schema->storage->txn_rollback;
163
167
164
};
168
};
165
- 
169
170
subtest 'get_facetable_fields() tests' => sub {
171
172
    plan tests => 15;
173
174
    $schema->storage->txn_begin;
175
176
    Koha::SearchFields->search()->delete;
177
178
    $builder->build({
179
        source => 'SearchField',
180
        value => {
181
            name => 'author',
182
            label => 'author',
183
            type => 'string',
184
            facet_order => undef
185
        }
186
    });
187
    $builder->build({
188
        source => 'SearchField',
189
        value => {
190
            name => 'holdingbranch',
191
            label => 'holdingbranch',
192
            type => 'string',
193
            facet_order => 1
194
        }
195
    });
196
    $builder->build({
197
        source => 'SearchField',
198
        value => {
199
            name => 'homebranch',
200
            label => 'homebranch',
201
            type => 'string',
202
            facet_order => 2
203
        }
204
    });
205
    $builder->build({
206
        source => 'SearchField',
207
        value => {
208
            name => 'itype',
209
            label => 'itype',
210
            type => 'string',
211
            facet_order => 3
212
        }
213
    });
214
    $builder->build({
215
        source => 'SearchField',
216
        value => {
217
            name => 'se',
218
            label => 'se',
219
            type => 'string',
220
            facet_order => 4
221
        }
222
    });
223
    $builder->build({
224
        source => 'SearchField',
225
        value => {
226
            name => 'su-geo',
227
            label => 'su-geo',
228
            type => 'string',
229
            facet_order => 5
230
        }
231
    });
232
    $builder->build({
233
        source => 'SearchField',
234
        value => {
235
            name => 'subject',
236
            label => 'subject',
237
            type => 'string',
238
            facet_order => 6
239
        }
240
    });
241
    $builder->build({
242
        source => 'SearchField',
243
        value => {
244
            name => 'not_facetable_field',
245
            label => 'not_facetable_field',
246
            type => 'string',
247
            facet_order => undef
248
        }
249
    });
250
251
    my @faceted_fields = Koha::SearchEngine::Elasticsearch->get_facetable_fields();
252
    is(scalar(@faceted_fields), 7);
253
254
    is($faceted_fields[0]->name, 'holdingbranch');
255
    is($faceted_fields[0]->facet_order, 1);
256
    is($faceted_fields[1]->name, 'homebranch');
257
    is($faceted_fields[1]->facet_order, 2);
258
    is($faceted_fields[2]->name, 'itype');
259
    is($faceted_fields[2]->facet_order, 3);
260
    is($faceted_fields[3]->name, 'se');
261
    is($faceted_fields[3]->facet_order, 4);
262
    is($faceted_fields[4]->name, 'su-geo');
263
    is($faceted_fields[4]->facet_order, 5);
264
    is($faceted_fields[5]->name, 'subject');
265
    is($faceted_fields[5]->facet_order, 6);
266
    is($faceted_fields[6]->name, 'author');
267
    ok(!$faceted_fields[6]->facet_order);
268
269
270
    $schema->storage->txn_rollback;
271
};

Return to bug 18235