@@ -, +, @@ is not found and fix unit test --- Koha/Plugins.pm | 3 +-- t/db_dependent/Koha/Plugins/Plugins.t | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) --- a/Koha/Plugins.pm +++ a/Koha/Plugins.pm @@ -311,8 +311,7 @@ sub InstallPlugins { # Warn user if the specified classes doesn't exist and return nothing foreach my $class_name (@classes_filters) { unless ( any { $class_name eq $_ } @plugin_classes ) { - warn "$class_name has not been found, try a different name"; - return; + Koha::Exceptions::BadParameter->throw("$class_name has not been found, try a different name"); } } --- a/t/db_dependent/Koha/Plugins/Plugins.t +++ a/t/db_dependent/Koha/Plugins/Plugins.t @@ -26,6 +26,7 @@ use Module::Load::Conditional qw(can_load); use Test::MockModule; use Test::More tests => 19; use Test::Warn; +use Test::Exception; use C4::Context; use Koha::Cache::Memory::Lite; @@ -187,7 +188,7 @@ subtest 'GetPlugins() tests' => sub { subtest 'InstallPlugins() tests' => sub { - plan tests => 4; + plan tests => 6; $schema->storage->txn_begin; @@ -198,7 +199,7 @@ subtest 'InstallPlugins() tests' => sub { # Tests for the exclude parameter # Test the returned plugins of the InstallPlugins subroutine my $plugins = Koha::Plugins->new( { enable_plugins => 1 } ); - my @installed_plugins = $plugins->InstallPlugins( { exclude => [ "Test", "Koha::Plugin::MarcFieldValues" ] } ); + my @installed_plugins = $plugins->InstallPlugins( { exclude => [ "Koha::Plugin::Test", "Koha::Plugin::MarcFieldValues" ] } ); my $plugin_classes = join( " ", map { $_->{class} } @installed_plugins ); my $result = grep { $plugin_classes !~ $_ } [ ":Test |:Test\$", ":MarcFieldValues |:MarcFieldValues\$" ] @@ -219,7 +220,7 @@ subtest 'InstallPlugins() tests' => sub { # Tests for the include parameter # Test the returned plugins of the InstallPlugins subroutine - @installed_plugins = $plugins->InstallPlugins( { include => [ "Test", "Koha::Plugin::MarcFieldValues" ] } ); + @installed_plugins = $plugins->InstallPlugins( { include => [ "Koha::Plugin::Test", "Koha::Plugin::MarcFieldValues" ] } ); $result = 1; foreach my $plugin_class ( map { $_->{class} } @installed_plugins ) { @@ -236,6 +237,19 @@ subtest 'InstallPlugins() tests' => sub { } ok( $result, "Only included plugins are installed" ); + # Tests when both include and exclude parameter are used simultaneously + throws_ok + { + $plugins->InstallPlugins( { exclude => [ "Koha::Plugin::Test" ], include => [ "Koha::Plugin::Test" ] } ); + } + 'Koha::Exceptions::BadParameter'; + # Tests when the plugin to be installled is not found + throws_ok + { + $plugins->InstallPlugins( { include => [ "Koha::Plugin::NotfoundPlugin" ] } ); + } + 'Koha::Exceptions::BadParameter'; + $schema->storage->txn_rollback; }; --