Bugzilla – Attachment 89278 Details for
Bug 21073
Improve plugin performance
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21073: Regression tests for GetPlugins
Bug-21073-Regression-tests-for-GetPlugins.patch (text/plain), 5.38 KB, created by
Agustín Moyano
on 2019-05-03 02:49:56 UTC
(
hide
)
Description:
Bug 21073: Regression tests for GetPlugins
Filename:
MIME Type:
Creator:
Agustín Moyano
Created:
2019-05-03 02:49:56 UTC
Size:
5.38 KB
patch
obsolete
>From 561b8b6af6815f8b8f89b86d2f5ab119b95ec4f9 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 2 May 2019 14:00:52 -0300 >Subject: [PATCH] Bug 21073: Regression tests for GetPlugins > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: Agustin Moyano <agustinmoyano@theke.io> >--- > t/db_dependent/Plugins.t | 101 ++++++++++++++++++++++++++++++----------------- > 1 file changed, 65 insertions(+), 36 deletions(-) > >diff --git a/t/db_dependent/Plugins.t b/t/db_dependent/Plugins.t >index da9001be96..34764214c6 100755 >--- a/t/db_dependent/Plugins.t >+++ b/t/db_dependent/Plugins.t >@@ -1,5 +1,19 @@ > #!/usr/bin/perl > >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 3 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, see <http://www.gnu.org/licenses>. >+ > use Modern::Perl; > > use Archive::Extract; >@@ -9,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 => 42; >+use Test::More tests => 41; > > use C4::Context; > use Koha::Database; >@@ -18,7 +32,9 @@ use Koha::Plugins::Methods; > use t::lib::Mocks; > > BEGIN { >- push( @INC, dirname(__FILE__) . '/../lib' ); >+ # Mock pluginsdir before loading Plugins module >+ my $path = dirname(__FILE__) . '/../lib'; >+ t::lib::Mocks::mock_config( 'pluginsdir', $path ); > > use_ok('Koha::Plugins'); > use_ok('Koha::Plugins::Handler'); >@@ -28,6 +44,53 @@ BEGIN { > > my $schema = Koha::Database->new->schema; > >+subtest 'GetPlugins() tests' => sub { >+ >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ # Temporarily remove any installed plugins data >+ Koha::Plugins::Methods->delete; >+ >+ my $plugins = Koha::Plugins->new({ enable_plugins => 1 }); >+ $plugins->InstallPlugins; >+ >+ my @plugins = $plugins->GetPlugins({ method => 'report' }); >+ >+ 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' } }); >+ @names = map { $_->get_metadata()->{'name'} } @plugins; >+ is( scalar @names, 2, "Only two plugins found via a metadata tag" ); >+ >+ $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; >+ > Koha::Plugins->new( { enable_plugins => 1 } )->InstallPlugins(); > > ok( Koha::Plugins::Methods->search( { plugin_class => 'Koha::Plugin::Test' } )->count, 'Test plugin methods added to database' ); >@@ -82,18 +145,6 @@ close $fh; > my $classname = ref($plugin); > like( $plugin->test_template($fn), qr/^I am $fn/, 'Template works' ); > >-# testing GetPlugins >-my @plugins = Koha::Plugins->new({ enable_plugins => 1 })->GetPlugins({ >- method => 'report' >-}); >-my @names = map { $_->get_metadata()->{'name'} } @plugins; >-is( scalar grep( /^Test Plugin$/, @names), 1, "Koha::Plugins::GetPlugins functions correctly" ); >-@plugins = Koha::Plugins->new({ enable_plugins => 1 })->GetPlugins({ >- metadata => { my_example_tag => 'find_me' }, >-}); >-@names = map { $_->get_metadata()->{'name'} } @plugins; >-is( scalar grep( /^Test Plugin$/, @names), 1, "GetPlugins also found Test Plugin via a metadata tag" ); >- > for my $pass ( 1 .. 2 ) { > my $plugins_dir; > my $module_name = 'Koha::Plugin::Com::ByWaterSolutions::KitchenSink'; >@@ -160,28 +211,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; >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 21073
:
76955
|
76956
|
76957
|
76958
|
76973
|
88379
|
88380
|
88381
|
89247
|
89251
|
89252
|
89255
|
89256
|
89272
|
89273
|
89274
|
89275
|
89276
|
89277
|
89278
|
89279
|
89786
|
89800
|
89801
|
89802
|
89803
|
89804
|
89805
|
89806
|
89807
|
89808
|
90630
|
90631
|
90650
|
90651
|
90652
|
90653
|
90654
|
90655
|
90656
|
90657
|
90658
|
90659
|
90660
|
90661
|
90662
|
90663
|
90664
|
90724
|
90725
|
90726
|
90727
|
90728
|
90729
|
90730
|
90731
|
90732
|
90733
|
90734
|
90735
|
90736
|
90737
|
90738
|
90739
|
90759
|
90816