Browse Source

Bug 29273: Remove warnings from plugin tests

This patch is suggesting to move the broken test plugins into a separate
directory.

t/lib/plugins and t/lib/bad_plugins

Signed-off-by: David Nind <david@davidnind.com>
JK: Add executable bit to Broken.t
Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
21.11.x
Jonathan Druart 3 years ago
parent
commit
22392e4a61
  1. 7
      t/db_dependent/Koha/Plugins/Barcode_transform_hooks.t
  2. 2
      t/db_dependent/Koha/Plugins/Biblio_and_Items_plugin_hooks.t
  3. 47
      t/db_dependent/Koha/Plugins/Broken.t
  4. 2
      t/db_dependent/Koha/Plugins/Circulation_hooks.t
  5. 2
      t/db_dependent/Koha/Plugins/Holds_hooks.t
  6. 2
      t/db_dependent/Koha/Plugins/Patron.t
  7. 23
      t/db_dependent/Koha/Plugins/Plugins.t
  8. 0
      t/lib/bad_plugins/Koha/Plugin/BrokenInstall.pm
  9. 0
      t/lib/bad_plugins/Koha/Plugin/BrokenUpgrade.pm
  10. 0
      t/lib/plugins/Koha/Plugin/BadAPIRoute.pm
  11. 0
      t/lib/plugins/Koha/Plugin/MarcFieldValues.pm
  12. 0
      t/lib/plugins/Koha/Plugin/Test.pm
  13. 0
      t/lib/plugins/Koha/Plugin/Test/Controller.pm
  14. 0
      t/lib/plugins/Koha/Plugin/TestItemBarcodeTransform.pm

7
t/db_dependent/Koha/Plugins/Barcode_transform_hooks.t

@ -27,7 +27,7 @@ use t::lib::TestBuilder;
BEGIN {
# Mock pluginsdir before loading Plugins module
my $path = dirname(__FILE__) . '/../../../lib';
my $path = dirname(__FILE__) . '/../../../lib/plugins';
t::lib::Mocks::mock_config( 'pluginsdir', $path );
use_ok('Koha::Plugins');
@ -53,10 +53,7 @@ subtest 'patron_barcode_transform() and item_barcode_transform() hook tests' =>
my $plugins = Koha::Plugins->new;
warnings_are
{ $plugins->InstallPlugins; }
[ "Calling 'install' died for plugin Koha::Plugin::BrokenInstall",
"Calling 'upgrade' died for plugin Koha::Plugin::BrokenUpgrade" ];
warning_is { $plugins->InstallPlugins; } undef;
C4::Context->dbh->do("DELETE FROM plugin_methods WHERE plugin_class LIKE '%TestBarcodes%'");

2
t/db_dependent/Koha/Plugins/Biblio_and_Items_plugin_hooks.t

@ -28,7 +28,7 @@ use t::lib::TestBuilder;
BEGIN {
# Mock pluginsdir before loading Plugins module
my $path = dirname(__FILE__) . '/../../../lib';
my $path = dirname(__FILE__) . '/../../../lib/plugins';
t::lib::Mocks::mock_config( 'pluginsdir', $path );
use_ok('Koha::Plugins');

47
t/db_dependent/Koha/Plugins/Broken.t

@ -0,0 +1,47 @@
#!/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 Test::More tests => 3;
use Test::MockModule;
use Test::Warn;
use File::Basename;
use t::lib::Mocks;
use t::lib::TestBuilder;
BEGIN {
# Mock pluginsdir before loading Plugins module
my $path = dirname(__FILE__) . '/../../../lib/bad_plugins';
t::lib::Mocks::mock_config( 'pluginsdir', $path );
use_ok('Koha::Plugins');
use_ok('Koha::Plugins::Handler');
}
my $schema = Koha::Database->new->schema;
my $builder = t::lib::TestBuilder->new;
t::lib::Mocks::mock_config( 'enable_plugins', 1 );
my $plugins = Koha::Plugins->new;
warnings_are
{ $plugins->InstallPlugins; }
[ "Calling 'install' died for plugin Koha::Plugin::BrokenInstall",
"Calling 'upgrade' died for plugin Koha::Plugin::BrokenUpgrade" ];

2
t/db_dependent/Koha/Plugins/Circulation_hooks.t

@ -29,7 +29,7 @@ use t::lib::TestBuilder;
BEGIN {
# Mock pluginsdir before loading Plugins module
my $path = dirname(__FILE__) . '/../../../lib';
my $path = dirname(__FILE__) . '/../../../lib/plugins';
t::lib::Mocks::mock_config( 'pluginsdir', $path );
use_ok('Koha::Plugins');

2
t/db_dependent/Koha/Plugins/Holds_hooks.t

@ -29,7 +29,7 @@ use t::lib::TestBuilder;
BEGIN {
# Mock pluginsdir before loading Plugins module
my $path = dirname(__FILE__) . '/../../../lib';
my $path = dirname(__FILE__) . '/../../../lib/plugins';
t::lib::Mocks::mock_config( 'pluginsdir', $path );
use_ok('Koha::Plugins');

2
t/db_dependent/Koha/Plugins/Patron.t

@ -28,7 +28,7 @@ use t::lib::TestBuilder;
BEGIN {
# Mock pluginsdir before loading Plugins module
my $path = dirname(__FILE__) . '/../../../lib';
my $path = dirname(__FILE__) . '/../../../lib/plugins';
t::lib::Mocks::mock_config( 'pluginsdir', $path );
use_ok('Koha::Plugins');

23
t/db_dependent/Koha/Plugins/Plugins.t

@ -36,7 +36,7 @@ use t::lib::Mocks;
BEGIN {
# Mock pluginsdir before loading Plugins module
my $path = dirname(__FILE__) . '/../../../lib';
my $path = dirname(__FILE__) . '/../../../lib/plugins';
t::lib::Mocks::mock_config( 'pluginsdir', $path );
use_ok('Koha::Plugins');
@ -61,9 +61,7 @@ subtest 'call() tests' => sub {
my @plugins;
warnings_are
{ @plugins = $plugins->InstallPlugins; }
[ "Calling 'install' died for plugin Koha::Plugin::BrokenInstall", "Calling 'upgrade' died for plugin Koha::Plugin::BrokenUpgrade" ];
warning_is { @plugins = $plugins->InstallPlugins; } undef;
foreach my $plugin (@plugins) {
$plugin->enable();
@ -99,10 +97,7 @@ subtest 'more call() tests' => sub {
my $plugins = Koha::Plugins->new({ enable_plugins => 1 });
my @plugins;
warnings_are
{ @plugins = $plugins->InstallPlugins; }
[ "Calling 'install' died for plugin Koha::Plugin::BrokenInstall",
"Calling 'upgrade' died for plugin Koha::Plugin::BrokenUpgrade" ];
warning_is { @plugins = $plugins->InstallPlugins; } undef;
foreach my $plugin (@plugins) {
$plugin->enable();
@ -142,8 +137,7 @@ subtest 'GetPlugins() tests' => sub {
my $plugins = Koha::Plugins->new({ enable_plugins => 1 });
warnings_are { $plugins->InstallPlugins; }
[ "Calling 'install' died for plugin Koha::Plugin::BrokenInstall", "Calling 'upgrade' died for plugin Koha::Plugin::BrokenUpgrade" ];
warning_is { $plugins->InstallPlugins; } undef;
my @plugins = $plugins->GetPlugins({ method => 'report', all => 1 });
@ -204,8 +198,7 @@ subtest 'is_enabled() tests' => sub {
$schema->storage->txn_begin;
Koha::Plugins::Methods->delete;
warnings_are { Koha::Plugins->new( { enable_plugins => 1 } )->InstallPlugins(); }
[ "Calling 'install' died for plugin Koha::Plugin::BrokenInstall", "Calling 'upgrade' died for plugin Koha::Plugin::BrokenUpgrade" ];
warning_is { Koha::Plugins->new( { enable_plugins => 1 } )->InstallPlugins(); } undef;
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' );
@ -320,9 +313,7 @@ for my $pass ( 1 .. 2 ) {
ok( -f $plugins_dir . "/Koha/Plugin/Com/ByWaterSolutions/KitchenSink.pm", "KitchenSink plugin installed successfully" );
$INC{$pm_path} = $full_pm_path; # FIXME I do not really know why, but if this is moved before the $plugin constructor, it will fail with Can't locate object method "new" via package "Koha::Plugin::Com::ByWaterSolutions::KitchenSink"
warnings_are
{ Koha::Plugins->new( { enable_plugins => 1 } )->InstallPlugins(); }
[ "Calling 'install' died for plugin Koha::Plugin::BrokenInstall", "Calling 'upgrade' died for plugin Koha::Plugin::BrokenUpgrade" ];
warning_is { Koha::Plugins->new( { enable_plugins => 1 } )->InstallPlugins(); } undef;
ok( -f $full_pm_path, "Koha::Plugins::Handler::delete works correctly (pass $pass)" );
Koha::Plugins::Handler->delete({ class => "Koha::Plugin::Com::ByWaterSolutions::KitchenSink", enable_plugins => 1 });
my $sth = C4::Context->dbh->table_info( undef, undef, $table, 'TABLE' );
@ -400,7 +391,7 @@ subtest 'bundle_path() tests' => sub {
my $plugin = Koha::Plugin::Test->new;
is( $plugin->bundle_path, File::Spec->catdir(@current_dir) . '/lib/Koha/Plugin/Test' );
is( $plugin->bundle_path, File::Spec->catdir(@current_dir) . '/lib/plugins/Koha/Plugin/Test' );
};

0
t/lib/Koha/Plugin/BrokenInstall.pm → t/lib/bad_plugins/Koha/Plugin/BrokenInstall.pm

0
t/lib/Koha/Plugin/BrokenUpgrade.pm → t/lib/bad_plugins/Koha/Plugin/BrokenUpgrade.pm

0
t/lib/Koha/Plugin/BadAPIRoute.pm → t/lib/plugins/Koha/Plugin/BadAPIRoute.pm

0
t/lib/Koha/Plugin/MarcFieldValues.pm → t/lib/plugins/Koha/Plugin/MarcFieldValues.pm

0
t/lib/Koha/Plugin/Test.pm → t/lib/plugins/Koha/Plugin/Test.pm

0
t/lib/Koha/Plugin/Test/Controller.pm → t/lib/plugins/Koha/Plugin/Test/Controller.pm

0
t/lib/Koha/Plugin/TestItemBarcodeTransform.pm → t/lib/plugins/Koha/Plugin/TestItemBarcodeTransform.pm

Loading…
Cancel
Save