Skip to content

Commit efb47de

Browse files
committed
add tests for tick() with no value
1 parent 032dd6e commit efb47de

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

Changes

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
Revision history for WWW::Mechanize
22

33
{{$NEXT}}
4+
[FIXED]
5+
- tick() can now handle checkboxes without a value (GH#331) (Jordan M Adler
6+
and Julien Fiegehenn)
47

58
[DOCUMENTATION]
69
- Explain that file URIs need url encoding (GH#329) (Julien Fiegehenn and

lib/WWW/Mechanize.pm

+5
Original file line numberDiff line numberDiff line change
@@ -2043,6 +2043,11 @@ as the third optional argument will cause the checkbox to be unticked.
20432043
The third value does not need to be set if you wish to merely tick the
20442044
box.
20452045
2046+
$mech->tick('extra', 'cheese');
2047+
$mech->tick('extra', 'mushrooms');
2048+
2049+
$mech->tick('no_value', ''); # <input type="checkbox" name="no_value">
2050+
20462051
=cut
20472052

20482053
sub tick {

t/tick.html

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44

55
<input type="checkbox" name="foo" value="hello" /> Hello<br />
66
<input type="checkbox" name="foo" value="bye" /> Bye<br />
7-
<input type="checkbox" name="foo" value="arse" /> Arse<br />
7+
<input type="checkbox" name="foo" value="parse" /> Parse<br />
88
<input type="checkbox" name="foo" value="wibble" /> Wibble<br />
99
<input type="checkbox" name="foo" value="foo" /> Foo<br />
10+
<label>
11+
<input type="checkbox" name="no_value" /> I have no value
12+
</label>
1013

1114
<input type="Submit" name="submit" value="Submit" label="Submit" />
1215
</form>

t/tick.t

+4-2
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,19 @@ $mech->tick('foo','hello');
2222
$mech->tick('foo','bye');
2323
$mech->untick('foo','hello');
2424

25+
$mech->tick('no_value', '');
26+
2527
my $form = $mech->form_number(1);
2628
isa_ok( $form, 'HTML::Form' );
2729

2830
my $reqstring = $form->click->as_string;
2931

3032
my $wanted = <<'EOT';
3133
POST http://localhost/
32-
Content-Length: 21
34+
Content-Length: 31
3335
Content-Type: application/x-www-form-urlencoded
3436
35-
foo=bye&submit=Submit
37+
foo=bye&no_value=&submit=Submit
3638
EOT
3739

3840
is( $reqstring, $wanted, 'Proper posting' );

0 commit comments

Comments
 (0)