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