From 17ce0a83d97bede1a166b9841be7b1348477189a Mon Sep 17 00:00:00 2001 From: tetragon Date: Tue, 2 Oct 2007 02:54:28 +0000 Subject: Adding format_options and output_options template constructor arguments Merging PDF and Postscript generation to the same file Adding DVI support git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1684 4979c152-3d1c-0410-bac9-87ea11338e46 --- t/01-load.t | 4 ++-- t/04-template-handling.t | 43 ++++++++++++++++++++++++++++++++++--------- 2 files changed, 36 insertions(+), 11 deletions(-) (limited to 't') diff --git a/t/01-load.t b/t/01-load.t index 8b84cd88..6d654615 100644 --- a/t/01-load.t +++ b/t/01-load.t @@ -32,10 +32,10 @@ use_ok('LedgerSMB::Session'); use_ok('LedgerSMB::Sysconfig'); use_ok('LedgerSMB::Tax'); use_ok('LedgerSMB::Template'); +use_ok('LedgerSMB::Template::Elements'); use_ok('LedgerSMB::Template::CSV'); use_ok('LedgerSMB::Template::HTML'); -use_ok('LedgerSMB::Template::PDF'); -use_ok('LedgerSMB::Template::PS'); +use_ok('LedgerSMB::Template::LaTeX'); use_ok('LedgerSMB::Template::TXT'); use_ok('LedgerSMB::User'); diff --git a/t/04-template-handling.t b/t/04-template-handling.t index e97980e2..27e63bf3 100644 --- a/t/04-template-handling.t +++ b/t/04-template-handling.t @@ -17,9 +17,10 @@ use LedgerSMB::Form; use LedgerSMB::Sysconfig; use LedgerSMB::Locale; use LedgerSMB::Template; +use LedgerSMB::Template::Elements; +use LedgerSMB::Template::CSV; use LedgerSMB::Template::HTML; -use LedgerSMB::Template::PDF; -use LedgerSMB::Template::PS; +use LedgerSMB::Template::LaTeX; use LedgerSMB::Template::TXT; $LedgerSMB::Sysconfig::tempdir = 't/var'; @@ -153,19 +154,19 @@ is(LedgerSMB::Template::HTML::postprocess({outputfile => '04-template'}), # Template->new $myconfig = {'templates' => 't/data'}; -throws_ok{new LedgerSMB::Template('user' => $myconfig, 'language' => 'x/0')} +throws_ok{new LedgerSMB::Template('user' => $myconfig, 'language' => 'x/0', 'format' => 'HTML')} qr/Invalid language/, 'Template, new: Invalid language caught 1'; -throws_ok{new LedgerSMB::Template('user' => $myconfig, 'language' => '1\\2')} +throws_ok{new LedgerSMB::Template('user' => $myconfig, 'language' => '1\\2', 'format' => 'HTML')} qr/Invalid language/, 'Template, new: Invalid language caught 2'; -throws_ok{new LedgerSMB::Template('user' => $myconfig, 'language' => '1:2')} +throws_ok{new LedgerSMB::Template('user' => $myconfig, 'language' => '1:2', 'format' => 'HTML')} qr/Invalid language/, 'Template, new: Invalid language caught 3'; -throws_ok{new LedgerSMB::Template('user' => $myconfig, 'language' => '..')} +throws_ok{new LedgerSMB::Template('user' => $myconfig, 'language' => '..', 'format' => 'HTML')} qr/Invalid language/, 'Template, new: Invalid language caught 4'; -throws_ok{new LedgerSMB::Template('user' => $myconfig, 'language' => '.svn')} +throws_ok{new LedgerSMB::Template('user' => $myconfig, 'language' => '.svn', 'format' => 'HTML')} qr/Invalid language/, 'Template, new: Invalid language caught 5'; $template = undef; -$template = new LedgerSMB::Template('user' => $myconfig, 'language' => 'de'); +$template = new LedgerSMB::Template('user' => $myconfig, 'language' => 'de', 'format' => 'HTML'); ok(defined $template, 'Template, new: Object creation with valid language'); isa_ok($template, 'LedgerSMB::Template', 'Template, new: Object creation with valid language'); @@ -173,7 +174,7 @@ is($template->{include_path}, 't/data/de;t/data', 'Template, new: Object creation with valid language has good include_path'); $template = undef; $template = new LedgerSMB::Template('user' => $myconfig, 'language' => 'de', - 'path' => 't/data', 'output_file' => 'test'); + 'path' => 't/data', 'output_file' => 'test', 'format' => 'HTML'); ok(defined $template, 'Template, new: Object creation with valid language and path'); isa_ok($template, 'LedgerSMB::Template', @@ -277,6 +278,21 @@ is($template->render({'login' => 'foo&bar'}), is($template->{output}, "I am a template.\nLook at me foo&bar.", 'Template, render (HTML): Simple HTML template, correct output'); +$template = undef; +$template = new LedgerSMB::Template('user' => $myconfig, 'format' => 'HTML', + 'template' => \'Look at me .', 'no_auto_output' => 1); +ok(defined $template, + 'Template, new (HTML): Object creation with string template'); +isa_ok($template, 'LedgerSMB::Template', + 'Template, new (HTML): Object creation with string template'); +is($template->{include_path}, 't/data', + 'Template, new (HTML): Object creation with string template'); +is($template->render({'login' => 'foo&bar'}), + undef, + 'Template, render (HTML): Simple HTML string template, no file'); +is($template->{output}, "Look at me foo&bar.", + 'Template, render (HTML): Simple HTML string template, correct output'); + $template = undef; $template = new LedgerSMB::Template('user' => $myconfig, 'format' => 'HTML', 'template' => '04-gettext', 'output_file' => '04-gettext', @@ -327,3 +343,12 @@ SKIP: { ok(!-e "t/var/04-gettext-output-$$.pdf", 'Template, render (PDF): testfile removed'); } + +################################### +## LedgerSMB::Template::Elements ## +################################### + +$template = undef; +$form = undef; + +$form = new Form; -- cgit v1.2.3