View | Details | Raw Unified | Return to bug 34978
Collapse All | Expand All

(-)a/Koha/Plugins.pm (-2 / +1 lines)
Lines 318-325 sub InstallPlugins { Link Here
318
        # Warn user if the specified classes doesn't exist and return nothing
318
        # Warn user if the specified classes doesn't exist and return nothing
319
        foreach my $class_name (@classes_filters) {
319
        foreach my $class_name (@classes_filters) {
320
            unless ( any { $class_name eq $_ } @plugin_classes ) {
320
            unless ( any { $class_name eq $_ } @plugin_classes ) {
321
                warn "$class_name has not been found, try a different name";
321
                Koha::Exceptions::BadParameter->throw("$class_name has not been found, try a different name");
322
                return;
323
            }
322
            }
324
        }
323
        }
325
324
(-)a/t/db_dependent/Koha/Plugins/Plugins.t (-4 / +17 lines)
Lines 27-32 use Test::MockModule; Link Here
27
use Test::NoWarnings;
27
use Test::NoWarnings;
28
use Test::More tests => 20;
28
use Test::More tests => 20;
29
use Test::Warn;
29
use Test::Warn;
30
use Test::Exception;
30
31
31
use C4::Context;
32
use C4::Context;
32
use Koha::Cache::Memory::Lite;
33
use Koha::Cache::Memory::Lite;
Lines 193-199 subtest 'GetPlugins() tests' => sub { Link Here
193
194
194
subtest 'InstallPlugins() tests' => sub {
195
subtest 'InstallPlugins() tests' => sub {
195
196
196
    plan tests => 4;
197
    plan tests => 6;
197
198
198
    $schema->storage->txn_begin;
199
    $schema->storage->txn_begin;
199
200
Lines 204-210 subtest 'InstallPlugins() tests' => sub { Link Here
204
    # Tests for the exclude parameter
205
    # Tests for the exclude parameter
205
    # Test the returned plugins of the InstallPlugins subroutine
206
    # Test the returned plugins of the InstallPlugins subroutine
206
    my $plugins           = Koha::Plugins->new( { enable_plugins => 1 } );
207
    my $plugins           = Koha::Plugins->new( { enable_plugins => 1 } );
207
    my @installed_plugins = $plugins->InstallPlugins( { exclude => [ "Test", "Koha::Plugin::MarcFieldValues" ] } );
208
    my @installed_plugins = $plugins->InstallPlugins( { exclude => [ "Koha::Plugin::Test", "Koha::Plugin::MarcFieldValues" ] } );
208
    my $plugin_classes    = join( " ", map { $_->{class} } @installed_plugins );
209
    my $plugin_classes    = join( " ", map { $_->{class} } @installed_plugins );
209
210
210
    my $result = grep { $plugin_classes !~ $_ } [ ":Test |:Test\$", ":MarcFieldValues |:MarcFieldValues\$" ]
211
    my $result = grep { $plugin_classes !~ $_ } [ ":Test |:Test\$", ":MarcFieldValues |:MarcFieldValues\$" ]
Lines 225-231 subtest 'InstallPlugins() tests' => sub { Link Here
225
226
226
    # Tests for the include parameter
227
    # Tests for the include parameter
227
    # Test the returned plugins of the InstallPlugins subroutine
228
    # Test the returned plugins of the InstallPlugins subroutine
228
    @installed_plugins = $plugins->InstallPlugins( { include => [ "Test", "Koha::Plugin::MarcFieldValues" ] } );
229
    @installed_plugins = $plugins->InstallPlugins( { include => [ "Koha::Plugin::Test", "Koha::Plugin::MarcFieldValues" ] } );
229
230
230
    $result = 1;
231
    $result = 1;
231
    foreach my $plugin_class ( map { $_->{class} } @installed_plugins ) {
232
    foreach my $plugin_class ( map { $_->{class} } @installed_plugins ) {
Lines 242-247 subtest 'InstallPlugins() tests' => sub { Link Here
242
    }
243
    }
243
    ok( $result, "Only included plugins are installed" );
244
    ok( $result, "Only included plugins are installed" );
244
245
246
    # Tests when both include and exclude parameter are used simultaneously
247
    throws_ok
248
        {
249
            $plugins->InstallPlugins( { exclude => [ "Koha::Plugin::Test" ], include => [ "Koha::Plugin::Test" ] } );
250
        }
251
        'Koha::Exceptions::BadParameter';
252
    # Tests when the plugin to be installled is not found
253
    throws_ok
254
        {
255
            $plugins->InstallPlugins( { include => [ "Koha::Plugin::NotfoundPlugin" ] } );
256
        }
257
        'Koha::Exceptions::BadParameter';
258
245
    $schema->storage->txn_rollback;
259
    $schema->storage->txn_rollback;
246
};
260
};
247
261
248
- 

Return to bug 34978