Bug 28303: Add unit test for badtemplatecheck

This tests that pluginsdir value is not modified by the call to
badtemplatecheck to make sure badtemplatecheck operates with its own
copy of pluginsdir configuration value.

Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Joonas Kylmälä 2021-10-03 10:53:40 +00:00 committed by Jonathan Druart
parent 17a1b0cec5
commit bb16931d9d
1 changed files with 7 additions and 1 deletions

View File

@ -101,7 +101,7 @@ subtest 'Testing themelanguage' => sub {
};
subtest 'Testing gettemplate/badtemplatecheck' => sub {
plan tests => 7;
plan tests => 8;
my $cgi = CGI->new;
my $template;
@ -118,6 +118,12 @@ subtest 'Testing gettemplate/badtemplatecheck' => sub {
warning_like { eval { C4::Templates::badtemplatecheck( '/tmp/about.tt' ) }; warn $@ if $@; } undef, 'No warn on template from plugin dir';
# Refuse wrong extension
warning_like { eval { C4::Templates::badtemplatecheck( '/tmp/about.tmpl' ) }; warn $@ if $@; } qr/bad template/, 'Warn on bad extension';
# Make sure badtemplatecheck works on a copy of pluginsdir and doesn't modify its values
t::lib::Mocks::mock_config( 'pluginsdir', [ '/tmp', '/tmp2' ] );
C4::Templates::badtemplatecheck('/tmp/test.tt');
cmp_deeply( C4::Context->config('pluginsdir'), ['/tmp', '/tmp2'], "Doesn't modify configuration values" );
};
subtest "Absolute path change in _get_template_file" => sub {