|
Lines 25-31
use File::Temp qw( tempdir tempfile );
Link Here
|
| 25 |
use FindBin qw($Bin); |
25 |
use FindBin qw($Bin); |
| 26 |
use Module::Load::Conditional qw(can_load); |
26 |
use Module::Load::Conditional qw(can_load); |
| 27 |
use Test::MockModule; |
27 |
use Test::MockModule; |
| 28 |
use Test::More tests => 55; |
28 |
use Test::More tests => 58; |
|
|
29 |
use Test::Warn; |
| 29 |
|
30 |
|
| 30 |
use C4::Context; |
31 |
use C4::Context; |
| 31 |
use Koha::Database; |
32 |
use Koha::Database; |
|
Lines 47-53
BEGIN {
Link Here
|
| 47 |
my $schema = Koha::Database->new->schema; |
48 |
my $schema = Koha::Database->new->schema; |
| 48 |
|
49 |
|
| 49 |
subtest 'call() tests' => sub { |
50 |
subtest 'call() tests' => sub { |
| 50 |
plan tests => 3; |
51 |
|
|
|
52 |
plan tests => 4; |
| 51 |
|
53 |
|
| 52 |
$schema->storage->txn_begin; |
54 |
$schema->storage->txn_begin; |
| 53 |
# Temporarily remove any installed plugins data |
55 |
# Temporarily remove any installed plugins data |
|
Lines 55-61
subtest 'call() tests' => sub {
Link Here
|
| 55 |
|
57 |
|
| 56 |
t::lib::Mocks::mock_config('enable_plugins', 1); |
58 |
t::lib::Mocks::mock_config('enable_plugins', 1); |
| 57 |
my $plugins = Koha::Plugins->new({ enable_plugins => 1 }); |
59 |
my $plugins = Koha::Plugins->new({ enable_plugins => 1 }); |
| 58 |
my @plugins = $plugins->InstallPlugins; |
60 |
|
|
|
61 |
my @plugins; |
| 62 |
|
| 63 |
warnings_are |
| 64 |
{ @plugins = $plugins->InstallPlugins; } |
| 65 |
[ "Calling 'install' died for plugin Koha::Plugin::BrokenInstall", "Calling 'upgrade' died for plugin Koha::Plugin::BrokenUpgrade" ]; |
| 66 |
|
| 59 |
foreach my $plugin (@plugins) { |
67 |
foreach my $plugin (@plugins) { |
| 60 |
$plugin->enable(); |
68 |
$plugin->enable(); |
| 61 |
} |
69 |
} |
|
Lines 80-93
subtest 'call() tests' => sub {
Link Here
|
| 80 |
|
88 |
|
| 81 |
subtest 'GetPlugins() tests' => sub { |
89 |
subtest 'GetPlugins() tests' => sub { |
| 82 |
|
90 |
|
| 83 |
plan tests => 2; |
91 |
plan tests => 3; |
| 84 |
|
92 |
|
| 85 |
$schema->storage->txn_begin; |
93 |
$schema->storage->txn_begin; |
| 86 |
# Temporarily remove any installed plugins data |
94 |
# Temporarily remove any installed plugins data |
| 87 |
Koha::Plugins::Methods->delete; |
95 |
Koha::Plugins::Methods->delete; |
| 88 |
|
96 |
|
| 89 |
my $plugins = Koha::Plugins->new({ enable_plugins => 1 }); |
97 |
my $plugins = Koha::Plugins->new({ enable_plugins => 1 }); |
| 90 |
$plugins->InstallPlugins; |
98 |
|
|
|
99 |
warnings_are { $plugins->InstallPlugins; } |
| 100 |
[ "Calling 'install' died for plugin Koha::Plugin::BrokenInstall", "Calling 'upgrade' died for plugin Koha::Plugin::BrokenUpgrade" ]; |
| 91 |
|
101 |
|
| 92 |
my @plugins = $plugins->GetPlugins({ method => 'report', all => 1 }); |
102 |
my @plugins = $plugins->GetPlugins({ method => 'report', all => 1 }); |
| 93 |
|
103 |
|
|
Lines 148-154
subtest 'is_enabled() tests' => sub {
Link Here
|
| 148 |
$schema->storage->txn_begin; |
158 |
$schema->storage->txn_begin; |
| 149 |
Koha::Plugins::Methods->delete; |
159 |
Koha::Plugins::Methods->delete; |
| 150 |
|
160 |
|
| 151 |
Koha::Plugins->new( { enable_plugins => 1 } )->InstallPlugins(); |
161 |
warnings_are { Koha::Plugins->new( { enable_plugins => 1 } )->InstallPlugins(); } |
|
|
162 |
[ "Calling 'install' died for plugin Koha::Plugin::BrokenInstall", "Calling 'upgrade' died for plugin Koha::Plugin::BrokenUpgrade" ]; |
| 152 |
|
163 |
|
| 153 |
ok( Koha::Plugins::Methods->search( { plugin_class => 'Koha::Plugin::Test' } )->count, 'Test plugin methods added to database' ); |
164 |
ok( Koha::Plugins::Methods->search( { plugin_class => 'Koha::Plugin::Test' } )->count, 'Test plugin methods added to database' ); |
| 154 |
is( Koha::Plugins::Methods->search({ plugin_class => 'Koha::Plugin::Test', plugin_method => '_private_sub' })->count, 0, 'Private methods are skipped' ); |
165 |
is( Koha::Plugins::Methods->search({ plugin_class => 'Koha::Plugin::Test', plugin_method => '_private_sub' })->count, 0, 'Private methods are skipped' ); |
|
Lines 262-268
for my $pass ( 1 .. 2 ) {
Link Here
|
| 262 |
|
273 |
|
| 263 |
ok( -f $plugins_dir . "/Koha/Plugin/Com/ByWaterSolutions/KitchenSink.pm", "KitchenSink plugin installed successfully" ); |
274 |
ok( -f $plugins_dir . "/Koha/Plugin/Com/ByWaterSolutions/KitchenSink.pm", "KitchenSink plugin installed successfully" ); |
| 264 |
$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" |
275 |
$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" |
| 265 |
Koha::Plugins->new( { enable_plugins => 1 } )->InstallPlugins(); |
276 |
warnings_are |
|
|
277 |
{ Koha::Plugins->new( { enable_plugins => 1 } )->InstallPlugins(); } |
| 278 |
[ "Calling 'install' died for plugin Koha::Plugin::BrokenInstall", "Calling 'upgrade' died for plugin Koha::Plugin::BrokenUpgrade" ]; |
| 266 |
ok( -f $full_pm_path, "Koha::Plugins::Handler::delete works correctly (pass $pass)" ); |
279 |
ok( -f $full_pm_path, "Koha::Plugins::Handler::delete works correctly (pass $pass)" ); |
| 267 |
Koha::Plugins::Handler->delete({ class => "Koha::Plugin::Com::ByWaterSolutions::KitchenSink", enable_plugins => 1 }); |
280 |
Koha::Plugins::Handler->delete({ class => "Koha::Plugin::Com::ByWaterSolutions::KitchenSink", enable_plugins => 1 }); |
| 268 |
my $sth = C4::Context->dbh->table_info( undef, undef, $table, 'TABLE' ); |
281 |
my $sth = C4::Context->dbh->table_info( undef, undef, $table, 'TABLE' ); |