From 50bdd416e68e76c573932b01ea97e4b241171d87 Mon Sep 17 00:00:00 2001 From: Agustin Moyano Date: Wed, 15 May 2019 20:49:08 -0300 Subject: [PATCH] Bug 21073: (follow-up) QA fixes after rebase Signed-off-by: Tomas Cohen Arazi Signed-off-by: Kyle M Hall Signed-off-by: Martin Renvoize --- Koha/Plugins.pm | 2 +- Koha/Plugins/Handler.pm | 2 +- Koha/Plugins/Methods.pm | 4 ++++ t/db_dependent/Plugins.t | 51 ++++++++++++++++++++-------------------- 4 files changed, 32 insertions(+), 27 deletions(-) diff --git a/Koha/Plugins.pm b/Koha/Plugins.pm index 301ae65201..768a5678d8 100644 --- a/Koha/Plugins.pm +++ b/Koha/Plugins.pm @@ -112,7 +112,7 @@ sub GetPlugins { return @plugins; } -=head2 +=head2 InstallPlugins Koha::Plugins::InstallPlugins() diff --git a/Koha/Plugins/Handler.pm b/Koha/Plugins/Handler.pm index 551448c8c0..30b9e8bb0c 100644 --- a/Koha/Plugins/Handler.pm +++ b/Koha/Plugins/Handler.pm @@ -70,7 +70,7 @@ sub run { return $plugin->$plugin_method( $params ); } else { warn "Plugin does not have method $plugin_method"; - return undef; + return; } } diff --git a/Koha/Plugins/Methods.pm b/Koha/Plugins/Methods.pm index 2c1129de8a..cdac31ef1c 100644 --- a/Koha/Plugins/Methods.pm +++ b/Koha/Plugins/Methods.pm @@ -43,6 +43,10 @@ sub _type { return 'PluginMethod'; } +=head3 object_class + +=cut + sub object_class { return 'Koha::Plugin::Method'; } diff --git a/t/db_dependent/Plugins.t b/t/db_dependent/Plugins.t index 70e7fb3e7a..c72f27d683 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 => 47; +use Test::More tests => 49; use C4::Context; use Koha::Database; @@ -55,12 +55,12 @@ subtest 'GetPlugins() tests' => sub { my $plugins = Koha::Plugins->new({ enable_plugins => 1 }); $plugins->InstallPlugins; - my @plugins = $plugins->GetPlugins({ method => 'report' }); + my @plugins = $plugins->GetPlugins({ method => 'report', all => 1 }); my @names = map { $_->get_metadata()->{'name'} } @plugins; is( scalar grep( /^Test Plugin$/, @names), 1, "Koha::Plugins::GetPlugins functions correctly" ); - @plugins = $plugins->GetPlugins({ metadata => { my_example_tag => 'find_me' } }); + @plugins = $plugins->GetPlugins({ metadata => { my_example_tag => 'find_me' }, all => 1 }); @names = map { $_->get_metadata()->{'name'} } @plugins; is( scalar @names, 2, "Only two plugins found via a metadata tag" ); @@ -88,6 +88,27 @@ subtest 'Version upgrade tests' => sub { $schema->storage->txn_rollback; }; +subtest 'Version upgrade tests' => sub { + + plan tests => 1; + + $schema->storage->txn_begin; + + my $plugin = Koha::Plugin::Test->new( { enable_plugins => 1, cgi => CGI->new } ); + + # make sure there's no version on the DB + $schema->resultset('PluginData') + ->search( { plugin_class => $plugin->{class}, plugin_key => '__INSTALLED_VERSION__' } ) + ->delete; + + $plugin = Koha::Plugin::Test->new( { enable_plugins => 1, cgi => CGI->new } ); + my $version = $plugin->retrieve_data('__INSTALLED_VERSION__'); + + is( $version, $plugin->get_metadata->{version}, 'Version has been populated correctly' ); + + $schema->storage->txn_rollback; +}; + $schema->storage->txn_begin; Koha::Plugins::Methods->delete; @@ -239,28 +260,6 @@ subtest 'output and output_html tests' => sub { like($stdout, qr{¡Hola output_html!}, 'Correct data'); }; -subtest 'Version upgrade tests' => sub { - - plan tests => 1; - - $schema->storage->txn_begin; - - my $plugin = Koha::Plugin::Test->new( { enable_plugins => 1, cgi => CGI->new } ); - - # make sure there's no version on the DB - $schema->resultset('PluginData') - ->search( { plugin_class => $plugin->{class}, plugin_key => '__INSTALLED_VERSION__' } ) - ->delete; - - $plugin = Koha::Plugin::Test->new( { enable_plugins => 1, cgi => CGI->new } ); - my $version = $plugin->retrieve_data('__INSTALLED_VERSION__'); - - is( $version, $plugin->get_metadata->{version}, 'Version has been populated correctly' ); - - $schema->storage->txn_rollback; -}; - - subtest 'Test _version_compare' => sub { plan tests => 6; @@ -286,3 +285,5 @@ subtest 'new() tests' => sub { $result = Koha::Plugins->new({ enable_plugins => 1 }); 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 -- 2.39.5