]> Dogcows Code - chaz/p5-CGI-Ex/blob - t/2_fill_03_checkbox.t
CGI::Ex 2.00
[chaz/p5-CGI-Ex] / t / 2_fill_03_checkbox.t
1 # -*- Mode: Perl; -*-
2
3 =head1 NAME
4
5 2_fill_03_checkbox.t - Test CGI::Ex::Fill's ability to fill checkboxes fields
6
7 =cut
8
9 use Test::More tests => 2;
10 use strict;
11
12 use_ok('CGI::Ex::Fill');
13
14 my $hidden_form_in = qq{<input type="checkbox" name="foo1" value="bar1">
15 <input type="checkbox" name="foo1" value="bar2">
16 <input type="checkbox" name="foo1" value="bar3">
17 <input type="checkbox" name="foo2" value="bar1">
18 <input type="checkbox" name="foo2" value="bar2">
19 <input type="checkbox" name="foo2" value="bar3">
20 <input type="checkbox" name="foo3" value="bar1">
21 <input type="checkbox" name="foo3" checked value="bar2">
22 <input type="checkbox" name="foo3" value="bar3">
23 <input type="checkbox" name="foo4" value="bar1">
24 <input type="checkbox" name="foo4" checked value="bar2">
25 <input type="checkbox" name="foo4" value="bar3">
26 <input type="checkbox" name="foo5">
27 <input type="checkbox" name="foo6">
28 <input type="checkbox" name="foo7" checked>
29 <input type="checkbox" name="foo8" checked>};
30
31 my %fdat = (foo1 => 'bar1',
32 foo2 => ['bar1', 'bar2',],
33 foo3 => '',
34 foo5 => 'on',
35 foo6 => '',
36 foo7 => 'on',
37 foo8 => '');
38
39 my $output = CGI::Ex::Fill::form_fill($hidden_form_in,
40 \%fdat);
41
42 my $is_checked = join(" ",map { m/checked/i ? "yes" : "no" } split ("\n",$output));
43
44 ok($is_checked eq "yes no no yes yes no no no no no yes no yes no yes no",
45 "Checkboxes should match ($is_checked)");
46
This page took 0.032371 seconds and 4 git commands to generate.