Bugzilla – Attachment 193143 Details for
Bug 38384
General fix for plugins breaking database transactions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38384: (follow-up) Improve tests for caching
Bug-38384-follow-up-Improve-tests-for-caching.patch (text/plain), 3.09 KB, created by
Nick Clemens (kidclamp)
on 2026-02-13 17:40:17 UTC
(
hide
)
Description:
Bug 38384: (follow-up) Improve tests for caching
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2026-02-13 17:40:17 UTC
Size:
3.09 KB
patch
obsolete
>From c343b154fc1735ef881bb05542c992e27e60b4d7 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 13 Feb 2026 17:33:42 +0000 >Subject: [PATCH] Bug 38384: (follow-up) Improve tests for caching > >--- > t/db_dependent/Koha/Plugins/Loader.t | 39 +++++++++++++++++++++++++--- > 1 file changed, 35 insertions(+), 4 deletions(-) > >diff --git a/t/db_dependent/Koha/Plugins/Loader.t b/t/db_dependent/Koha/Plugins/Loader.t >index df1507b420d..b919af9baae 100755 >--- a/t/db_dependent/Koha/Plugins/Loader.t >+++ b/t/db_dependent/Koha/Plugins/Loader.t >@@ -17,7 +17,7 @@ > use Modern::Perl; > use File::Basename; > use Test::MockModule; >-use Test::More tests => 6; >+use Test::More tests => 9; > use Test::NoWarnings; > use Test::Warn; > >@@ -35,12 +35,15 @@ BEGIN { > t::lib::Mocks::mock_config( 'pluginsdir', $path ); > > use_ok('Koha::Plugins::Loader'); >+ use_ok('Koha::Plugins'); >+ use_ok('Koha::Plugins::Handler'); >+ use_ok('Koha::Plugin::Test'); > } > > my $schema = Koha::Database->new->schema; > > subtest 'get_enabled_plugins - basic functionality' => sub { >- plan tests => 4; >+ plan tests => 8; > > $schema->storage->txn_begin; > >@@ -50,13 +53,41 @@ subtest 'get_enabled_plugins - basic functionality' => sub { > # Remove any existing plugins > Koha::Plugins::Datas->delete; > >+ my $cache_key = 'enabled_plugins'; >+ > # Test with no enabled plugins > my @plugins = Koha::Plugins::Loader->get_enabled_plugins(); > is( scalar @plugins, 0, 'Returns empty list when no plugins are enabled' ); > > # Test caching behavior >- my @plugins_cached = Koha::Plugins::Loader->get_enabled_plugins(); >- is( scalar @plugins_cached, 0, 'Cached empty result works correctly' ); >+ my $cached = Koha::Cache::Memory::Lite->get_from_cache($cache_key); >+ is( $cached, undef, "Nothing cached when no plugins" ); >+ >+ my $mock_plugins = Test::MockModule->new("Koha::Plugins"); >+ $mock_plugins->mock( 'can_load', sub { return 0; } ); >+ >+ # Test with invalid plugin class that can't be loaded by adding directly to DB >+ Koha::Plugins::Data->new( >+ { >+ plugin_class => 'Koha::Plugin::Test', >+ plugin_key => '__ENABLED__', >+ plugin_value => 1, >+ } >+ )->store; >+ my $mock_test_plugin = Test::MockModule->new("Koha::Plugin::Test"); >+ $mock_test_plugin->mock( 'new', sub { return "Test"; } ); >+ >+ @plugins = Koha::Plugins::Loader->get_enabled_plugins(); >+ is( scalar @plugins, 0, 'Returns empty list when no plugins are loaded' ); >+ $cached = Koha::Cache::Memory::Lite->get_from_cache($cache_key); >+ is( $cached, undef, "Nothing cached when no plugins can be loaded" ); >+ >+ $mock_plugins->mock( "can_load", sub { return 1; } ); >+ >+ @plugins = Koha::Plugins::Loader->get_enabled_plugins(); >+ is( scalar @plugins, 1, 'Returns the plugin when loaded' ); >+ $cached = Koha::Cache::Memory::Lite->get_from_cache($cache_key); >+ is( @{$cached}[0], $plugins[0], "Plugin successfully loaded and cached" ); > > # The core functionality of loading plugins is tested indirectly through > # the Koha::Plugins tests which use the Loader >-- >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 38384
:
174150
|
174264
|
174265
|
174280
|
174282
|
189636
|
189637
|
189638
|
189639
|
189640
|
190514
|
190515
|
190516
|
190517
|
191860
|
192119
|
192628
|
192629
|
192630
|
192631
|
192632
|
192633
|
192662
|
192663
|
192664
|
192665
|
192666
|
192667
|
193142
|
193143
|
193144
|
193171
|
193172
|
193173
|
193174
|
193175
|
193176
|
193177
|
193178
|
193179