Bug 10698: (follow-up) remove now-superfluous FIXME comment
[koha_fer] / t / db_dependent / Plugins.t
index 52495ea..bb7a836 100755 (executable)
@@ -3,9 +3,10 @@
 use strict;
 use warnings;
 
-use Test::More tests => 15;
+use Test::More tests => 20;
 use File::Basename;
-
+use FindBin qw($Bin);
+use Archive::Extract;
 use Module::Load::Conditional qw(can_load);
 
 use C4::Context;
@@ -32,8 +33,32 @@ ok( $plugin->can('configure'), 'Test plugin can configure' );
 ok( $plugin->can('install'), 'Test plugin can install' );
 ok( $plugin->can('uninstall'), 'Test plugin can install' );
 
+ok( Koha::Plugins::Handler->run({ class => "Koha::Plugin::Test", method => 'report', enable_plugins => 1 }) eq "Koha::Plugin::Test::report", 'Test run plugin report method' );
+
 my $metadata = $plugin->get_metadata();
 ok( $metadata->{'name'} eq 'Test Plugin', 'Test $plugin->get_metadata()' );
 
 ok( $plugin->get_qualified_table_name('mytable') eq 'koha_plugin_test_mytable', 'Test $plugin->get_qualified_table_name()' );
-ok( $plugin->get_plugin_http_path() eq '/plugin/Koha/Plugin/Test', 'Test $plugin->get_plugin_http_path()' );
\ No newline at end of file
+ok( $plugin->get_plugin_http_path() eq '/plugin/Koha/Plugin/Test', 'Test $plugin->get_plugin_http_path()' );
+
+my @plugins = Koha::Plugins->new({ enable_plugins => 1 })->GetPlugins( 'report' );
+ok( $plugins[0]->get_metadata()->{'name'} eq 'Test Plugin', "Koha::Plugins::GetPlugins functions correctly" );
+
+SKIP: {
+    my $plugins_dir = C4::Context->config("pluginsdir");
+    skip "plugindir not set", 3 unless defined $plugins_dir;
+    skip "plugindir not writable", 3 unless -w $plugins_dir;
+    skip "KitchenSink plugin already installed", 3 if (-f "$plugins_dir/Koha/Plugin/Com/ByWaterSolutions/KitchenSink.pm");
+
+    my $ae = Archive::Extract->new( archive => "$Bin/KitchenSinkPlugin.kpz", type => 'zip' );
+    unless ( $ae->extract( to => $plugins_dir ) ) {
+        warn "ERROR: " . $ae->error;
+    }
+    use_ok('Koha::Plugin::Com::ByWaterSolutions::KitchenSink');
+    $plugin = Koha::Plugin::Com::ByWaterSolutions::KitchenSink->new({ enable_plugins => 1});
+
+    ok( -f $plugins_dir . "/Koha/Plugin/Com/ByWaterSolutions/KitchenSink.pm", "KitchenSink plugin installed successfully" );
+    Koha::Plugins::Handler->delete({ class => "Koha::Plugin::Com::ByWaterSolutions::KitchenSink" });
+    ok( !( -f $plugins_dir . "/Koha/Plugin/Com/ByWaterSolutions/KitchenSink.pm" ), "Koha::Plugins::Handler::delete works correctly." );
+}
+