Bug 12214: (follow-up) Clean up reports-toolbar.inc, show Edit link when SQL has...
[koha.git] / t / SuggestionEngine_AuthorityFile.t
blob18a6e42037534a53d515a4f5fc61e4c8fbbe2f1c
1 #!/usr/bin/perl
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
7 use strict;
8 use warnings;
9 use File::Spec;
10 use MARC::Record;
12 use Test::More;
13 use Test::MockModule;
15 BEGIN {
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,
23 'even' => 0,
24 'summary' => {
25 'authorized' => [ { 'heading' => 'Cooking' } ],
26 'otherscript' => [],
27 'seefrom' => [ 'Cookery' ],
28 'notes' => [ 'Your quintessential poor heading selection' ],
29 'seealso' => []
31 'used' => 1,
32 'authtype' => 'Topical Term'
33 } ], 1
34 });
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'");
43 done_testing();