3 # This Koha test module uses Test::MockModule to get around the need for known
4 # contents in the authority file by returning a single known authority record
5 # for every call to SearchAuthorities
16 use_ok
('Koha::SuggestionEngine');
19 my $module = new Test
::MockModule
('C4::AuthoritiesMarc');
20 $module->mock('SearchAuthorities', sub {
21 return [ { 'authid' => '1234',
22 'reported_tag' => undef,
25 'authorized' => [ { 'heading' => 'Cooking' } ],
27 'seefrom' => [ 'Cookery' ],
28 'notes' => [ 'Your quintessential poor heading selection' ],
32 'authtype' => 'Topical Term'
36 my $suggestor = Koha
::SuggestionEngine
->new( { plugins
=> [ 'AuthorityFile' ] } );
37 is
(ref($suggestor), 'Koha::SuggestionEngine', 'Created suggestion engine');
39 my $result = $suggestor->get_suggestions({search
=> 'Cookery'});
41 is_deeply
($result, [ { 'search' => 'an=1234', 'relevance' => 1, 'label' => 'Cooking' } ], "Suggested correct alternative to 'Cookery'");