X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=t%2F2_fill_04_select.t;h=fcb3b2a4d9d1e038c0cc391a9fbade5b68af2413;hb=refs%2Ftags%2Fv2.00;hp=1b8f1d4a371416f851de1c04bca3d2cbec475d9f;hpb=85070b46d0a93ddbeef07341421adb8389a55418;p=chaz%2Fp5-CGI-Ex diff --git a/t/2_fill_04_select.t b/t/2_fill_04_select.t index 1b8f1d4..fcb3b2a 100644 --- a/t/2_fill_04_select.t +++ b/t/2_fill_04_select.t @@ -1,15 +1,15 @@ # -*- Mode: Perl; -*- -use strict; +=head1 NAME -$^W = 1; +2_fill_04_select.t - Test CGI::Ex::Fill's ability to fill select fields -print "1..5\n"; +=cut -use CGI::Ex; -use CGI; +use strict; +use Test::More tests => 5; -print "ok 1\n"; +use_ok('CGI::Ex::Fill'); my $hidden_form_in = qq{ }; -my $q = new CGI( { foo1 => '0', - foo2 => ['bar1', 'bar2',], - foo3 => '' } - ); +my $q = { + foo1 => '0', + foo2 => ['bar1', 'bar2',], + foo3 => '', +}; -my $fif = new CGI::Ex; -my $output = $fif->fill(scalarref => \$hidden_form_in, - fobject => $q); +my $output = CGI::Ex::Fill::form_fill($hidden_form_in, + $q); my $is_selected = join(" ",map { m/selected/ ? "yes" : "no" } grep /option/, split ("\n",$output)); -if ($is_selected eq "yes no no yes yes no no no no no yes no"){ - print "ok 2\n"; -} else { - print "Got unexpected is_seleced for select menus:\n$is_selected\n$output\n"; - print "not ok 2\n"; -} +ok($is_selected eq "yes no no yes yes no no no no no yes no", + "Selected should match ($is_selected)"); + $hidden_form_in = qq{ }; -$q = new CGI( { foo1 => 'bar1', - foo2 => ['bar1', 'bar2',], - foo3 => '' } - ); +$q = { + foo1 => 'bar1', + foo2 => ['bar1', 'bar2',], + foo3 => '', +}; -$fif = new CGI::Ex; -$output = $fif->fill(scalarref => \$hidden_form_in, - fobject => $q); +$output = CGI::Ex::Fill::form_fill($hidden_form_in, + $q); $is_selected = join(" ",map { m/selected/ ? "yes" : "no" } grep /option/, split ("\n",$output)); -if ($is_selected eq "yes no no yes yes no no no no no yes no"){ - print "ok 3\n"; -} else { - print "Got unexpected is_seleced for select menus:\n$is_selected\n$output\n"; - print "not ok 3\n"; -} +ok($is_selected eq "yes no no yes yes no no no no no yes no", + "Selected should match ($is_selected)"); # test empty option tag $hidden_form_in = qq{}; -$fif = new CGI::Ex; -$output = $fif->fill(scalarref => \$hidden_form_in, - fobject => $q); -if ($output eq qq{}){ - print "ok 4\n"; -} else { - print "Got unexpected output for empty option:\n$output\n"; - print "not ok 4\n"; -} + +$output = CGI::Ex::Fill::form_fill($hidden_form_in, + $q); +ok($output eq qq{}, + "Should match ($output)"); $hidden_form_in = qq{}; -$fif = new CGI::Ex; -$output = $fif->fill(scalarref => \$hidden_form_in, - fobject => $q); -if ($output =~ m!^$!){ - print "ok 5\n"; -} else { - print "Got unexpected output for empty option:\n$output\n"; - print "not ok 5\n"; -} +$output = CGI::Ex::Fill::form_fill($hidden_form_in, + $q); +ok($output =~ m!^$!, + "Should match ($output)");