Browse Source

Bug 7804 - Add Koha Plugin System - QA Followup 3 - Additional Unit Tests

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
3.12.x
Kyle Hall 9 years ago
committed by Jared Camins-Esakov
parent
commit
c332b372ca
  1. 7
      Koha/Plugins/Base.pm
  2. BIN
      t/db_dependent/KitchenSinkPlugin.kpz
  3. 22
      t/db_dependent/Plugins.t

7
Koha/Plugins/Base.pm

@ -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'},

BIN
t/db_dependent/KitchenSinkPlugin.kpz

Binary file not shown.

22
t/db_dependent/Plugins.t

@ -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()' );
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." );

Loading…
Cancel
Save