|
Lines 26-32
use List::MoreUtils qw(none);
Link Here
|
| 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::NoWarnings; |
28 |
use Test::NoWarnings; |
| 29 |
use Test::More tests => 20; |
29 |
use Test::More tests => 21; |
| 30 |
use Test::Warn; |
30 |
use Test::Warn; |
| 31 |
use Test::Exception; |
31 |
use Test::Exception; |
| 32 |
|
32 |
|
|
Lines 137-142
subtest 'more call() tests' => sub {
Link Here
|
| 137 |
$schema->storage->txn_rollback; |
137 |
$schema->storage->txn_rollback; |
| 138 |
}; |
138 |
}; |
| 139 |
|
139 |
|
|
|
140 |
subtest 'call with SUSPEND_PLUGIN' => sub { |
| 141 |
plan tests => 4; |
| 142 |
$schema->storage->txn_begin; |
| 143 |
|
| 144 |
# Mocks; make sure that TestItemBarcodeTransform can install/report |
| 145 |
t::lib::Mocks::mock_config( 'enable_plugins', 1 ); |
| 146 |
Koha::Cache::Memory::Lite->clear_from_cache( Koha::Plugins->ENABLED_PLUGINS_CACHE_KEY ); |
| 147 |
my $mock_plugin = Test::MockModule->new('Koha::Plugin::TestItemBarcodeTransform'); |
| 148 |
$mock_plugin->mock( 'install', sub { return 1; } ); |
| 149 |
$mock_plugin->mock( 'report', sub { return 'What a report' } ); |
| 150 |
|
| 151 |
my $plugin1 = Koha::Plugin::Test->new( { enable_plugins => 1, cgi => CGI->new } ); |
| 152 |
my $plugin2 = Koha::Plugin::TestItemBarcodeTransform->new( { enable_plugins => 1, cgi => CGI->new } ); |
| 153 |
|
| 154 |
my $count1 = Koha::Plugins->call('report') // 0; |
| 155 |
ok( $count1 >= 2, 'We expect at least two report responses' ); |
| 156 |
|
| 157 |
# Suspend the report method |
| 158 |
$ENV{'SUSPEND_PLUGIN_report'} = 1; |
| 159 |
my $count2 = Koha::Plugins->call('report') // 0; |
| 160 |
is( $count2, 0, 'No responses expected when suspending method' ); |
| 161 |
delete $ENV{'SUSPEND_PLUGIN_report'}; |
| 162 |
|
| 163 |
# Suspend a class |
| 164 |
$ENV{'SUSPEND_PLUGIN_Koha_Plugin_Test'} = 1; |
| 165 |
$count2 = Koha::Plugins->call('report') // 0; |
| 166 |
is( $count2, $count1 - 1, 'One response less expected when suspending class' ); |
| 167 |
is( scalar grep( /What a report/, Koha::Plugins->call('report') ), 1, 'Output of TestItemBarcodeTransform found' ); |
| 168 |
delete $ENV{'SUSPEND_PLUGIN_Koha_Plugin_Test'}; |
| 169 |
|
| 170 |
$schema->storage->txn_rollback; |
| 171 |
}; |
| 172 |
|
| 140 |
subtest 'feature_enabled tests' => sub { |
173 |
subtest 'feature_enabled tests' => sub { |
| 141 |
plan tests => 4; |
174 |
plan tests => 4; |
| 142 |
|
175 |
|
| 143 |
- |
|
|