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

(-)a/t/db_dependent/Koha/Plugins/Barcode_transform_hooks.t (-5 / +2 lines)
Lines 27-33 use t::lib::TestBuilder; Link Here
27
27
28
BEGIN {
28
BEGIN {
29
    # Mock pluginsdir before loading Plugins module
29
    # Mock pluginsdir before loading Plugins module
30
    my $path = dirname(__FILE__) . '/../../../lib';
30
    my $path = dirname(__FILE__) . '/../../../lib/plugins';
31
    t::lib::Mocks::mock_config( 'pluginsdir', $path );
31
    t::lib::Mocks::mock_config( 'pluginsdir', $path );
32
32
33
    use_ok('Koha::Plugins');
33
    use_ok('Koha::Plugins');
Lines 53-62 subtest 'patron_barcode_transform() and item_barcode_transform() hook tests' => Link Here
53
53
54
    my $plugins = Koha::Plugins->new;
54
    my $plugins = Koha::Plugins->new;
55
55
56
    warnings_are
56
    warning_is { $plugins->InstallPlugins; } undef;
57
     { $plugins->InstallPlugins; }
58
     [ "Calling 'install' died for plugin Koha::Plugin::BrokenInstall",
59
       "Calling 'upgrade' died for plugin Koha::Plugin::BrokenUpgrade" ];
60
57
61
    C4::Context->dbh->do("DELETE FROM plugin_methods WHERE plugin_class LIKE '%TestBarcodes%'");
58
    C4::Context->dbh->do("DELETE FROM plugin_methods WHERE plugin_class LIKE '%TestBarcodes%'");
62
59
(-)a/t/db_dependent/Koha/Plugins/Biblio_and_Items_plugin_hooks.t (-1 / +1 lines)
Lines 28-34 use t::lib::TestBuilder; Link Here
28
28
29
BEGIN {
29
BEGIN {
30
    # Mock pluginsdir before loading Plugins module
30
    # Mock pluginsdir before loading Plugins module
31
    my $path = dirname(__FILE__) . '/../../../lib';
31
    my $path = dirname(__FILE__) . '/../../../lib/plugins';
32
    t::lib::Mocks::mock_config( 'pluginsdir', $path );
32
    t::lib::Mocks::mock_config( 'pluginsdir', $path );
33
33
34
    use_ok('Koha::Plugins');
34
    use_ok('Koha::Plugins');
(-)a/t/db_dependent/Koha/Plugins/Broken.t (+47 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 3 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with Koha; if not, see <http://www.gnu.org/licenses>.
16
17
use Modern::Perl;
18
19
use Test::More tests => 3;
20
use Test::MockModule;
21
use Test::Warn;
22
23
use File::Basename;
24
25
use t::lib::Mocks;
26
use t::lib::TestBuilder;
27
28
BEGIN {
29
    # Mock pluginsdir before loading Plugins module
30
    my $path = dirname(__FILE__) . '/../../../lib/bad_plugins';
31
    t::lib::Mocks::mock_config( 'pluginsdir', $path );
32
33
    use_ok('Koha::Plugins');
34
    use_ok('Koha::Plugins::Handler');
35
}
36
37
my $schema  = Koha::Database->new->schema;
38
my $builder = t::lib::TestBuilder->new;
39
40
t::lib::Mocks::mock_config( 'enable_plugins', 1 );
41
42
my $plugins = Koha::Plugins->new;
43
44
warnings_are
45
 { $plugins->InstallPlugins; }
46
 [ "Calling 'install' died for plugin Koha::Plugin::BrokenInstall",
47
   "Calling 'upgrade' died for plugin Koha::Plugin::BrokenUpgrade" ];
(-)a/t/db_dependent/Koha/Plugins/Circulation_hooks.t (-1 / +1 lines)
Lines 29-35 use t::lib::TestBuilder; Link Here
29
29
30
BEGIN {
30
BEGIN {
31
    # Mock pluginsdir before loading Plugins module
31
    # Mock pluginsdir before loading Plugins module
32
    my $path = dirname(__FILE__) . '/../../../lib';
32
    my $path = dirname(__FILE__) . '/../../../lib/plugins';
33
    t::lib::Mocks::mock_config( 'pluginsdir', $path );
33
    t::lib::Mocks::mock_config( 'pluginsdir', $path );
34
34
35
    use_ok('Koha::Plugins');
35
    use_ok('Koha::Plugins');
(-)a/t/db_dependent/Koha/Plugins/Holds_hooks.t (-1 / +1 lines)
Lines 29-35 use t::lib::TestBuilder; Link Here
29
29
30
BEGIN {
30
BEGIN {
31
    # Mock pluginsdir before loading Plugins module
31
    # Mock pluginsdir before loading Plugins module
32
    my $path = dirname(__FILE__) . '/../../../lib';
32
    my $path = dirname(__FILE__) . '/../../../lib/plugins';
33
    t::lib::Mocks::mock_config( 'pluginsdir', $path );
33
    t::lib::Mocks::mock_config( 'pluginsdir', $path );
34
34
35
    use_ok('Koha::Plugins');
35
    use_ok('Koha::Plugins');
(-)a/t/db_dependent/Koha/Plugins/Patron.t (-1 / +1 lines)
Lines 28-34 use t::lib::TestBuilder; Link Here
28
28
29
BEGIN {
29
BEGIN {
30
    # Mock pluginsdir before loading Plugins module
30
    # Mock pluginsdir before loading Plugins module
31
    my $path = dirname(__FILE__) . '/../../../lib';
31
    my $path = dirname(__FILE__) . '/../../../lib/plugins';
32
    t::lib::Mocks::mock_config( 'pluginsdir', $path );
32
    t::lib::Mocks::mock_config( 'pluginsdir', $path );
33
33
34
    use_ok('Koha::Plugins');
34
    use_ok('Koha::Plugins');
(-)a/t/db_dependent/Koha/Plugins/Plugins.t (-16 / +7 lines)
Lines 36-42 use t::lib::Mocks; Link Here
36
36
37
BEGIN {
37
BEGIN {
38
    # Mock pluginsdir before loading Plugins module
38
    # Mock pluginsdir before loading Plugins module
39
    my $path = dirname(__FILE__) . '/../../../lib';
39
    my $path = dirname(__FILE__) . '/../../../lib/plugins';
40
    t::lib::Mocks::mock_config( 'pluginsdir', $path );
40
    t::lib::Mocks::mock_config( 'pluginsdir', $path );
41
41
42
    use_ok('Koha::Plugins');
42
    use_ok('Koha::Plugins');
Lines 61-69 subtest 'call() tests' => sub { Link Here
61
61
62
    my @plugins;
62
    my @plugins;
63
63
64
    warnings_are
64
    warning_is { @plugins = $plugins->InstallPlugins; } undef;
65
     { @plugins = $plugins->InstallPlugins; }
66
     [ "Calling 'install' died for plugin Koha::Plugin::BrokenInstall", "Calling 'upgrade' died for plugin Koha::Plugin::BrokenUpgrade" ];
67
65
68
    foreach my $plugin (@plugins) {
66
    foreach my $plugin (@plugins) {
69
        $plugin->enable();
67
        $plugin->enable();
Lines 99-108 subtest 'more call() tests' => sub { Link Here
99
    my $plugins = Koha::Plugins->new({ enable_plugins => 1 });
97
    my $plugins = Koha::Plugins->new({ enable_plugins => 1 });
100
    my @plugins;
98
    my @plugins;
101
99
102
    warnings_are
100
    warning_is { @plugins = $plugins->InstallPlugins; } undef;
103
     { @plugins = $plugins->InstallPlugins; }
104
     [ "Calling 'install' died for plugin Koha::Plugin::BrokenInstall",
105
       "Calling 'upgrade' died for plugin Koha::Plugin::BrokenUpgrade" ];
106
101
107
    foreach my $plugin (@plugins) {
102
    foreach my $plugin (@plugins) {
108
        $plugin->enable();
103
        $plugin->enable();
Lines 142-149 subtest 'GetPlugins() tests' => sub { Link Here
142
137
143
    my $plugins = Koha::Plugins->new({ enable_plugins => 1 });
138
    my $plugins = Koha::Plugins->new({ enable_plugins => 1 });
144
139
145
    warnings_are { $plugins->InstallPlugins; }
140
    warning_is { $plugins->InstallPlugins; } undef;
146
    [ "Calling 'install' died for plugin Koha::Plugin::BrokenInstall", "Calling 'upgrade' died for plugin Koha::Plugin::BrokenUpgrade" ];
147
141
148
    my @plugins = $plugins->GetPlugins({ method => 'report', all => 1 });
142
    my @plugins = $plugins->GetPlugins({ method => 'report', all => 1 });
149
143
Lines 204-211 subtest 'is_enabled() tests' => sub { Link Here
204
$schema->storage->txn_begin;
198
$schema->storage->txn_begin;
205
Koha::Plugins::Methods->delete;
199
Koha::Plugins::Methods->delete;
206
200
207
warnings_are { Koha::Plugins->new( { enable_plugins => 1 } )->InstallPlugins(); }
201
warning_is { Koha::Plugins->new( { enable_plugins => 1 } )->InstallPlugins(); } undef;
208
[ "Calling 'install' died for plugin Koha::Plugin::BrokenInstall", "Calling 'upgrade' died for plugin Koha::Plugin::BrokenUpgrade" ];
209
202
210
ok( Koha::Plugins::Methods->search( { plugin_class => 'Koha::Plugin::Test' } )->count, 'Test plugin methods added to database' );
203
ok( Koha::Plugins::Methods->search( { plugin_class => 'Koha::Plugin::Test' } )->count, 'Test plugin methods added to database' );
211
is( Koha::Plugins::Methods->search({ plugin_class => 'Koha::Plugin::Test', plugin_method => '_private_sub' })->count, 0, 'Private methods are skipped' );
204
is( Koha::Plugins::Methods->search({ plugin_class => 'Koha::Plugin::Test', plugin_method => '_private_sub' })->count, 0, 'Private methods are skipped' );
Lines 320-328 for my $pass ( 1 .. 2 ) { Link Here
320
313
321
    ok( -f $plugins_dir . "/Koha/Plugin/Com/ByWaterSolutions/KitchenSink.pm", "KitchenSink plugin installed successfully" );
314
    ok( -f $plugins_dir . "/Koha/Plugin/Com/ByWaterSolutions/KitchenSink.pm", "KitchenSink plugin installed successfully" );
322
    $INC{$pm_path} = $full_pm_path; # FIXME I do not really know why, but if this is moved before the $plugin constructor, it will fail with Can't locate object method "new" via package "Koha::Plugin::Com::ByWaterSolutions::KitchenSink"
315
    $INC{$pm_path} = $full_pm_path; # FIXME I do not really know why, but if this is moved before the $plugin constructor, it will fail with Can't locate object method "new" via package "Koha::Plugin::Com::ByWaterSolutions::KitchenSink"
323
    warnings_are
316
    warning_is { Koha::Plugins->new( { enable_plugins => 1 } )->InstallPlugins(); } undef;
324
        { Koha::Plugins->new( { enable_plugins => 1 } )->InstallPlugins(); }
325
        [ "Calling 'install' died for plugin Koha::Plugin::BrokenInstall", "Calling 'upgrade' died for plugin Koha::Plugin::BrokenUpgrade" ];
326
    ok( -f $full_pm_path, "Koha::Plugins::Handler::delete works correctly (pass $pass)" );
317
    ok( -f $full_pm_path, "Koha::Plugins::Handler::delete works correctly (pass $pass)" );
327
    Koha::Plugins::Handler->delete({ class => "Koha::Plugin::Com::ByWaterSolutions::KitchenSink", enable_plugins => 1 });
318
    Koha::Plugins::Handler->delete({ class => "Koha::Plugin::Com::ByWaterSolutions::KitchenSink", enable_plugins => 1 });
328
    my $sth = C4::Context->dbh->table_info( undef, undef, $table, 'TABLE' );
319
    my $sth = C4::Context->dbh->table_info( undef, undef, $table, 'TABLE' );
Lines 400-406 subtest 'bundle_path() tests' => sub { Link Here
400
391
401
    my $plugin = Koha::Plugin::Test->new;
392
    my $plugin = Koha::Plugin::Test->new;
402
393
403
    is( $plugin->bundle_path, File::Spec->catdir(@current_dir) . '/lib/Koha/Plugin/Test' );
394
    is( $plugin->bundle_path, File::Spec->catdir(@current_dir) . '/lib/plugins/Koha/Plugin/Test' );
404
395
405
};
396
};
406
397

Return to bug 29273