From 5deb0455ef5b5a2ffe8cbe26a75cdd07e8788ded Mon Sep 17 00:00:00 2001 From: tetragon Date: Fri, 1 Jun 2007 14:13:33 +0000 Subject: Templating updates for output handling git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1248 4979c152-3d1c-0410-bac9-87ea11338e46 --- t/04-template-handling.t | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) (limited to 't/04-template-handling.t') diff --git a/t/04-template-handling.t b/t/04-template-handling.t index 04048b10..0e2f52bb 100644 --- a/t/04-template-handling.t +++ b/t/04-template-handling.t @@ -3,13 +3,14 @@ use strict; use warnings; -$ENV{TMPDIR} = 't/var'; +#$ENV{TMPDIR} = 't/var'; +$ENV{TMPDIR} = '/Users/seneca/sourceforge-svn/ledger-smb/trunk/t/var'; use Test::More 'no_plan'; use Test::Trap qw(trap $trap); use Test::Exception; -use Error qw(:try); +use Error qw(:try :warndie); use LedgerSMB::AM; use LedgerSMB::Form; @@ -212,3 +213,40 @@ ok(defined $template, 'Template, new: Object creation with non-existent format'); throws_ok{$template->render({'login' => 'foo'})} qr/Can't locate/, 'Template, render: Invalid format caught'; + +$template = undef; +$template = new LedgerSMB::Template('user' => $myconfig, 'format' => 'PDF', + 'template' => '04-template'); +ok(defined $template, + 'Template, new: Object creation with format and template'); +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\&bar'}), 't/var/04-template-output.pdf', + 'Template, render: Simple PDF template, default filename'); +ok(-e 't/var/04-template-output.pdf', 'Template, render (PDF): File created'); + +$template = undef; +$template = new LedgerSMB::Template('user' => $myconfig, 'format' => 'PS', + 'template' => '04-template'); +ok(defined $template, + 'Template, new: Object creation with format and template'); +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\&bar'}), 't/var/04-template-output.ps', + 'Template, render: Simple Postscript template, default filename'); +ok(-e 't/var/04-template-output.ps', 'Template, render (PS): 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&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'); + -- cgit v1.2.3