summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Fiegehenn <simbabque@cpan.org>2022-07-04 22:16:11 +0100
committerOlaf Alders <olaf@wundersolutions.com>2022-07-04 22:19:12 -0400
commit15fdf99d52e87d8382000577612076eb7d95f504 (patch)
tree5ede4c75b93a90c2b8311941f6b48785ffd3b18b
parent59336ecb014d674ba86029929c59fe88a0ad8e2d (diff)
add tests for tick() with no value
-rw-r--r--Changes3
-rw-r--r--lib/WWW/Mechanize.pm5
-rw-r--r--t/tick.html5
-rw-r--r--t/tick.t6
4 files changed, 16 insertions, 3 deletions
diff --git a/Changes b/Changes
index 4f2ef92..e3c11f6 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,9 @@
Revision history for WWW::Mechanize
{{$NEXT}}
+ [FIXED]
+ - tick() can now handle checkboxes without a value (GH#331) (Jordan M Adler
+ and Julien Fiegehenn)
2.10 2022-07-04 21:06:13Z
diff --git a/lib/WWW/Mechanize.pm b/lib/WWW/Mechanize.pm
index ee24ece..79c413a 100644
--- a/lib/WWW/Mechanize.pm
+++ b/lib/WWW/Mechanize.pm
@@ -2076,6 +2076,11 @@ as the third optional argument will cause the checkbox to be unticked.
The third value does not need to be set if you wish to merely tick the
box.
+ $mech->tick('extra', 'cheese');
+ $mech->tick('extra', 'mushrooms');
+
+ $mech->tick('no_value', ''); # <input type="checkbox" name="no_value">
+
=cut
sub tick {
diff --git a/t/tick.html b/t/tick.html
index 88256a5..27e1a16 100644
--- a/t/tick.html
+++ b/t/tick.html
@@ -4,9 +4,12 @@
<input type="checkbox" name="foo" value="hello" /> Hello<br />
<input type="checkbox" name="foo" value="bye" /> Bye<br />
-<input type="checkbox" name="foo" value="arse" /> Arse<br />
+<input type="checkbox" name="foo" value="parse" /> Parse<br />
<input type="checkbox" name="foo" value="wibble" /> Wibble<br />
<input type="checkbox" name="foo" value="foo" /> Foo<br />
+<label>
+ <input type="checkbox" name="no_value" /> I have no value
+</label>
<input type="Submit" name="submit" value="Submit" label="Submit" />
</form>
diff --git a/t/tick.t b/t/tick.t
index 2a46fd0..60df387 100644
--- a/t/tick.t
+++ b/t/tick.t
@@ -22,6 +22,8 @@ $mech->tick('foo','hello');
$mech->tick('foo','bye');
$mech->untick('foo','hello');
+$mech->tick('no_value', '');
+
my $form = $mech->form_number(1);
isa_ok( $form, 'HTML::Form' );
@@ -29,10 +31,10 @@ my $reqstring = $form->click->as_string;
my $wanted = <<'EOT';
POST http://localhost/
-Content-Length: 21
+Content-Length: 31
Content-Type: application/x-www-form-urlencoded
-foo=bye&submit=Submit
+foo=bye&no_value=&submit=Submit
EOT
is( $reqstring, $wanted, 'Proper posting' );