From d35ef0ec9da16f1fd477b1d0b2604ec022cfc0f0 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 9 Feb 2023 11:45:02 +0100 Subject: [PATCH] Bug 32539: Add tests Signed-off-by: Jonathan Druart --- .../Koha/Template/Plugin/KohaPlugins.t | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Template/Plugin/KohaPlugins.t b/t/db_dependent/Koha/Template/Plugin/KohaPlugins.t index 04763b2f25f..4e34e602884 100755 --- a/t/db_dependent/Koha/Template/Plugin/KohaPlugins.t +++ b/t/db_dependent/Koha/Template/Plugin/KohaPlugins.t @@ -2,7 +2,8 @@ use Modern::Perl; -use Test::More tests => 14; +use Test::More tests => 18; +use Test::Warn; use CGI; use File::Basename; use File::Spec; @@ -52,6 +53,19 @@ ok( index( $plugin->get_plugins_opac_head, 'Koha::Plugin::Test::opac_head' ) != ok( index( $plugin->get_plugins_intranet_js, 'Koha::Plugin::Test::intranet_js' ) != -1, 'Test plugin intranet_js return value is part of code returned by get_plugins_intranet_js' ); ok( index( $plugin->get_plugins_intranet_head, 'Koha::Plugin::Test::intranet_head' ) != -1, 'Test plugin intranet_head return value is part of code returned by get_plugins_intranet_head' ); +sub boom { + my ( $self, $file ) = @_; + die "Something wrong is happening in this hook"; +} +$mock_plugin->mock( 'opac_head', \&boom ); +$mock_plugin->mock( 'opac_js', \&boom ); +$mock_plugin->mock( 'intranet_head', \&boom ); +$mock_plugin->mock( 'intranet_js', \&boom ); +warning_like { $plugin->get_plugins_opac_head } qr{Error calling 'opac_head' on the Koha::Plugin::Testplugin \(Something wrong is happening in this hook}; +warning_like { $plugin->get_plugins_opac_js } qr{Error calling 'opac_js' on the Koha::Plugin::Testplugin \(Something wrong is happening in this hook}; +warning_like { $plugin->get_plugins_intranet_head } qr{Error calling 'intranet_head' on the Koha::Plugin::Testplugin \(Something wrong is happening in this hook}; +warning_like { $plugin->get_plugins_intranet_js } qr{Error calling 'intranet_js' on the Koha::Plugin::Testplugin \(Something wrong is happening in this hook}; + t::lib::Mocks::mock_config('enable_plugins',0); is( $plugin->get_plugins_opac_js, q{}, 'Test plugin opac_js return value is empty' ); is( $plugin->get_plugins_opac_head, q{}, 'Test plugin opac_head return value is empty' ); -- 2.25.1