Bugzilla – Attachment 194516 Details for
Bug 41991
Suspend a plugin method or specific plugin class (per process or vhost)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 41991: Unit tests
Bug-41991-Unit-tests.patch (text/plain), 2.59 KB, created by
Marcel de Rooy
on 2026-03-05 15:03:53 UTC
(
hide
)
Description:
Bug 41991: Unit tests
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2026-03-05 15:03:53 UTC
Size:
2.59 KB
patch
obsolete
>From 084dff4e3b41698298a36086978275c61834eeff Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 5 Mar 2026 15:45:55 +0100 >Subject: [PATCH] Bug 41991: Unit tests >Content-Type: text/plain; charset=utf-8 > >Test plan: >Run t/db_dependent/Koha/Plugins/Plugins.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > t/db_dependent/Koha/Plugins/Plugins.t | 35 ++++++++++++++++++++++++++- > 1 file changed, 34 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Plugins/Plugins.t b/t/db_dependent/Koha/Plugins/Plugins.t >index 9988bfff14..3339d450c5 100755 >--- a/t/db_dependent/Koha/Plugins/Plugins.t >+++ b/t/db_dependent/Koha/Plugins/Plugins.t >@@ -26,7 +26,7 @@ use List::MoreUtils qw(none); > use Module::Load::Conditional qw(can_load); > use Test::MockModule; > use Test::NoWarnings; >-use Test::More tests => 20; >+use Test::More tests => 21; > use Test::Warn; > use Test::Exception; > >@@ -137,6 +137,39 @@ subtest 'more call() tests' => sub { > $schema->storage->txn_rollback; > }; > >+subtest 'call with SUSPEND_PLUGIN' => sub { >+ plan tests => 4; >+ $schema->storage->txn_begin; >+ >+ # Mocks; make sure that TestItemBarcodeTransform can install/report >+ t::lib::Mocks::mock_config( 'enable_plugins', 1 ); >+ Koha::Cache::Memory::Lite->clear_from_cache( Koha::Plugins->ENABLED_PLUGINS_CACHE_KEY ); >+ my $mock_plugin = Test::MockModule->new('Koha::Plugin::TestItemBarcodeTransform'); >+ $mock_plugin->mock( 'install', sub { return 1; } ); >+ $mock_plugin->mock( 'report', sub { return 'What a report' } ); >+ >+ my $plugin1 = Koha::Plugin::Test->new( { enable_plugins => 1, cgi => CGI->new } ); >+ my $plugin2 = Koha::Plugin::TestItemBarcodeTransform->new( { enable_plugins => 1, cgi => CGI->new } ); >+ >+ my $count1 = Koha::Plugins->call('report') // 0; >+ ok( $count1 >= 2, 'We expect at least two report responses' ); >+ >+ # Suspend the report method >+ $ENV{'SUSPEND_PLUGIN_report'} = 1; >+ my $count2 = Koha::Plugins->call('report') // 0; >+ is( $count2, 0, 'No responses expected when suspending method' ); >+ delete $ENV{'SUSPEND_PLUGIN_report'}; >+ >+ # Suspend a class >+ $ENV{'SUSPEND_PLUGIN_Koha_Plugin_Test'} = 1; >+ $count2 = Koha::Plugins->call('report') // 0; >+ is( $count2, $count1 - 1, 'One response less expected when suspending class' ); >+ is( scalar grep( /What a report/, Koha::Plugins->call('report') ), 1, 'Output of TestItemBarcodeTransform found' ); >+ delete $ENV{'SUSPEND_PLUGIN_Koha_Plugin_Test'}; >+ >+ $schema->storage->txn_rollback; >+}; >+ > subtest 'feature_enabled tests' => sub { > plan tests => 4; > >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 41991
:
194514
|
194515
| 194516