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 09f9517741..d3bfd6041c 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 4d6bd517f6..0d9ad568c3 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; }