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 <tomascohen@theke.io>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
Tomas Cohen Arazi 2019-04-30 10:54:01 -03:00 committed by Nick Clemens
parent 4aa2e16ec1
commit 1cd1fcc9d7
2 changed files with 17 additions and 3 deletions

View File

@ -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";
}
}

View File

@ -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' );
};