From 553f1e0c4a9f664b8a627b57311b4eedbeabface Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Tue, 4 Jul 2006 04:14:20 +0000 Subject: [PATCH] Add new tests for unused numeric macros and the rownum macro in t/Macro/SQL.t Document how unused numeric macros are handled in the SQL macro and that rownum starts counting at 1. Quote entries in the related section to make detecting spaces in names easier. --- lib/WebGUI/i18n/English/Macro_SQL.pm | 7 +++++-- t/Help/related.t | 2 +- t/Macro/SQL.t | 10 ++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/WebGUI/i18n/English/Macro_SQL.pm b/lib/WebGUI/i18n/English/Macro_SQL.pm index 0092b141f..f81e6a8bb 100644 --- a/lib/WebGUI/i18n/English/Macro_SQL.pm +++ b/lib/WebGUI/i18n/English/Macro_SQL.pm @@ -15,13 +15,16 @@ our $I18N = { 'sql body' => { message => q|

^SQL();
-A one line SQL report. Sometimes you just need to pull something back from the database quickly. This macro is also useful in extending the SQL Report wobject. It uses the numeric macros (^0; ^1; ^2; etc) to position data and can also use the ^^rownum; macro just like the SQL Report wobject. Examples:

+A one line SQL report. Sometimes you just need to pull something back from the database quickly. This macro is also useful in extending the SQL Report wobject. It uses the numeric macros (^0; ^1; ^2; etc) to position data and can also use the ^^rownum; macro just like the SQL Report wobject.

+

Examples:

^SQL("select count(*) from users","There are ^0; users on this system.");

^SQL("select userId,username from users order by username","<a href='^/;?op=viewProfile&uid=^0;'>^1;</a><br />");

+

If there are more numeric macros than selected columns in the SQL report the extra macros will be discarded.

+

The rownum macro, ^rownum;, begins counting at 1.

|, - lastUpdated => 1146805799, + lastUpdated => 1151986323, }, 'illegal query' => { diff --git a/t/Help/related.t b/t/Help/related.t index fb3df5ccc..f30a26181 100644 --- a/t/Help/related.t +++ b/t/Help/related.t @@ -66,7 +66,7 @@ plan tests => scalar @relatedHelp + scalar @isaHelp; foreach my $related (@relatedHelp) { my ($topic, $entry, $parentTopic, $parentEntry) = @{ $related }{'namespace', 'tag', 'parentTopic', 'parentEntry'}; - ok( exists $helpTable{$topic}{$entry}, "Help entry: $topic -> $entry from $parentTopic -> $parentEntry"); + ok( exists $helpTable{$topic}{$entry}, "Help entry: $topic -> '$entry' from $parentTopic -> $parentEntry"); } foreach my $isa (@isaHelp) { diff --git a/t/Macro/SQL.t b/t/Macro/SQL.t index 06c4364a5..50bce5045 100644 --- a/t/Macro/SQL.t +++ b/t/Macro/SQL.t @@ -73,6 +73,16 @@ my @testSets = ( template => '^0;', output => 'Cannot execute this type of query.', }, + { ##Test unused macro variables + sql => q!select zero,one,two,three from testTable order by one!, + template => join(':', map { "^$_;" } 0..4).'-', + output => '0:1:2:3:-100:101:102:103:-', + }, + { ##rownum test + sql => q!select zero,one,two,three from testTable order by one!, + template => join(':', map { "^$_;" } 'rownum', 0..3).',', + output => '1:0:1:2:3,2:100:101:102:103,', + }, ); my $numTests = scalar @testSets;