Lines 24-30
use File::Temp qw( tempdir tempfile );
Link Here
|
24 |
use FindBin qw($Bin); |
24 |
use FindBin qw($Bin); |
25 |
use Module::Load::Conditional qw(can_load); |
25 |
use Module::Load::Conditional qw(can_load); |
26 |
use Test::MockModule; |
26 |
use Test::MockModule; |
27 |
use Test::More tests => 18; |
27 |
use Test::More tests => 30; |
28 |
use Test::Warn; |
28 |
use Test::Warn; |
29 |
|
29 |
|
30 |
use C4::Context; |
30 |
use C4::Context; |
Lines 185-190
subtest 'GetPlugins() tests' => sub {
Link Here
|
185 |
$schema->storage->txn_rollback; |
185 |
$schema->storage->txn_rollback; |
186 |
}; |
186 |
}; |
187 |
|
187 |
|
|
|
188 |
subtest 'InstallPlugins() tests' => sub { |
189 |
|
190 |
plan tests => 4; |
191 |
|
192 |
$schema->storage->txn_begin; |
193 |
|
194 |
# Temporarily remove any installed plugins data |
195 |
Koha::Plugins::Methods->delete; |
196 |
$schema->resultset('PluginData')->delete; |
197 |
|
198 |
# Tests for the exclude paramater |
199 |
# Test the returned plugins of the InstallPlugins subroutine |
200 |
my $plugins = Koha::Plugins->new({ enable_plugins => 1 }); |
201 |
my @installed_plugins = $plugins->InstallPlugins({ exclude => ["Test", "Koha::Plugin::MarcFieldValues"] }); |
202 |
my $plugin_classes = join(" ", map{$_->{class}} @installed_plugins); |
203 |
|
204 |
my $result = grep { $plugin_classes !~ $_ } [":Test |:Test\$", ":MarcFieldValues |:MarcFieldValues\$"] |
205 |
&& $plugin_classes =~ ":TestItemBarcodeTransform |:TestItemBarcodeTransform\$"; |
206 |
ok($result, "Excluded plugins are not returned"); |
207 |
|
208 |
# Test the plugins in the database |
209 |
my @plugins = $plugins->GetPlugins({ all => 1, error => 1 }); |
210 |
$plugin_classes = join(" ", map{$_->{class}} @plugins); |
211 |
|
212 |
$result = grep { $plugin_classes !~ $_ } [":Test |:Test\$", ":MarcFieldValues |:MarcFieldValues\$"] |
213 |
&& $plugin_classes =~ ":TestItemBarcodeTransform |:TestItemBarcodeTransform\$"; |
214 |
ok($result, "Excluded plugins are not installed"); |
215 |
|
216 |
# Remove installed plugins data |
217 |
Koha::Plugins::Methods->delete; |
218 |
$schema->resultset('PluginData')->delete; |
219 |
|
220 |
# Tests for the include parameter |
221 |
# Test the returned plugins of the InstallPlugins subroutine |
222 |
@installed_plugins = $plugins->InstallPlugins({ include => ["Test", "Koha::Plugin::MarcFieldValues"]}); |
223 |
|
224 |
$result = 1; |
225 |
foreach my $plugin_class ( map{ $_->{class} } @installed_plugins ) { |
226 |
$result = 0 unless("$plugin_class" =~ ":Test\$" || "$plugin_class" =~ ":MarcFieldValues\$"); |
227 |
} |
228 |
ok($result, "Only included plugins are returned"); |
229 |
|
230 |
# Test the plugins in the database |
231 |
@plugins = $plugins->GetPlugins({ all => 1, error => 1}); |
232 |
|
233 |
$result = 1; |
234 |
foreach my $plugin_class ( map{ $_->{class} } @plugins ) { |
235 |
$result = 0 unless("$plugin_class" =~ ":Test\$" || "$plugin_class" =~ ":MarcFieldValues\$"); |
236 |
} |
237 |
ok($result, "Only included plugins are installed"); |
238 |
|
239 |
$schema->storage->txn_rollback; |
240 |
}; |
241 |
|
188 |
subtest 'Version upgrade tests' => sub { |
242 |
subtest 'Version upgrade tests' => sub { |
189 |
|
243 |
|
190 |
plan tests => 1; |
244 |
plan tests => 1; |
191 |
- |
|
|