From bb16931d9d544ea7c71c0ddc58dfdfea60393e22 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Joonas=20Kylm=C3=A4l=C3=A4?= Date: Sun, 3 Oct 2021 10:53:40 +0000 Subject: [PATCH] Bug 28303: Add unit test for badtemplatecheck MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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ä Signed-off-by: Jonathan Druart --- t/db_dependent/Templates.t | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Templates.t b/t/db_dependent/Templates.t index 5d44d47fa5..b6c3e7e4ec 100755 --- a/t/db_dependent/Templates.t +++ b/t/db_dependent/Templates.t @@ -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 { -- 2.39.5