From 023b4a9374b0d1e78d9051c2714026ad44fdb916 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Sun, 29 Jan 2017 15:52:22 +0100 Subject: [PATCH] Bug 18010: Unit test for gettemplate Content-Type: text/plain; charset=utf-8 A trivial test, similar to the ones in Auth.t. Without the check in gettemplate (added in the second patch), the passwd file will be exposed and the test fails. Test plan: Run t/db_dependent/Templates.t without second patch. The two tests in the last subtest should fail. Signed-off-by: Marcel de Rooy --- t/db_dependent/Templates.t | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Templates.t b/t/db_dependent/Templates.t index 5c3b7c8..a55d028 100755 --- a/t/db_dependent/Templates.t +++ b/t/db_dependent/Templates.t @@ -19,9 +19,10 @@ use Modern::Perl; use CGI; -use Test::More tests => 6; +use Test::More tests => 7; use Test::Deep; use Test::MockModule; +use Test::Warn; use t::lib::Mocks; @@ -59,4 +60,12 @@ subtest 'Testing themelanguage for unique themes (BZ 17982)' => sub { cmp_deeply( ( C4::Templates::themelanguage( C4::Context->config('intrahtdocs'), 'about.tt' , 'intranet', 'fake_cgi' ) )[2], [ 'prog' ], 'We only expect one prog here' ); }; +subtest 'Testing gettemplate' => sub { + plan tests => 2; + + my $template; + warning_like { eval { $template = C4::Templates::gettemplate( '/etc/passwd', 'opac', CGI->new, 1 ) }; warn $@ if $@; } qr/bad template/, 'Bad template check'; + is( $template ? $template->output: '', '', 'Check output' ); +}; + 1; -- 2.1.4