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