From 8525a71874c60410de525e30ac2514b25e9319a9 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 17 Feb 2026 09:59:13 -0500 Subject: [PATCH] Bug 36542: Update unit test Signed-off-by: Kyle M Hall --- .../Koha/Plugins/Biblio_and_Items_plugin_hooks.t | 4 ++-- t/lib/plugins/Koha/Plugin/Test.pm | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/t/db_dependent/Koha/Plugins/Biblio_and_Items_plugin_hooks.t b/t/db_dependent/Koha/Plugins/Biblio_and_Items_plugin_hooks.t index 09f9517741f..d3bfd6041c5 100755 --- a/t/db_dependent/Koha/Plugins/Biblio_and_Items_plugin_hooks.t +++ b/t/db_dependent/Koha/Plugins/Biblio_and_Items_plugin_hooks.t @@ -62,11 +62,11 @@ subtest 'after_biblio_action() and after_item_action() hooks tests' => sub { my $biblio_id; warning_like { ( $biblio_id, undef ) = C4::Biblio::AddBiblio( MARC::Record->new(), '' ); } - qr/after_biblio_action called with action: create, ref: Koha::Biblio/, + qr/after_biblio_action called with action: create, ref: Koha::Biblio, biblio found/, 'AddBiblio calls the hook with action=create'; warning_like { C4::Biblio::ModBiblio( MARC::Record->new(), $biblio_id, '' ); } - qr/after_biblio_action called with action: modify, ref: Koha::Biblio/, + qr/after_biblio_action called with action: modify, ref: Koha::Biblio, biblio found/, 'ModBiblio calls the hook with action=modify'; my $item; diff --git a/t/lib/plugins/Koha/Plugin/Test.pm b/t/lib/plugins/Koha/Plugin/Test.pm index 4d6bd517f69..0d9ad568c39 100644 --- a/t/lib/plugins/Koha/Plugin/Test.pm +++ b/t/lib/plugins/Koha/Plugin/Test.pm @@ -6,6 +6,8 @@ use Modern::Perl; use Koha::Exception; use Koha::Plugins::Tab; +use Koha::Biblios; + use MARC::Field; use Mojo::JSON qw( decode_json ); @@ -192,7 +194,15 @@ sub after_biblio_action { my $biblio_id = $payload->{biblio_id}; if ( $action ne 'delete' ) { - Koha::Exception->throw( "after_biblio_action called with action: $action, ref: " . ref($biblio) ); + $biblio = Koha::Biblios->find($biblio_id); + if ($biblio) { + $biblio_id = $biblio->id; + Koha::Exception->throw( + "after_biblio_action called with action: $action, ref: " . ref($biblio) . ", biblio found" ); + } else { + Koha::Exception->throw( + "after_biblio_action called with action: $action, ref: " . ref($biblio) . ", biblio not found" ); + } } else { Koha::Exception->throw("after_biblio_action called with action: $action, id: $biblio_id") if $biblio_id; } -- 2.50.1 (Apple Git-155)