Bugzilla – Attachment 58806 Details for
Bug 15879
Allow multiple plugin directories to be defined in koha-conf.xml
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15879: Add Tests
Bug-15879-Add-Tests.patch (text/plain), 3.72 KB, created by
Jonathan Druart
on 2017-01-11 11:04:50 UTC
(
hide
)
Description:
Bug 15879: Add Tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2017-01-11 11:04:50 UTC
Size:
3.72 KB
patch
obsolete
>From 661c5446218d7d15820666d6b3979c57acf04957 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 10 Jan 2017 21:52:07 +0100 >Subject: [PATCH] Bug 15879: Add Tests > >Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> >--- > Koha/Plugins/Handler.pm | 2 +- > t/db_dependent/Plugins.t | 34 +++++++++++++++++++++++++--------- > 2 files changed, 26 insertions(+), 10 deletions(-) > >diff --git a/Koha/Plugins/Handler.pm b/Koha/Plugins/Handler.pm >index e613b86..b0e316a 100644 >--- a/Koha/Plugins/Handler.pm >+++ b/Koha/Plugins/Handler.pm >@@ -102,7 +102,7 @@ sub delete { > > C4::Context->dbh->do( "DELETE FROM plugin_data WHERE plugin_class = ?", undef, ($plugin_class) ); > >- unlink("$plugin_path.pm"); >+ unlink "$plugin_path.pm" or warn "Could not unlink $plugin_path.pm: $!"; > remove_tree($plugin_path); > } > >diff --git a/t/db_dependent/Plugins.t b/t/db_dependent/Plugins.t >index 92a6f8c..c9d24a7 100755 >--- a/t/db_dependent/Plugins.t >+++ b/t/db_dependent/Plugins.t >@@ -1,15 +1,16 @@ > #!/usr/bin/perl > >-use strict; >-use warnings; >+use Modern::Perl; > >-use Test::More tests => 24; >+use Test::More tests => 28; > use File::Basename; >+use File::Temp qw( tempdir ); > use FindBin qw($Bin); > use Archive::Extract; > use Module::Load::Conditional qw(can_load); > > use C4::Context; >+use t::lib::Mocks; > > BEGIN { > push( @INC, dirname(__FILE__) . '/..' ); >@@ -60,11 +61,25 @@ my @plugins2 = Koha::Plugins->new({ enable_plugins => 1 })->GetPlugins({ > }); > isnt( scalar @plugins2, scalar @plugins, 'GetPlugins with two metadata conditions' ); > >-SKIP: { >- my $plugins_dir = C4::Context->config("pluginsdir"); >- skip "plugindir not set", 4 unless defined $plugins_dir; >- skip "plugindir not writable", 4 unless -w $plugins_dir; >- # no need to skip further tests if KitchenSink would already exist >+for my $pass ( 1 .. 2 ) { >+ my $plugins_dir; >+ my $module_name = 'Koha::Plugin::Com::ByWaterSolutions::KitchenSink'; >+ my $pm_path = 'Koha/Plugin/Com/ByWaterSolutions/KitchenSink.pm'; >+ if ( $pass == 1 ) { >+ my $plugins_dir1 = tempdir( CLEANUP => 1 ); >+ t::lib::Mocks::mock_config('pluginsdir', $plugins_dir1); >+ $plugins_dir = $plugins_dir1; >+ push @INC, $plugins_dir1; >+ } else { >+ my $plugins_dir1 = tempdir( CLEANUP => 1 ); >+ my $plugins_dir2 = tempdir( CLEANUP => 1 ); >+ t::lib::Mocks::mock_config('pluginsdir', [ $plugins_dir2, $plugins_dir1 ]); >+ $plugins_dir = $plugins_dir2; >+ pop @INC; >+ push @INC, $plugins_dir2; >+ push @INC, $plugins_dir1; >+ } >+ my $full_pm_path = $plugins_dir . '/' . $pm_path; > > my $ae = Archive::Extract->new( archive => "$Bin/KitchenSinkPlugin.kpz", type => 'zip' ); > unless ( $ae->extract( to => $plugins_dir ) ) { >@@ -75,9 +90,10 @@ SKIP: { > my $table = $plugin->get_qualified_table_name( 'mytable' ); > > 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" > Koha::Plugins::Handler->delete({ class => "Koha::Plugin::Com::ByWaterSolutions::KitchenSink", enable_plugins => 1 }); > my $sth = C4::Context->dbh->table_info( undef, undef, $table, 'TABLE' ); > my $info = $sth->fetchall_arrayref; > is( @$info, 0, "Table $table does no longer exist" ); >- ok( !( -f $plugins_dir . "/Koha/Plugin/Com/ByWaterSolutions/KitchenSink.pm" ), "Koha::Plugins::Handler::delete works correctly." ); >+ ok( !( -f $full_pm_path ), "Koha::Plugins::Handler::delete works correctly." ); > } >-- >2.9.3
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 15879
:
48296
|
48297
|
58594
|
58805
| 58806