added test file
[webpac2] / t / 5-output-tt.t
1 #!/usr/bin/perl -w
2
3 use strict;
4 use lib 'lib';
5
6 use Test::More tests => 5;
7
8 BEGIN {
9 use_ok( 'WebPAC::Test' );
10 use_ok( 'WebPAC::Output::TT' );
11 }
12
13 ok(my $tt = new WebPAC::Output::TT(
14         include_path => "$abs_path../conf/output/tt",
15         %LOG
16 ), "new");
17
18 my $ds = {
19         'Source' => {
20                 'name' => 'Izvor: ',
21                 'tag' => 'Source',
22                 'display' => [ 'foo' ]
23                 },
24         'ID' => {
25                 'name' => 'ID',
26                 'tag' => 'IDths',
27                 'search' => [ 'bar' ],
28                 'lookup_key' => [ 'bar' ]
29                 },
30         'filename' => [ 'out/thes/001.html' ],
31         'name' => 'filename',
32         'tag' => 'filename'
33 };
34
35 throws_ok { $tt->apply( template => 'foo', data => [] ) } qr/error.*foo/, "apply without template";
36
37 cmp_ok(my $text = $tt->apply( template => 'text.tt', data => $ds ), '=~', qr/Source.*foo/, "apply");
38
39 diag $text if $debug;
40