Koha/t/db_dependent/SuggestionEngine_ExplodedTerms.t
Robin Sheat 2b72cc9c21 Bug 8890 - move two more db dependent tests
* t/AuthoritiesMarc.t
* t/SuggestionEngine_ExplodedTerms.t

Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
2012-10-24 17:52:42 +02:00

31 lines
1.1 KiB
Perl
Executable file

#!/usr/bin/perl
use strict;
use warnings;
use Test::More;
BEGIN {
use_ok('Koha::SuggestionEngine');
}
my $suggestor = Koha::SuggestionEngine->new( { plugins => [ 'ExplodedTerms' ] } );
is(ref($suggestor), 'Koha::SuggestionEngine', 'Created suggestion engine');
my $result = $suggestor->get_suggestions({search => 'Cookery'});
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'");
$result = $suggestor->get_suggestions({search => 'su:Cookery'});
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'");
$result = $suggestor->get_suggestions({search => 'nt:Cookery'});
is(scalar @$result, 0, "No suggestions for fielded search");
$result = $suggestor->get_suggestions({search => 'ccl=su:Cookery'});
is(scalar @$result, 0, "No suggestions for CCL search");
done_testing();