From 7e53cc7bd7634bfc19c9eb52ba83566cc35f44c9 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 14 Jun 2019 16:51:07 -0300 Subject: [PATCH] Bug 21073: (QA follow-up) Only public subs should be considered Signed-off-by: Tomas Cohen Arazi Signed-off-by: Kyle M Hall --- Koha/Plugins.pm | 2 +- t/db_dependent/Plugins.t | 5 +++-- t/lib/Koha/Plugin/Test.pm | 4 ++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Koha/Plugins.pm b/Koha/Plugins.pm index 768a5678d8..be1d091631 100644 --- a/Koha/Plugins.pm +++ b/Koha/Plugins.pm @@ -136,7 +136,7 @@ sub InstallPlugins { Koha::Plugins::Methods->search({ plugin_class => $plugin_class })->delete(); - foreach my $method ( @{ Class::Inspector->methods($plugin_class) } ) { + foreach my $method ( @{ Class::Inspector->methods( $plugin_class, 'public' ) } ) { Koha::Plugins::Method->new( { plugin_class => $plugin_class, diff --git a/t/db_dependent/Plugins.t b/t/db_dependent/Plugins.t index c72f27d683..53ae26e06e 100755 --- a/t/db_dependent/Plugins.t +++ b/t/db_dependent/Plugins.t @@ -23,7 +23,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 => 49; +use Test::More tests => 50; use C4::Context; use Koha::Database; @@ -115,6 +115,7 @@ Koha::Plugins::Methods->delete; Koha::Plugins->new( { enable_plugins => 1 } )->InstallPlugins(); ok( Koha::Plugins::Methods->search( { plugin_class => 'Koha::Plugin::Test' } )->count, 'Test plugin methods added to database' ); +is( Koha::Plugins::Methods->search({ plugin_class => 'Koha::Plugin::Test', plugin_method => '_private_sub' })->count, 0, 'Private methods are skipped' ); my $mock_plugin = Test::MockModule->new( 'Koha::Plugin::Test' ); $mock_plugin->mock( 'test_template', sub { @@ -286,4 +287,4 @@ subtest 'new() tests' => sub { is( ref($result), 'Koha::Plugins', 'calling new with enable_plugins makes it override the config' ); }; -$schema->storage->txn_rollback; \ No newline at end of file +$schema->storage->txn_rollback; diff --git a/t/lib/Koha/Plugin/Test.pm b/t/lib/Koha/Plugin/Test.pm index 2cb749e7dd..764b5a6b2b 100644 --- a/t/lib/Koha/Plugin/Test.pm +++ b/t/lib/Koha/Plugin/Test.pm @@ -182,3 +182,7 @@ sub api_routes { return decode_json($spec); } + +sub _private_sub { + return ""; +} -- 2.20.1 (Apple Git-117)