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

(-)a/Koha/Plugins.pm (-1 / +1 lines)
Lines 112-118 sub GetPlugins { Link Here
112
    return @plugins;
112
    return @plugins;
113
}
113
}
114
114
115
=head2
115
=head2 InstallPlugins
116
116
117
Koha::Plugins::InstallPlugins()
117
Koha::Plugins::InstallPlugins()
118
118
(-)a/Koha/Plugins/Handler.pm (-1 / +1 lines)
Lines 70-76 sub run { Link Here
70
        return $plugin->$plugin_method( $params );
70
        return $plugin->$plugin_method( $params );
71
    } else {
71
    } else {
72
        warn "Plugin does not have method $plugin_method";
72
        warn "Plugin does not have method $plugin_method";
73
        return undef;
73
        return;
74
    }
74
    }
75
}
75
}
76
76
(-)a/Koha/Plugins/Methods.pm (+4 lines)
Lines 43-48 sub _type { Link Here
43
    return 'PluginMethod';
43
    return 'PluginMethod';
44
}
44
}
45
45
46
=head3 object_class
47
48
=cut
49
46
sub object_class {
50
sub object_class {
47
    return 'Koha::Plugin::Method';
51
    return 'Koha::Plugin::Method';
48
}
52
}
(-)a/t/db_dependent/Plugins.t (-26 / +26 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
91
$schema->storage->txn_begin;
112
$schema->storage->txn_begin;
92
Koha::Plugins::Methods->delete;
113
Koha::Plugins::Methods->delete;
93
114
Lines 239-266 subtest 'output and output_html tests' => sub { Link Here
239
    like($stdout, qr{¡Hola output_html!}, 'Correct data');
260
    like($stdout, qr{¡Hola output_html!}, 'Correct data');
240
};
261
};
241
262
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 {
263
subtest 'Test _version_compare' => sub {
265
264
266
    plan tests => 6;
265
    plan tests => 6;
Lines 286-288 subtest 'new() tests' => sub { Link Here
286
    $result = Koha::Plugins->new({ enable_plugins => 1 });
285
    $result = Koha::Plugins->new({ enable_plugins => 1 });
287
    is( ref($result), 'Koha::Plugins', 'calling new with enable_plugins makes it override the config' );
286
    is( ref($result), 'Koha::Plugins', 'calling new with enable_plugins makes it override the config' );
288
};
287
};
289
- 
288
289
$schema->storage->txn_rollback;

Return to bug 21073