1
#!/usr/bin/perl -Ilib -I../lib
3
3
# Copyright (c) 2000-2006 Nathan Wiger <nate@wiger.org>.
4
4
# All Rights Reserved. If you're reading this, you're bored.
5
5
# 1a-generate.t - test FormBuilder generation of forms
8
use vars qw($TESTING $DEBUG);
11
$DEBUG = $ENV{DEBUG} || 0;
10
our $DEBUG = $ENV{DEBUG} || 0;
12
BEGIN { $VERSION = '3.0501'; }
15
17
# use a BEGIN block so we print our plan before CGI::FormBuilder is loaded
19
unshift @INC, "$FindBin::Bin/../lib";
19
plan tests => $numtests;
22
plan tests => $numtests + 1;
21
24
# success if we said NOTEST
22
25
if ($ENV{NOTEST}) {
407
#31 - Backbase tagname support (experiemental)
410
stylesheet => 'fbstyle.css',
411
submit => [qw(Update Delete)],
414
fields => [qw(fullname gender fav_color lover)], # need hash order
420
select => 'b:select',
422
option => 'b:option',
432
label => 'Full Name',
438
options => [qw(M F)],
439
comment => "It's one or the other",
442
label => 'Favy Colour',
443
options => [qw(Red Green Blue Orange Yellow Purple)],
444
comment => 'Choose just one, even if you have more than one',
445
invalid => 1, # tricky
448
label => 'Things you love',
449
options => [qw(Sex Drugs Rock+Roll)],
459
fieldsets => [[acct=>'Account Information'],
460
[prefs=>'User Preferences'],
461
[phone=>'Phone Number(s)']],
463
fields => [qw/first_name last_name outside_1 email home_phone new_set
464
work_phone call_me email_me outside_2 sex outside_3/],
467
first_name => { fieldset => 'acct' },
468
last_name => { fieldset => 'acct' },
469
email => { fieldset => 'acct' },
470
home_phone => { fieldset => 'phone' },
471
work_phone => { fieldset => 'phone' },
472
new_set => { fieldset => 'Inline Created' },
473
call_me => { fieldset => 'prefs' },
474
email_me => { fieldset => 'prefs' },
475
first_name => { fieldset => 'acct' },
476
sex => { fieldset => 'acct',
477
options => [qw/Yes No/] },
481
#33 - builtin Div.pm "template" support
485
fields => [qw/ticket user email part_number/],
486
fieldsets => [[acct=>'Account Information'],
487
[prefs=>'Part Information']],
490
validate => { ticket => '/^\d+$/' },
491
submit => [qw/Update Delete Cancel/],
493
template => {type => 'div'},
497
ticket => { fieldset => 'acct' },
498
email => { fieldset => 'prefs' },
502
# Older tests moved from 1b-fields
503
#34 - misc checkboxes
506
fields => [qw/name color/],
507
labels => {color => 'Favorite Color'},
508
validate => {email => 'EMAIL'},
509
required => [qw/name/],
510
sticky => 0, columns => 1,
511
action => 'TEST', title => 'TEST',
515
options => [qw(red> green& blue")],
516
multiple => 1, cleanopts => 0,
519
options => [qw(lower UPPER)], nameopts => 1,
526
# check individual fields as static
528
fields => [qw/name email color/],
533
name => { static => 1 },
534
email => { type => 'static' },
541
fields => [qw/name color hid1 hid2/],
544
values => { hid1 => 'Val1a' },
547
name => { static => 1, type => 'text' },
548
hid1 => { type => 'hidden', value => 'Val1b' }, # should replace Val1a
549
hid2 => { type => 'hidden', value => 'Val2' },
550
color => { value => 'blew', options => [qw(read blew yell)] },
551
Tummy => { value => [qw(lg xxl)], options => [qw(sm med lg xl xxl xxxl)] },