Bug 21073: (QA follow-up) Only public subs should be considered
authorTomas Cohen Arazi <tomascohen@theke.io>
Fri, 14 Jun 2019 19:51:07 +0000 (16:51 -0300)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Tue, 18 Jun 2019 16:30:19 +0000 (17:30 +0100)
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Koha/Plugins.pm
t/db_dependent/Plugins.t
t/lib/Koha/Plugin/Test.pm

index 768a567..be1d091 100644 (file)
@@ -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,
index c72f27d..53ae26e 100755 (executable)
@@ -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;
index 2cb749e..764b5a6 100644 (file)
@@ -182,3 +182,7 @@ sub api_routes {
 
     return decode_json($spec);
 }
+
+sub _private_sub {
+    return "";
+}