From db4e0fdfc6f0f612fa533609dcf5c818fccb2984 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 10 May 2019 11:52:34 -0300 Subject: [PATCH] Bug 22053: (QA follow-up) Fix tests This patch makes the tests enable the plugins that are required for them. Otherwise unexpected failures can happen Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/ImportBatch.t | 3 ++- t/db_dependent/Koha/Template/Plugin/KohaPlugins.t | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/t/db_dependent/ImportBatch.t b/t/db_dependent/ImportBatch.t index f42e0d8822..bcc25ef9d1 100644 --- a/t/db_dependent/ImportBatch.t +++ b/t/db_dependent/ImportBatch.t @@ -187,7 +187,8 @@ subtest "RecordsFromMarcPlugin" => sub { close $fh; t::lib::Mocks::mock_config( 'enable_plugins', 1 ); - my ( $plugin ) = Koha::Plugins->new->GetPlugins({ metadata => { name => 'MarcFieldValues' } }); + t::lib::Mocks::mock_preference( 'UseKohaPlugins', 1 ); + my ($plugin) = Koha::Plugins->new->GetPlugins({ all => 1, metadata => { name => 'MarcFieldValues' } }); isnt( $plugin, undef, "Plugin found" ); my $records = C4::ImportBatch::RecordsFromMarcPlugin( $name, ref $plugin, 'UTF-8' ); is( @$records, 2, 'Two results returned' ); diff --git a/t/db_dependent/Koha/Template/Plugin/KohaPlugins.t b/t/db_dependent/Koha/Template/Plugin/KohaPlugins.t index b0d50e66a0..5ecc1cdb37 100755 --- a/t/db_dependent/Koha/Template/Plugin/KohaPlugins.t +++ b/t/db_dependent/Koha/Template/Plugin/KohaPlugins.t @@ -24,6 +24,16 @@ BEGIN { use_ok('Koha::Plugin::Test'); } +t::lib::Mocks::mock_preference( 'UseKohaPlugins', 1 ); +t::lib::Mocks::mock_config( 'enable_plugins', 1 ); + +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; + +# Enable all plugins +my @plugins = Koha::Plugins->new->GetPlugins({ all => 1, class => 'Koha::Plugin::Test' }); +map { $_->enable; } @plugins; + my $mock_plugin = Test::MockModule->new( 'Koha::Plugin::Test' ); $mock_plugin->mock( 'test_template', sub { my ( $self, $file ) = @_; @@ -36,8 +46,6 @@ use_ok( 'Koha::Template::Plugin::KohaPlugins', 'Can use Koha::Template::Plugin:: ok( my $plugin = Koha::Template::Plugin::KohaPlugins->new(), 'Able to instantiate template plugin' ); -t::lib::Mocks::mock_preference('UseKohaPlugins',1); -t::lib::Mocks::mock_config('enable_plugins',1); ok( index( $plugin->get_plugins_opac_js, 'Koha::Plugin::Test::opac_js' ) != -1, 'Test plugin opac_js return value is part of code returned by get_plugins_opac_js' ); ok( index( $plugin->get_plugins_opac_head, 'Koha::Plugin::Test::opac_head' ) != -1, 'Test plugin opac_head return value is part of code returned by get_plugins_opac_head' ); ok( index( $plugin->get_plugins_intranet_js, 'Koha::Plugin::Test::intranet_js' ) != -1, 'Test plugin intranet_js return value is part of code returned by get_plugins_intranet_js' ); @@ -49,3 +57,5 @@ is( $plugin->get_plugins_opac_js, q{}, 'Test plugin opac_js return value is empt is( $plugin->get_plugins_opac_head, q{}, 'Test plugin opac_head return value is empty' ); is( $plugin->get_plugins_intranet_js, q{}, 'Test plugin intranet_js return value is empty' ); is( $plugin->get_plugins_intranet_head, q{}, 'Test plugin intranet_head return value is empty' ); + +$schema->storage->txn_rollback; -- 2.21.0