Lines 24-30
use File::Temp qw( tempdir tempfile );
Link Here
|
24 |
use FindBin qw($Bin); |
24 |
use FindBin qw($Bin); |
25 |
use Module::Load::Conditional qw(can_load); |
25 |
use Module::Load::Conditional qw(can_load); |
26 |
use Test::MockModule; |
26 |
use Test::MockModule; |
27 |
use Test::More tests => 62; |
27 |
use Test::More tests => 51; |
28 |
use Test::Warn; |
28 |
use Test::Warn; |
29 |
|
29 |
|
30 |
use C4::Context; |
30 |
use C4::Context; |
Lines 196-218
subtest 'InstallPlugins() tests' => sub {
Link Here
|
196 |
Koha::Plugins::Methods->delete; |
196 |
Koha::Plugins::Methods->delete; |
197 |
$schema->resultset('PluginData')->delete; |
197 |
$schema->resultset('PluginData')->delete; |
198 |
|
198 |
|
199 |
# Tests for the exclude paramater |
199 |
# Tests for the exclude parameter |
200 |
# Test the returned plugins of the InstallPlugins subroutine |
200 |
# Test the returned plugins of the InstallPlugins subroutine |
201 |
my $plugins = Koha::Plugins->new({ enable_plugins => 1 }); |
201 |
my $plugins = Koha::Plugins->new( { enable_plugins => 1 } ); |
202 |
my @installed_plugins = $plugins->InstallPlugins({ exclude => ["Test", "Koha::Plugin::MarcFieldValues"] }); |
202 |
my @installed_plugins = $plugins->InstallPlugins( { exclude => [ "Test", "Koha::Plugin::MarcFieldValues" ] } ); |
203 |
my $plugin_classes = join(" ", map{$_->{class}} @installed_plugins); |
203 |
my $plugin_classes = join( " ", map { $_->{class} } @installed_plugins ); |
204 |
|
204 |
|
205 |
my $result = grep { $plugin_classes !~ $_ } [":Test |:Test\$", ":MarcFieldValues |:MarcFieldValues\$"] |
205 |
my $result = grep { $plugin_classes !~ $_ } [ ":Test |:Test\$", ":MarcFieldValues |:MarcFieldValues\$" ] |
206 |
&& $plugin_classes =~ ":TestItemBarcodeTransform |:TestItemBarcodeTransform\$"; |
206 |
&& $plugin_classes =~ ":TestItemBarcodeTransform |:TestItemBarcodeTransform\$"; |
207 |
ok($result, "Excluded plugins are not returned"); |
207 |
ok( $result, "Excluded plugins are not returned" ); |
208 |
|
208 |
|
209 |
# Test the plugins in the database |
209 |
# Test the plugins in the database |
210 |
my @plugins = $plugins->GetPlugins({ all => 1, error => 1 }); |
210 |
my @plugins = $plugins->GetPlugins( { all => 1, error => 1 } ); |
211 |
$plugin_classes = join(" ", map{$_->{class}} @plugins); |
211 |
$plugin_classes = join( " ", map { $_->{class} } @plugins ); |
212 |
|
212 |
|
213 |
$result = grep { $plugin_classes !~ $_ } [":Test |:Test\$", ":MarcFieldValues |:MarcFieldValues\$"] |
213 |
$result = grep { $plugin_classes !~ $_ } [ ":Test |:Test\$", ":MarcFieldValues |:MarcFieldValues\$" ] |
214 |
&& $plugin_classes =~ ":TestItemBarcodeTransform |:TestItemBarcodeTransform\$"; |
214 |
&& $plugin_classes =~ ":TestItemBarcodeTransform |:TestItemBarcodeTransform\$"; |
215 |
ok($result, "Excluded plugins are not installed"); |
215 |
ok( $result, "Excluded plugins are not installed" ); |
216 |
|
216 |
|
217 |
# Remove installed plugins data |
217 |
# Remove installed plugins data |
218 |
Koha::Plugins::Methods->delete; |
218 |
Koha::Plugins::Methods->delete; |
Lines 220-241
subtest 'InstallPlugins() tests' => sub {
Link Here
|
220 |
|
220 |
|
221 |
# Tests for the include parameter |
221 |
# Tests for the include parameter |
222 |
# Test the returned plugins of the InstallPlugins subroutine |
222 |
# Test the returned plugins of the InstallPlugins subroutine |
223 |
@installed_plugins = $plugins->InstallPlugins({ include => ["Test", "Koha::Plugin::MarcFieldValues"]}); |
223 |
@installed_plugins = $plugins->InstallPlugins( { include => [ "Test", "Koha::Plugin::MarcFieldValues" ] } ); |
224 |
|
224 |
|
225 |
$result = 1; |
225 |
$result = 1; |
226 |
foreach my $plugin_class ( map{ $_->{class} } @installed_plugins ) { |
226 |
foreach my $plugin_class ( map { $_->{class} } @installed_plugins ) { |
227 |
$result = 0 unless("$plugin_class" =~ ":Test\$" || "$plugin_class" =~ ":MarcFieldValues\$"); |
227 |
$result = 0 unless ( "$plugin_class" =~ ":Test\$" || "$plugin_class" =~ ":MarcFieldValues\$" ); |
228 |
} |
228 |
} |
229 |
ok($result, "Only included plugins are returned"); |
229 |
ok( $result, "Only included plugins are returned" ); |
230 |
|
230 |
|
231 |
# Test the plugins in the database |
231 |
# Test the plugins in the database |
232 |
@plugins = $plugins->GetPlugins({ all => 1, error => 1}); |
232 |
@plugins = $plugins->GetPlugins( { all => 1, error => 1 } ); |
233 |
|
233 |
|
234 |
$result = 1; |
234 |
$result = 1; |
235 |
foreach my $plugin_class ( map{ $_->{class} } @plugins ) { |
235 |
foreach my $plugin_class ( map { $_->{class} } @plugins ) { |
236 |
$result = 0 unless("$plugin_class" =~ ":Test\$" || "$plugin_class" =~ ":MarcFieldValues\$"); |
236 |
$result = 0 unless ( "$plugin_class" =~ ":Test\$" || "$plugin_class" =~ ":MarcFieldValues\$" ); |
237 |
} |
237 |
} |
238 |
ok($result, "Only included plugins are installed"); |
238 |
ok( $result, "Only included plugins are installed" ); |
239 |
|
239 |
|
240 |
$schema->storage->txn_rollback; |
240 |
$schema->storage->txn_rollback; |
241 |
}; |
241 |
}; |
242 |
- |
|
|