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

(-)a/Koha/Plugins/Handler.pm (-3 / +6 lines)
Lines 25-30 use File::Path qw( remove_tree ); Link Here
25
use Module::Load qw( load );
25
use Module::Load qw( load );
26
26
27
use C4::Context;
27
use C4::Context;
28
use Koha::Plugins;
28
use Koha::Plugins::Methods;
29
use Koha::Plugins::Methods;
29
30
30
BEGIN {
31
BEGIN {
Lines 76-82 sub run { Link Here
76
77
77
=item delete
78
=item delete
78
79
79
Deletes a plugin
80
Deletes a plugin.
81
82
Called in plugins/plugins-uninstall.pl.
80
83
81
=cut
84
=cut
82
85
Lines 101-108 sub delete { Link Here
101
        enable_plugins => $args->{enable_plugins},
104
        enable_plugins => $args->{enable_plugins},
102
    });
105
    });
103
106
104
    C4::Context->dbh->do( "DELETE FROM plugin_data WHERE plugin_class = ?", undef, ($plugin_class) );
107
    # TODO Would next call be a candidate for replacing destructive by disable ?
105
    Koha::Plugins::Methods->search({ plugin_class => $plugin_class })->delete();
108
    Koha::Plugins->RemovePlugins( { plugin_class => $plugin_class, destructive => 1 } );
106
109
107
    unlink "$plugin_path.pm" or warn "Could not unlink $plugin_path.pm: $!";
110
    unlink "$plugin_path.pm" or warn "Could not unlink $plugin_path.pm: $!";
108
    remove_tree($plugin_path);
111
    remove_tree($plugin_path);
(-)a/t/db_dependent/Koha/Plugins/Account_hooks.t (-1 / +1 lines)
Lines 69-74 subtest 'Koha::Account tests' => sub { Link Here
69
    qr/after_account_action called with action: add_credit, type: payment, ref: Koha::Account::Line/,
69
    qr/after_account_action called with action: add_credit, type: payment, ref: Koha::Account::Line/,
70
      '->add_credit calls the after_account_action hook with type payment';
70
      '->add_credit calls the after_account_action hook with type payment';
71
71
72
    Koha::Plugins::Methods->delete;
72
    Koha::Plugins->RemovePlugins;
73
    $schema->storage->txn_rollback;
73
    $schema->storage->txn_rollback;
74
};
74
};
(-)a/t/db_dependent/Koha/Plugins/BackgroundJob.t (-1 / +1 lines)
Lines 85-89 subtest 'background_tasks() hooks tests' => sub { Link Here
85
    is_deeply( $tasks, $bj->core_types_to_classes, 'Only core mapping returned when plugins disabled' );
85
    is_deeply( $tasks, $bj->core_types_to_classes, 'Only core mapping returned when plugins disabled' );
86
86
87
    $schema->storage->txn_rollback;
87
    $schema->storage->txn_rollback;
88
    Koha::Plugins::Methods->delete;
88
    Koha::Plugins->RemovePlugins;
89
};
89
};
(-)a/t/db_dependent/Koha/Plugins/Barcode_transform_hooks.t (-1 / +1 lines)
Lines 100-104 subtest 'patron_barcode_transform() and item_barcode_transform() hook tests' => Link Here
100
        'Koha::Item->store calls the item_barcode_transform hook';
100
        'Koha::Item->store calls the item_barcode_transform hook';
101
101
102
    $schema->storage->txn_rollback;
102
    $schema->storage->txn_rollback;
103
    Koha::Plugins::Methods->delete;
103
    Koha::Plugins->RemovePlugins;
104
};
104
};
(-)a/t/db_dependent/Koha/Plugins/Biblio_and_Items_plugin_hooks.t (-1 / +1 lines)
Lines 84-88 subtest 'after_biblio_action() and after_item_action() hooks tests' => sub { Link Here
84
            'DelBiblio calls the hook with action=delete biblio_id passed';
84
            'DelBiblio calls the hook with action=delete biblio_id passed';
85
85
86
    $schema->storage->txn_rollback;
86
    $schema->storage->txn_rollback;
87
    Koha::Plugins::Methods->delete;
87
    Koha::Plugins->RemovePlugins;
88
};
88
};
(-)a/t/db_dependent/Koha/Plugins/Circulation_hooks.t (-1 / +1 lines)
Lines 121-125 subtest 'after_circ_action() hook tests' => sub { Link Here
121
    };
121
    };
122
122
123
    $schema->storage->txn_rollback;
123
    $schema->storage->txn_rollback;
124
    Koha::Plugins::Methods->delete;
124
    Koha::Plugins->RemovePlugins;
125
};
125
};
(-)a/t/db_dependent/Koha/Plugins/Holds_hooks.t (-3 / +3 lines)
Lines 80-86 subtest 'after_hold_create() hook tests' => sub { Link Here
80
          qr/after_hold_create called with parameter Koha::Hold/ ],
80
          qr/after_hold_create called with parameter Koha::Hold/ ],
81
          'AddReserve calls the after_hold_create hook, deprecation warning found';
81
          'AddReserve calls the after_hold_create hook, deprecation warning found';
82
82
83
    Koha::Plugins::Methods->delete;
83
    Koha::Plugins->RemovePlugins;
84
    $schema->storage->txn_rollback;
84
    $schema->storage->txn_rollback;
85
};
85
};
86
86
Lines 124-130 subtest 'after_hold_action (placed) hook tests' => sub { Link Here
124
    }
124
    }
125
    [ qr/after_hold_create is deprecated and will be removed soon/, qr/after_hold_action called with action: place, ref: Koha::Hold/,  ], 'AddReserve calls the after_hold_action hook';
125
    [ qr/after_hold_create is deprecated and will be removed soon/, qr/after_hold_action called with action: place, ref: Koha::Hold/,  ], 'AddReserve calls the after_hold_action hook';
126
126
127
    Koha::Plugins::Methods->delete;
127
    Koha::Plugins->RemovePlugins;
128
    $schema->storage->txn_rollback;
128
    $schema->storage->txn_rollback;
129
};
129
};
130
130
Lines 205-210 subtest 'Koha::Hold tests' => sub { Link Here
205
    qr/after_hold_action called with action: cancel, ref: Koha::Old::Hold/,
205
    qr/after_hold_action called with action: cancel, ref: Koha::Old::Hold/,
206
      '->cancel calls the after_hold_action hook';
206
      '->cancel calls the after_hold_action hook';
207
207
208
    Koha::Plugins::Methods->delete;
208
    Koha::Plugins->RemovePlugins;
209
    $schema->storage->txn_rollback;
209
    $schema->storage->txn_rollback;
210
};
210
};
(-)a/t/db_dependent/Koha/Plugins/Patron.t (-1 / +1 lines)
Lines 88-94 subtest 'check_password hook tests' => sub { Link Here
88
    ok( $patron->set_password({ password => 'explosion', skip_validation => 1}), 'Patron password updated via skip validation');
88
    ok( $patron->set_password({ password => 'explosion', skip_validation => 1}), 'Patron password updated via skip validation');
89
89
90
    $schema->storage->txn_rollback;
90
    $schema->storage->txn_rollback;
91
    Koha::Plugins::Methods->delete;
91
    Koha::Plugins->RemovePlugins;
92
};
92
};
93
93
94
1;
94
1;
(-)a/t/db_dependent/Koha/Plugins/Plugins.t (-12 / +7 lines)
Lines 57-64 subtest 'call() tests' => sub { Link Here
57
57
58
    $schema->storage->txn_begin;
58
    $schema->storage->txn_begin;
59
    # Temporarily remove any installed plugins data
59
    # Temporarily remove any installed plugins data
60
    Koha::Plugins::Methods->delete;
60
    Koha::Plugins->RemovePlugins( { destructive => 1 } );
61
    $schema->resultset('PluginData')->delete();
62
61
63
    t::lib::Mocks::mock_config('enable_plugins', 1);
62
    t::lib::Mocks::mock_config('enable_plugins', 1);
64
    my $plugins = Koha::Plugins->new({ enable_plugins => 1 });
63
    my $plugins = Koha::Plugins->new({ enable_plugins => 1 });
Lines 95-102 subtest 'more call() tests' => sub { Link Here
95
94
96
    $schema->storage->txn_begin;
95
    $schema->storage->txn_begin;
97
    # Temporarily remove any installed plugins data
96
    # Temporarily remove any installed plugins data
98
    Koha::Plugins::Methods->delete;
97
    Koha::Plugins->RemovePlugins( { destructive => 1 } );
99
    $schema->resultset('PluginData')->delete();
100
98
101
    t::lib::Mocks::mock_config('enable_plugins', 1);
99
    t::lib::Mocks::mock_config('enable_plugins', 1);
102
    my $plugins = Koha::Plugins->new({ enable_plugins => 1 });
100
    my $plugins = Koha::Plugins->new({ enable_plugins => 1 });
Lines 138-145 subtest 'feature_enabled tests' => sub { Link Here
138
    $schema->storage->txn_begin;
136
    $schema->storage->txn_begin;
139
137
140
    # Temporarily remove any installed plugins data
138
    # Temporarily remove any installed plugins data
141
    Koha::Plugins::Methods->delete;
139
    Koha::Plugins->RemovePlugins( { destructive => 1 } );
142
    $schema->resultset('PluginData')->delete();
143
140
144
    t::lib::Mocks::mock_config( 'enable_plugins', 0 );
141
    t::lib::Mocks::mock_config( 'enable_plugins', 0 );
145
    my $enabled = Koha::Plugins->feature_enabled('check_password');
142
    my $enabled = Koha::Plugins->feature_enabled('check_password');
Lines 169-176 subtest 'GetPlugins() tests' => sub { Link Here
169
    plan tests => 3;
166
    plan tests => 3;
170
167
171
    $schema->storage->txn_begin;
168
    $schema->storage->txn_begin;
172
    # Temporarily remove any installed plugins data
169
    # Temporarily remove any installed plugins data (FIXME not done)
173
    Koha::Plugins::Methods->delete;
170
    Koha::Plugins->RemovePlugins;
174
171
175
    my $plugins = Koha::Plugins->new({ enable_plugins => 1 });
172
    my $plugins = Koha::Plugins->new({ enable_plugins => 1 });
176
173
Lines 215-222 subtest 'is_enabled() tests' => sub { Link Here
215
    $schema->storage->txn_begin;
212
    $schema->storage->txn_begin;
216
213
217
    # Make sure there's no previous installs or leftovers on DB
214
    # Make sure there's no previous installs or leftovers on DB
218
    Koha::Plugins::Methods->delete;
215
    Koha::Plugins->RemovePlugins( { destructive => 1 } );
219
    $schema->resultset('PluginData')->delete;
220
216
221
    my $plugin = Koha::Plugin::Test->new({ enable_plugins => 1, cgi => CGI->new });
217
    my $plugin = Koha::Plugin::Test->new({ enable_plugins => 1, cgi => CGI->new });
222
    ok( $plugin->is_enabled, 'Plugins enabled by default' );
218
    ok( $plugin->is_enabled, 'Plugins enabled by default' );
Lines 234-241 subtest 'is_enabled() tests' => sub { Link Here
234
230
235
subtest 'Koha::Plugin::Test' => sub {
231
subtest 'Koha::Plugin::Test' => sub {
236
    $schema->storage->txn_begin;
232
    $schema->storage->txn_begin;
237
    Koha::Plugins::Methods->delete;
233
    Koha::Plugins->RemovePlugins( { destructive => 1 } );
238
    $schema->resultset('PluginData')->delete;
239
234
240
    warning_is { Koha::Plugins->new( { enable_plugins => 1 } )->InstallPlugins(); } undef;
235
    warning_is { Koha::Plugins->new( { enable_plugins => 1 } )->InstallPlugins(); } undef;
241
236
(-)a/t/db_dependent/Koha/Plugins/Recall_hooks.t (-2 / +1 lines)
Lines 26-32 use t::lib::TestBuilder; Link Here
26
use Koha::Database;
26
use Koha::Database;
27
use C4::Circulation qw();
27
use C4::Circulation qw();
28
use Koha::CirculationRules;
28
use Koha::CirculationRules;
29
use Koha::Plugins::Methods;
30
use Koha::Recalls;
29
use Koha::Recalls;
31
30
32
BEGIN {
31
BEGIN {
Lines 95-100 subtest 'after_recall_action hook' => sub { Link Here
95
    qr/after_recall_action called with action: add, ref: Koha::Recall/,
94
    qr/after_recall_action called with action: add, ref: Koha::Recall/,
96
      '->add_recall calls the after_recall_action hook with action add';
95
      '->add_recall calls the after_recall_action hook with action add';
97
96
98
    Koha::Plugins::Methods->delete;
97
    Koha::Plugins->RemovePlugins;
99
    $schema->storage->txn_rollback;
98
    $schema->storage->txn_rollback;
100
};
99
};
(-)a/t/db_dependent/Koha/Plugins/authority_hooks.t (-1 / +1 lines)
Lines 66-70 subtest 'after_authority_action hook' => sub { Link Here
66
            'DelAuthority calls the hook with action=delete, id passed';
66
            'DelAuthority calls the hook with action=delete, id passed';
67
67
68
    $schema->storage->txn_rollback;
68
    $schema->storage->txn_rollback;
69
    Koha::Plugins::Methods->delete;
69
    Koha::Plugins->RemovePlugins;
70
};
70
};
(-)a/t/db_dependent/Koha/REST/Plugin/PluginRoutes.t (-2 / +1 lines)
Lines 234-240 subtest 'needs_install use case tests' => sub { Link Here
234
234
235
    t::lib::Mocks::mock_preference('Version', '3.0.0');
235
    t::lib::Mocks::mock_preference('Version', '3.0.0');
236
236
237
    $schema->resultset('PluginData')->delete;
237
    Koha::Plugins->RemovePlugins( { destructive => 1 } );    # FIXME destructive seems not to be needed here
238
    $plugins->InstallPlugins;
238
    $plugins->InstallPlugins;
239
239
240
    # re-initialize Koha::REST::V1 after mocking
240
    # re-initialize Koha::REST::V1 after mocking
241
- 

Return to bug 35536