bug 8215: (followup) make sure C4::CourseReserves doesn't export anything
[koha.git] / t / SuggestionEngine_AuthorityFile.t
1 #!/usr/bin/perl
2 #
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
6
7 use strict;
8 use warnings;
9 use File::Spec;
10 use MARC::Record;
11
12 use Test::More;
13 use Test::MockModule;
14
15 BEGIN {
16         use_ok('Koha::SuggestionEngine');
17 }
18
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' => []
30                     },
31                     'used' => 1,
32                     'authtype' => 'Topical Term'
33                 } ], 1
34 });
35
36 my $suggestor = Koha::SuggestionEngine->new( { plugins => [ 'AuthorityFile' ] } );
37 is(ref($suggestor), 'Koha::SuggestionEngine', 'Created suggestion engine');
38
39 my $result = $suggestor->get_suggestions({search => 'Cookery'});
40
41 is_deeply($result, [ { 'search' => 'an=1234', 'relevance' => 1, 'label' => 'Cooking' } ], "Suggested correct alternative to 'Cookery'");
42
43 done_testing();