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 => 61; |
28 |
use Test::More tests => 62; |
29 |
use Test::Warn; |
29 |
use Test::Warn; |
30 |
|
30 |
|
31 |
use C4::Context; |
31 |
use C4::Context; |
Lines 153-158
subtest 'GetPlugins() tests' => sub {
Link Here
|
153 |
$schema->storage->txn_rollback; |
153 |
$schema->storage->txn_rollback; |
154 |
}; |
154 |
}; |
155 |
|
155 |
|
|
|
156 |
subtest 'InstallPlugins() tests' => sub { |
157 |
|
158 |
plan tests => 4; |
159 |
|
160 |
$schema->storage->txn_begin; |
161 |
|
162 |
# Temporarily remove any installed plugins data |
163 |
Koha::Plugins::Methods->delete; |
164 |
$schema->resultset('PluginData')->delete; |
165 |
|
166 |
# Tests for the exclude paramater |
167 |
# Test the returned plugins of the InstallPlugins subroutine |
168 |
my $plugins = Koha::Plugins->new({ enable_plugins => 1 }); |
169 |
my @installed_plugins = $plugins->InstallPlugins({ exclude => ["Test", "Koha::Plugin::MarcFieldValues"] }); |
170 |
my $plugin_classes = join(" ", map{$_->{class}} @installed_plugins); |
171 |
|
172 |
my $result = grep { $plugin_classes !~ $_ } [":Test |:Test\$", ":MarcFieldValues |:MarcFieldValues\$"] |
173 |
&& $plugin_classes =~ ":TestItemBarcodeTransform |:TestItemBarcodeTransform\$"; |
174 |
ok($result, "Excluded plugins are not returned"); |
175 |
|
176 |
# Test the plugins in the database |
177 |
my @plugins = $plugins->GetPlugins({ all => 1, error => 1 }); |
178 |
$plugin_classes = join(" ", map{$_->{class}} @plugins); |
179 |
|
180 |
$result = grep { $plugin_classes !~ $_ } [":Test |:Test\$", ":MarcFieldValues |:MarcFieldValues\$"] |
181 |
&& $plugin_classes =~ ":TestItemBarcodeTransform |:TestItemBarcodeTransform\$"; |
182 |
ok($result, "Excluded plugins are not installed"); |
183 |
|
184 |
# Remove installed plugins data |
185 |
Koha::Plugins::Methods->delete; |
186 |
$schema->resultset('PluginData')->delete; |
187 |
|
188 |
# Tests for the include parameter |
189 |
# Test the returned plugins of the InstallPlugins subroutine |
190 |
@installed_plugins = $plugins->InstallPlugins({ include => ["Test", "Koha::Plugin::MarcFieldValues"]}); |
191 |
|
192 |
$result = 1; |
193 |
foreach my $plugin_class ( map{ $_->{class} } @installed_plugins ) { |
194 |
$result = 0 unless("$plugin_class" =~ ":Test\$" || "$plugin_class" =~ ":MarcFieldValues\$"); |
195 |
} |
196 |
ok($result, "Only included plugins are returned"); |
197 |
|
198 |
# Test the plugins in the database |
199 |
@plugins = $plugins->GetPlugins({ all => 1, error => 1}); |
200 |
|
201 |
$result = 1; |
202 |
foreach my $plugin_class ( map{ $_->{class} } @plugins ) { |
203 |
$result = 0 unless("$plugin_class" =~ ":Test\$" || "$plugin_class" =~ ":MarcFieldValues\$"); |
204 |
} |
205 |
ok($result, "Only included plugins are installed"); |
206 |
|
207 |
$schema->storage->txn_rollback; |
208 |
}; |
209 |
|
156 |
subtest 'Version upgrade tests' => sub { |
210 |
subtest 'Version upgrade tests' => sub { |
157 |
|
211 |
|
158 |
plan tests => 1; |
212 |
plan tests => 1; |
159 |
- |
|
|