From 1cd1fcc9d72fc031f1aba42eee7e79040f758569 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 30 Apr 2019 10:54:01 -0300 Subject: [PATCH] Bug 22053: (QA follow-up) Override enable_plugins configuration This patch makes the update script override the configured enable_plugins setting in koha-conf.xml. on testing the failure I wrote trivial tests on how Koha::Plugins->new({ enable_plugins => 1 }) should work. Adding them to this patch as well. Signed-off-by: Tomas Cohen Arazi Signed-off-by: Nick Clemens --- .../mysql/atomicupdate/bug_22053_enable-all-plugins.perl | 4 ++-- t/db_dependent/Plugins.t | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug_22053_enable-all-plugins.perl b/installer/data/mysql/atomicupdate/bug_22053_enable-all-plugins.perl index 63ef70a1d0..206ed6f5ce 100644 --- a/installer/data/mysql/atomicupdate/bug_22053_enable-all-plugins.perl +++ b/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"; -} \ No newline at end of file +} diff --git a/t/db_dependent/Plugins.t b/t/db_dependent/Plugins.t index e89cebe0b3..8e45e078af 100755 --- a/t/db_dependent/Plugins.t +++ b/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' ); +}; -- 2.11.4.GIT