Bug 32539: Add tests

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 7bb4aeba9f)
Signed-off-by: Jacob O'Mara <jacob.omara@ptfs-europe.com>
This commit is contained in:
Jonathan Druart 2023-02-09 11:45:02 +01:00 committed by Jacob O'Mara
parent 0623ba78e5
commit 24363f91da

View file

@ -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' );