1 |
dpavlin |
16 |
#!/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 |
dpavlin |
31 |
no_log => 1, |
20 |
|
|
), "new"); |
21 |
dpavlin |
16 |
|
22 |
dpavlin |
70 |
my $ds = { |
23 |
|
|
'Source' => { |
24 |
|
|
'name' => 'Izvor: ', |
25 |
|
|
'tag' => 'Source', |
26 |
|
|
'display' => [ 'foo' ] |
27 |
|
|
}, |
28 |
|
|
'ID' => { |
29 |
|
|
'name' => 'ID', |
30 |
|
|
'tag' => 'IDths', |
31 |
dpavlin |
212 |
'search' => [ 'bar' ], |
32 |
dpavlin |
70 |
'lookup_key' => [ 'bar' ] |
33 |
|
|
}, |
34 |
dpavlin |
16 |
'filename' => [ 'out/thes/001.html' ], |
35 |
|
|
'name' => 'filename', |
36 |
|
|
'tag' => 'filename' |
37 |
dpavlin |
70 |
}; |
38 |
dpavlin |
16 |
|
39 |
|
|
throws_ok { $tt->apply( template => 'foo', data => [] ) } qr/error.*foo/, "apply without template"; |
40 |
|
|
|
41 |
dpavlin |
70 |
cmp_ok(my $text = $tt->apply( template => 'text.tt', data => $ds ), '=~', qr/Source.*foo/, "apply"); |
42 |
dpavlin |
16 |
|
43 |
|
|
diag $text; |
44 |
|
|
|