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>
This commit is contained in:
parent
c7e2837c4e
commit
22392e4a61
|
|
@ -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%'");
|
||||
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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" ];
|
||||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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' );
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue