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