Bug 7804 - Add Koha Plugin System - QA Followup 3 - Additional Unit Tests
authorKyle M Hall <kyle@bywatersolutions.com>
Mon, 18 Mar 2013 16:57:09 +0000 (09:57 -0700)
committerJared Camins-Esakov <jcamins@cpbibliography.com>
Wed, 20 Mar 2013 18:50:38 +0000 (14:50 -0400)
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
Koha/Plugins/Base.pm
t/db_dependent/KitchenSinkPlugin.kpz [new file with mode: 0644]
t/db_dependent/Plugins.t

index 2681ee7..3b0ab15 100644 (file)
@@ -60,9 +60,9 @@ sub new {
 
 =head2 store_data
 
-set_data allows a plugin to store key value pairs in the database for future use.
+store_data allows a plugin to store key value pairs in the database for future use.
 
-usage: $self->set_data({ param1 => 'param1val', param2 => 'param2value' })
+usage: $self->store_data({ param1 => 'param1val', param2 => 'param2value' })
 
 =cut
 
@@ -108,9 +108,6 @@ C4:Template, but at the moment, it does not.
 sub get_template {
     my ( $self, $args ) = @_;
 
-    #    my $template =
-    #      C4::Templates->new( my $interface = 'intranet', my $filename = $self->mbf_path( $args->{'file'} ), my $tmplbase = '', my $query = $self->{'cgi'} );
-
     my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
         {   template_name   => $self->mbf_path( $args->{'file'} ),
             query           => $self->{'cgi'},
diff --git a/t/db_dependent/KitchenSinkPlugin.kpz b/t/db_dependent/KitchenSinkPlugin.kpz
new file mode 100644 (file)
index 0000000..97b88b6
Binary files /dev/null and b/t/db_dependent/KitchenSinkPlugin.kpz differ
index a36fe3c..03fa4bf 100755 (executable)
@@ -3,9 +3,10 @@
 use strict;
 use warnings;
 
-use Test::More tests => 16;
+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;
@@ -38,4 +39,19 @@ 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()->GetPlugins( 'report' );
+ok( $plugins[0]->get_metadata()->{'name'} eq 'Test Plugin', "Koha::Plugins::GetPlugins functions correctly" );
+
+my $plugins_dir = C4::Context->config("pluginsdir");
+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." );