Lines 26-31
use Module::Load::Conditional qw(can_load);
Link Here
|
26 |
use Test::MockModule; |
26 |
use Test::MockModule; |
27 |
use Test::More tests => 19; |
27 |
use Test::More tests => 19; |
28 |
use Test::Warn; |
28 |
use Test::Warn; |
|
|
29 |
use Test::Exception; |
29 |
|
30 |
|
30 |
use C4::Context; |
31 |
use C4::Context; |
31 |
use Koha::Cache::Memory::Lite; |
32 |
use Koha::Cache::Memory::Lite; |
Lines 187-193
subtest 'GetPlugins() tests' => sub {
Link Here
|
187 |
|
188 |
|
188 |
subtest 'InstallPlugins() tests' => sub { |
189 |
subtest 'InstallPlugins() tests' => sub { |
189 |
|
190 |
|
190 |
plan tests => 4; |
191 |
plan tests => 6; |
191 |
|
192 |
|
192 |
$schema->storage->txn_begin; |
193 |
$schema->storage->txn_begin; |
193 |
|
194 |
|
Lines 198-204
subtest 'InstallPlugins() tests' => sub {
Link Here
|
198 |
# Tests for the exclude parameter |
199 |
# Tests for the exclude parameter |
199 |
# Test the returned plugins of the InstallPlugins subroutine |
200 |
# Test the returned plugins of the InstallPlugins subroutine |
200 |
my $plugins = Koha::Plugins->new( { enable_plugins => 1 } ); |
201 |
my $plugins = Koha::Plugins->new( { enable_plugins => 1 } ); |
201 |
my @installed_plugins = $plugins->InstallPlugins( { exclude => [ "Test", "Koha::Plugin::MarcFieldValues" ] } ); |
202 |
my @installed_plugins = $plugins->InstallPlugins( { exclude => [ "Koha::Plugin::Test", "Koha::Plugin::MarcFieldValues" ] } ); |
202 |
my $plugin_classes = join( " ", map { $_->{class} } @installed_plugins ); |
203 |
my $plugin_classes = join( " ", map { $_->{class} } @installed_plugins ); |
203 |
|
204 |
|
204 |
my $result = grep { $plugin_classes !~ $_ } [ ":Test |:Test\$", ":MarcFieldValues |:MarcFieldValues\$" ] |
205 |
my $result = grep { $plugin_classes !~ $_ } [ ":Test |:Test\$", ":MarcFieldValues |:MarcFieldValues\$" ] |
Lines 219-225
subtest 'InstallPlugins() tests' => sub {
Link Here
|
219 |
|
220 |
|
220 |
# Tests for the include parameter |
221 |
# Tests for the include parameter |
221 |
# Test the returned plugins of the InstallPlugins subroutine |
222 |
# Test the returned plugins of the InstallPlugins subroutine |
222 |
@installed_plugins = $plugins->InstallPlugins( { include => [ "Test", "Koha::Plugin::MarcFieldValues" ] } ); |
223 |
@installed_plugins = $plugins->InstallPlugins( { include => [ "Koha::Plugin::Test", "Koha::Plugin::MarcFieldValues" ] } ); |
223 |
|
224 |
|
224 |
$result = 1; |
225 |
$result = 1; |
225 |
foreach my $plugin_class ( map { $_->{class} } @installed_plugins ) { |
226 |
foreach my $plugin_class ( map { $_->{class} } @installed_plugins ) { |
Lines 236-241
subtest 'InstallPlugins() tests' => sub {
Link Here
|
236 |
} |
237 |
} |
237 |
ok( $result, "Only included plugins are installed" ); |
238 |
ok( $result, "Only included plugins are installed" ); |
238 |
|
239 |
|
|
|
240 |
# Tests when both include and exclude parameter are used simultaneously |
241 |
throws_ok |
242 |
{ |
243 |
$plugins->InstallPlugins( { exclude => [ "Koha::Plugin::Test" ], include => [ "Koha::Plugin::Test" ] } ); |
244 |
} |
245 |
'Koha::Exceptions::BadParameter'; |
246 |
# Tests when the plugin to be installled is not found |
247 |
throws_ok |
248 |
{ |
249 |
$plugins->InstallPlugins( { include => [ "Koha::Plugin::NotfoundPlugin" ] } ); |
250 |
} |
251 |
'Koha::Exceptions::BadParameter'; |
252 |
|
239 |
$schema->storage->txn_rollback; |
253 |
$schema->storage->txn_rollback; |
240 |
}; |
254 |
}; |
241 |
|
255 |
|
242 |
- |
|
|