Merge remote-tracking branch 'origin/new/bug_8623'
[koha.git] / t / SuggestionEngine_ExplodedTerms.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More;
7
8 BEGIN {
9         use_ok('Koha::SuggestionEngine');
10 }
11
12 my $suggestor = Koha::SuggestionEngine->new( { plugins => [ 'ExplodedTerms' ] } );
13 is(ref($suggestor), 'Koha::SuggestionEngine', 'Created suggestion engine');
14
15 my $result = $suggestor->get_suggestions({search => 'Cookery'});
16
17 ok((grep { $_->{'search'} eq 'su-na=Cookery' } @$result) && (grep { $_->{'search'} eq 'su-br=Cookery' } @$result) && (grep { $_->{'search'} eq 'su-rl=Cookery' } @$result), "Suggested correct alternatives for keyword search 'Cookery'");
18
19 $result = $suggestor->get_suggestions({search => 'su:Cookery'});
20
21 ok((grep { $_->{'search'} eq 'su-na=Cookery' } @$result) && (grep { $_->{'search'} eq 'su-br=Cookery' } @$result) && (grep { $_->{'search'} eq 'su-rl=Cookery' } @$result), "Suggested correct alternatives for subject search 'Cookery'");
22
23 $result = $suggestor->get_suggestions({search => 'nt:Cookery'});
24
25 is(scalar @$result, 0, "No suggestions for fielded search");
26
27 $result = $suggestor->get_suggestions({search => 'ccl=su:Cookery'});
28
29 is(scalar @$result, 0, "No suggestions for CCL search");
30
31 done_testing();