|
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 |
|