31
# No tests written for TT2 because I don't use it and apparently
32
# nobody else really does either...
37
# Need to fake a request or else we stall
38
$ENV{REQUEST_METHOD} = 'GET';
39
$ENV{QUERY_STRING} = 'ticket=111&user=pete&replacement=TRUE';
41
use CGI::FormBuilder 3.0501;
42
use CGI::FormBuilder::Test;
44
# Create our template and store it in a scalarref
45
my $template = outfile(0);
47
# What options we want to use, and what we expect to see
50
opt => { fields => [qw/name color/],
51
submit => 'No esta una button del resetto',
52
template => { type => 'TT2', template => \$template, variable => 'form' },
53
validate => { name => 'NAME' },
55
mod => { color => { options => [qw/red green blue/],
56
label => 'Best Color', value => 'red' },
57
size => { value => 42 },
58
sex => { options => [[M=>'Male'],[F=>'Female']] }
63
opt => { fields => [qw/name color size/],
64
template => { type => 'TT2', template => \$template, variable => 'form' },
65
values => {color => [qw/purple/], size => 8},
66
submit => 'Start over, boob!',
69
mod => { color => { options => [[white=>'White'],[black=>'Black'],[red=>'Green']],
71
name => { size => 80, maxlength => 80, comment => 'Fuck off' },
72
sex => { options => [[1=>'Yes'], [0=>'No'], [-1=>'Maybe']],
73
label => 'Fuck me?<br>' },
78
opt => { fields => [qw/name color email/], submit => [qw/Update Delete/], reset => 0,
79
template => { type => 'TT2', template => \$template, variable => 'form' },
80
values => {color => [qw/yellow green orange/]},
81
validate => { sex => [qw(1 3 5)] },
84
mod => { color => {options => [[red => 1], [blue => 2], [yellow => 3], [pink => 4]] },
85
size => {comment => '(unknown)', value => undef, force => 1 } ,
86
sex => {label => 'glass EYE fucker', options => [[1,2],[3,4],[5,6]] },
91
opt => { fields => [qw/yomomma mymomma/], submit => [qw/Remove Dance_With/], reset => 1,
92
template => { type => 'TT2', template => \$template, variable => 'form' },
93
values => {mymomma => [qw/medium large xxl/]},
94
validate => { yomomma => 'NAME' },
102
# Perl 5 is sick sometimes.
103
@test = @test[$ARGV[0] - 1] if @ARGV;
104
my $seq = $ARGV[0] || 1;
106
# Cycle thru and try it out
108
my $form = CGI::FormBuilder->new(
115
# the ${mod} key twiddles fields
116
while(my($f,$o) = each %{$_->{mod} || {}}) {
122
# Just compare the output of render with what's expected
123
# the correct string output is now in external files.
124
# The seemingly extra eval is required so that failures
125
# to import the template modules do not kill the tests.
126
# (since render is called regardless of whether $SKIP is set)
128
my $out = outfile($seq++);
129
my $ren = $SKIP ? '' : $form->render;
130
my $ok = skip($SKIP, $ren, $out);
132
if (! $ok && $ENV{LOGNAME} eq 'nwiger') {
133
open(O, ">/tmp/fb.1.html");
137
open(O, ">/tmp/fb.2.html");
141
system "diff /tmp/fb.1.html /tmp/fb.2.html";