Bug 18010: Unit test for gettemplate
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Sun, 29 Jan 2017 14:52:22 +0000 (15:52 +0100)
committerJulian Maurice <julian.maurice@biblibre.com>
Fri, 31 Mar 2017 13:19:19 +0000 (15:19 +0200)
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 <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>
(cherry picked from commit 5508897d5a2b73c30d50fed26a6bfed62bf49398)
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Conflicts:
t/db_dependent/Templates.t

(cherry picked from commit 1161a67476b5b61358fdaecca57b012e663a7b02)
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>

t/db_dependent/Templates.t

index 236bd1e..852884b 100755 (executable)
@@ -19,8 +19,12 @@ use Modern::Perl;
 
 use CGI;
 
-use Test::More tests => 5;
+use Test::More tests => 6;
 use Test::Deep;
+use Test::MockModule;
+use Test::Warn;
+
+use t::lib::Mocks;
 
 BEGIN {
     use_ok( 'C4::Templates' );
@@ -46,4 +50,12 @@ my @tables = ( 'biblio', 'biblioitems', 'borrowers', 'items', 'statistics', 'sub
 cmp_deeply( \@keys, \@tables, "GetColumnDefs returns the expected tables");
 
 
+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;