@@ -, +, @@ configuration --- .../bug_22053_enable-all-plugins.perl | 4 ++-- t/db_dependent/Plugins.t | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) --- a/installer/data/mysql/atomicupdate/bug_22053_enable-all-plugins.perl +++ a/installer/data/mysql/atomicupdate/bug_22053_enable-all-plugins.perl @@ -3,7 +3,7 @@ if( CheckVersion( $DBversion ) ) { use Koha::Plugins; - my @plugins = Koha::Plugins->new()->GetPlugins({ all => 1 }); + my @plugins = Koha::Plugins->new({ enable_plugins => 1 })->GetPlugins({ all => 1 }); foreach my $plugin ( @plugins ) { $plugin->enable; } @@ -11,4 +11,4 @@ if( CheckVersion( $DBversion ) ) { # Always end with this (adjust the bug info) SetVersion( $DBversion ); print "Upgrade to $DBversion done (Bug 22053 - enable all plugins)\n"; -} +} --- a/t/db_dependent/Plugins.t +++ a/t/db_dependent/Plugins.t @@ -9,7 +9,7 @@ use File::Temp qw( tempdir tempfile ); use FindBin qw($Bin); use Module::Load::Conditional qw(can_load); use Test::MockModule; -use Test::More tests => 46; +use Test::More tests => 47; use C4::Context; use Koha::Database; @@ -209,3 +209,17 @@ subtest 'Test _version_compare' => sub { is( Koha::Plugins::Base::_version_compare( '1', '1.0.0' ), 0, "1 is equal to 1.0.0" ); is( Koha::Plugins::Base::_version_compare( '1.0', '1.0.0' ), 0, "1.0 is equal to 1.0.0" ); }; + +subtest 'new() tests' => sub { + + plan tests => 2; + + t::lib::Mocks::mock_config( 'pluginsdir', [ C4::Context->temporary_directory ] ); + t::lib::Mocks::mock_config( 'enable_plugins', 0 ); + + my $result = Koha::Plugins->new(); + is( $result, undef, 'calling new() on disabled plugins returns undef' ); + + $result = Koha::Plugins->new({ enable_plugins => 1 }); + is( ref($result), 'Koha::Plugins', 'calling new with enable_plugins makes it override the config' ); +}; --