Lines 7-18
use File::Basename;
Link Here
|
7 |
use File::Spec; |
7 |
use File::Spec; |
8 |
use Test::More; |
8 |
use Test::More; |
9 |
use Test::MockModule; |
9 |
use Test::MockModule; |
|
|
10 |
use Test::Warn; |
10 |
|
11 |
|
11 |
BEGIN { |
12 |
my $contextModule = new Test::MockModule('C4::Context'); |
12 |
use_ok('Koha::SuggestionEngine'); |
13 |
$contextModule->mock('preference', sub { |
|
|
14 |
return ''; |
15 |
}); |
16 |
$contextModule->mock('config', sub { |
17 |
my ($self,$key) = @_; |
18 |
if ($key eq 'opachtdocs') { |
19 |
return get_where() . '/koha-tmpl/opac-tmpl'; |
20 |
} elsif ($key eq 'intrahtdocs') { |
21 |
return get_where() . '/koha-tmpl/intranet-tmpl'; |
22 |
} else { |
23 |
return ''; |
24 |
} |
25 |
}); |
26 |
|
27 |
use_ok('Koha::SuggestionEngine'); |
28 |
|
29 |
sub get_where { |
30 |
my $location = File::Spec->rel2abs(dirname(__FILE__)); |
31 |
if ($location =~ /db_dependent/) { |
32 |
$location .= '/../..'; |
33 |
} |
34 |
else { |
35 |
$location .= '/..'; |
36 |
} |
37 |
return $location; |
13 |
} |
38 |
} |
14 |
|
39 |
|
15 |
my $langModule = new Test::MockModule('C4::Languages'); |
40 |
my $langModule; |
|
|
41 |
if (! defined $ENV{KOHA_CONF}) { |
42 |
warning_like { $langModule = new Test::MockModule('C4::Languages'); } |
43 |
qr /unable to locate Koha configuration file koha-conf.xml/, |
44 |
'Expected warning for unset $KOHA_CONF'; |
45 |
} |
46 |
else { |
47 |
$langModule = new Test::MockModule('C4::Languages'); |
48 |
} |
16 |
$langModule->mock('regex_lang_subtags', sub { |
49 |
$langModule->mock('regex_lang_subtags', sub { |
17 |
return { |
50 |
return { |
18 |
'extension' => undef, |
51 |
'extension' => undef, |
Lines 53-72
$langModule->mock('getTranslatedLanguages', sub {
Link Here
|
53 |
} |
86 |
} |
54 |
]; |
87 |
]; |
55 |
}); |
88 |
}); |
56 |
my $tmplModule = new Test::MockModule('C4::Templates'); |
89 |
my $tmplModule; |
|
|
90 |
if (! defined $ENV{KOHA_CONF}) { |
91 |
warning_like { $tmplModule = new Test::MockModule('C4::Templates'); } |
92 |
qr /unable to locate Koha configuration file koha-conf.xml/, |
93 |
'Expected warning for unset $KOHA_CONF'; |
94 |
} |
95 |
else { |
96 |
$tmplModule = new Test::MockModule('C4::Templates'); |
97 |
} |
57 |
$tmplModule->mock('_get_template_file', sub { |
98 |
$tmplModule->mock('_get_template_file', sub { |
58 |
my ($tmplbase, $interface, $query) = @_; |
99 |
my ($tmplbase, $interface, $query) = @_; |
59 |
my $opactmpl = File::Spec->rel2abs(dirname(__FILE__) . '/../../koha-tmpl/opac-tmpl'); |
100 |
my $opactmpl = get_where() . '/koha-tmpl/opac-tmpl'; |
60 |
return ($opactmpl, 'bootstrap', 'en', "$opactmpl/bootstrap/en/modules/$tmplbase"); |
101 |
return ($opactmpl, 'bootstrap', 'en', "$opactmpl/bootstrap/en/modules/$tmplbase"); |
61 |
}); |
102 |
}); |
62 |
my $contextModule = new Test::MockModule('C4::Context'); |
|
|
63 |
$contextModule->mock('preference', sub { |
64 |
return ''; |
65 |
}); |
66 |
$contextModule->mock('config', sub { |
67 |
return ''; |
68 |
}); |
69 |
|
70 |
|
103 |
|
71 |
my $suggestor = Koha::SuggestionEngine->new( { plugins => [ 'ExplodedTerms' ] } ); |
104 |
my $suggestor = Koha::SuggestionEngine->new( { plugins => [ 'ExplodedTerms' ] } ); |
72 |
is(ref($suggestor), 'Koha::SuggestionEngine', 'Created suggestion engine'); |
105 |
is(ref($suggestor), 'Koha::SuggestionEngine', 'Created suggestion engine'); |
73 |
- |
|
|