summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authortetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46>2007-05-26 23:57:13 +0000
committertetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46>2007-05-26 23:57:13 +0000
commitb9982a0314b74a8fb342a20568a3e15b90d625bc (patch)
tree9cfe46d004c4f776babefe0eb7fbadb7435491bc /t
parent5f4e46ad636f986668a65aeaa7ce7ae314365378 (diff)
Adding PDF and Postscript support to LedgerSMB::Template
Removing all calls to $form->parse_template git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1241 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 't')
-rw-r--r--t/01-load.t4
-rw-r--r--t/04-template-handling.t32
2 files changed, 22 insertions, 14 deletions
diff --git a/t/01-load.t b/t/01-load.t
index d2cde8f1..ac7c970d 100644
--- a/t/01-load.t
+++ b/t/01-load.t
@@ -2,7 +2,7 @@
use strict;
use warnings;
-use Test::More tests => 32;
+use Test::More tests => 34;
use_ok('LedgerSMB');
use_ok('LedgerSMB::AA');
@@ -34,6 +34,8 @@ use_ok('LedgerSMB::Sysconfig');
use_ok('LedgerSMB::Tax');
use_ok('LedgerSMB::Template');
use_ok('LedgerSMB::Template::HTML');
+use_ok('LedgerSMB::Template::PDF');
+use_ok('LedgerSMB::Template::PS');
use_ok('LedgerSMB::User');
SKIP: {
diff --git a/t/04-template-handling.t b/t/04-template-handling.t
index f9b458f9..04048b10 100644
--- a/t/04-template-handling.t
+++ b/t/04-template-handling.t
@@ -18,6 +18,8 @@ use LedgerSMB::Locale;
use LedgerSMB::Template;
use LedgerSMB::Template::HTML;
+$LedgerSMB::Sysconfig::tempdir = 't/var';
+
my @r;
my $temp;
my $form;
@@ -131,8 +133,8 @@ is_deeply(LedgerSMB::Template::HTML::preprocess({'fruit' => '&veggies',
'test' => ['nest', 'bird', '0 < 15', 1]}),
{'fruit' => '&amp;veggies', 'test' => ['nest', 'bird', '0 &lt; 15', 1]},
'HTML, preprocess: Returned properly escaped nested contents');
-is(LedgerSMB::Template::HTML::postprocess('04-template'), undef,
- 'HTML, postprocess: Return undef');
+is(LedgerSMB::Template::HTML::postprocess({outputfile => '04-template'}),
+ '04-template.html', 'HTML, postprocess: Return output filename');
# Template->new
$myconfig = {'templates' => 't/data'};
@@ -173,9 +175,19 @@ isa_ok($template, 'LedgerSMB::Template',
'Template, new: Object creation with format and template');
is($template->{include_path}, 't/data',
'Template, new: Object creation with format and template');
-is($template->render({'login' => 'foo'}),
- "I am a template.\nLook at me foo.\n",
- 'Template, render: Simple HTML template');
+is($template->render({'login' => 'foo&bar'}), 't/var/04-template-output.html',
+ 'Template, render: Simple HTML template, default filename');
+ok(-e 't/var/04-template-output.html', 'Template, render (HTML): File created');
+open($FH, '<', 't/var/04-template-output.html');
+@r = <$FH>;
+close($FH);
+chomp(@r);
+is(join("\n", @r), "I am a template.\nLook at me foo&amp;bar.",
+ 'Template, render (HTML): Simple HTML template, correct output');
+is(unlink('t/var/04-template-output.html'), 1,
+ 'Template, render: removing testfile');
+ok(!-e 't/var/04-template-output.html',
+ 'Template, render (HTML): testfile removed');
$template = undef;
$template = new LedgerSMB::Template('user' => $myconfig, 'format' => 'HTML',
@@ -184,12 +196,6 @@ ok(defined $template,
'Template, new: Object creation with locale');
isa_ok($template, 'LedgerSMB::Template',
'Template, new: Object creation with locale');
-TODO: {
- local $TODO = 'gettext substitution of passed in data';
- is($template->render({'login' => 'April'}),
- "I am a template.\nLook at me Avril.\n",
- 'Template, render: HTML template with locale');
-}
$template = undef;
$template = new LedgerSMB::Template('user' => $myconfig, 'format' => 'HTML',
@@ -197,7 +203,7 @@ $template = new LedgerSMB::Template('user' => $myconfig, 'format' => 'HTML',
ok(defined $template,
'Template, new: Object creation with non-existent template');
throws_ok{$template->render({'login' => 'foo'})} qr/not found/,
- 'render: File not found caught';
+ 'Template, render: File not found caught';
$template = undef;
$template = new LedgerSMB::Template('user' => $myconfig, 'format' => 'TODO',
@@ -205,4 +211,4 @@ $template = new LedgerSMB::Template('user' => $myconfig, 'format' => 'TODO',
ok(defined $template,
'Template, new: Object creation with non-existent format');
throws_ok{$template->render({'login' => 'foo'})} qr/Can't locate/,
- 'render: Invalid format caught';
+ 'Template, render: Invalid format caught';