View | Details | Raw Unified | Return to bug 21073
Collapse All | Expand All

(-)a/Koha/Plugins.pm (-8 / +8 lines)
Lines 87-103 sub GetPlugins { Link Here
87
87
88
        load $plugin_class;
88
        load $plugin_class;
89
        my $plugin = $plugin_class->new({ enable_plugins => $self->{'enable_plugins'} });
89
        my $plugin = $plugin_class->new({ enable_plugins => $self->{'enable_plugins'} });
90
	
91
    	my $plugin_enabled = $plugin->retrieve_data('__ENABLED__');
92
    	$plugin->{enabled} = $plugin_enabled;
93
90
91
        my $plugin_enabled = $plugin->retrieve_data('__ENABLED__');
92
        $plugin->{enabled} = $plugin_enabled;
94
93
95
    	# Want all plugins. Not only enabled ones.
96
    	if ( defined($params->{all}) && $params->{all} ) {
97
        	$plugin_enabled = 1;
98
    	}
99
94
100
	next unless $plugin_enabled;
95
        # Want all plugins. Not only enabled ones.
96
        if ( defined($params->{all}) && $params->{all} ) {
97
            $plugin_enabled = 1;
98
        }
99
100
        next unless $plugin_enabled;
101
101
102
        # filter the plugin out by metadata
102
        # filter the plugin out by metadata
103
        my $plugin_metadata = $plugin->get_metadata;
103
        my $plugin_metadata = $plugin->get_metadata;
(-)a/t/db_dependent/Plugins.t (-26 / +27 lines)
Lines 23-29 use File::Temp qw( tempdir tempfile ); Link Here
23
use FindBin qw($Bin);
23
use FindBin qw($Bin);
24
use Module::Load::Conditional qw(can_load);
24
use Module::Load::Conditional qw(can_load);
25
use Test::MockModule;
25
use Test::MockModule;
26
use Test::More tests => 47;
26
use Test::More tests => 49;
27
27
28
use C4::Context;
28
use C4::Context;
29
use Koha::Database;
29
use Koha::Database;
Lines 55-66 subtest 'GetPlugins() tests' => sub { Link Here
55
    my $plugins = Koha::Plugins->new({ enable_plugins => 1 });
55
    my $plugins = Koha::Plugins->new({ enable_plugins => 1 });
56
    $plugins->InstallPlugins;
56
    $plugins->InstallPlugins;
57
57
58
    my @plugins = $plugins->GetPlugins({ method => 'report' });
58
    my @plugins = $plugins->GetPlugins({ method => 'report', all => 1 });
59
59
60
    my @names = map { $_->get_metadata()->{'name'} } @plugins;
60
    my @names = map { $_->get_metadata()->{'name'} } @plugins;
61
    is( scalar grep( /^Test Plugin$/, @names), 1, "Koha::Plugins::GetPlugins functions correctly" );
61
    is( scalar grep( /^Test Plugin$/, @names), 1, "Koha::Plugins::GetPlugins functions correctly" );
62
62
63
    @plugins = $plugins->GetPlugins({ metadata => { my_example_tag  => 'find_me' } });
63
    @plugins = $plugins->GetPlugins({ metadata => { my_example_tag  => 'find_me' }, all => 1 });
64
    @names = map { $_->get_metadata()->{'name'} } @plugins;
64
    @names = map { $_->get_metadata()->{'name'} } @plugins;
65
    is( scalar @names, 2, "Only two plugins found via a metadata tag" );
65
    is( scalar @names, 2, "Only two plugins found via a metadata tag" );
66
66
Lines 88-93 subtest 'Version upgrade tests' => sub { Link Here
88
    $schema->storage->txn_rollback;
88
    $schema->storage->txn_rollback;
89
};
89
};
90
90
91
subtest 'Version upgrade tests' => sub {
92
93
    plan tests => 1;
94
95
    $schema->storage->txn_begin;
96
97
    my $plugin = Koha::Plugin::Test->new( { enable_plugins => 1, cgi => CGI->new } );
98
99
    # make sure there's no version on the DB
100
    $schema->resultset('PluginData')
101
        ->search( { plugin_class => $plugin->{class}, plugin_key => '__INSTALLED_VERSION__' } )
102
        ->delete;
103
104
    $plugin = Koha::Plugin::Test->new( { enable_plugins => 1, cgi => CGI->new } );
105
    my $version = $plugin->retrieve_data('__INSTALLED_VERSION__');
106
107
    is( $version, $plugin->get_metadata->{version}, 'Version has been populated correctly' );
108
109
    $schema->storage->txn_rollback;
110
};
111
112
91
$schema->storage->txn_begin;
113
$schema->storage->txn_begin;
92
Koha::Plugins::Methods->delete;
114
Koha::Plugins::Methods->delete;
93
115
Lines 239-266 subtest 'output and output_html tests' => sub { Link Here
239
    like($stdout, qr{¡Hola output_html!}, 'Correct data');
261
    like($stdout, qr{¡Hola output_html!}, 'Correct data');
240
};
262
};
241
263
242
subtest 'Version upgrade tests' => sub {
243
244
    plan tests => 1;
245
246
    $schema->storage->txn_begin;
247
248
    my $plugin = Koha::Plugin::Test->new( { enable_plugins => 1, cgi => CGI->new } );
249
250
    # make sure there's no version on the DB
251
    $schema->resultset('PluginData')
252
        ->search( { plugin_class => $plugin->{class}, plugin_key => '__INSTALLED_VERSION__' } )
253
        ->delete;
254
255
    $plugin = Koha::Plugin::Test->new( { enable_plugins => 1, cgi => CGI->new } );
256
    my $version = $plugin->retrieve_data('__INSTALLED_VERSION__');
257
258
    is( $version, $plugin->get_metadata->{version}, 'Version has been populated correctly' );
259
260
    $schema->storage->txn_rollback;
261
};
262
263
264
subtest 'Test _version_compare' => sub {
264
subtest 'Test _version_compare' => sub {
265
265
266
    plan tests => 6;
266
    plan tests => 6;
Lines 286-288 subtest 'new() tests' => sub { Link Here
286
    $result = Koha::Plugins->new({ enable_plugins => 1 });
286
    $result = Koha::Plugins->new({ enable_plugins => 1 });
287
    is( ref($result), 'Koha::Plugins', 'calling new with enable_plugins makes it override the config' );
287
    is( ref($result), 'Koha::Plugins', 'calling new with enable_plugins makes it override the config' );
288
};
288
};
289
- 
289
290
$schema->storage->txn_rollback;

Return to bug 21073