Add the original source packages to maemo, source lenny
[dh-make-perl] / dev / i386 / libwww-mechanize-perl / libwww-mechanize-perl-1.34 / t / local / form.t
diff --git a/dev/i386/libwww-mechanize-perl/libwww-mechanize-perl-1.34/t/local/form.t b/dev/i386/libwww-mechanize-perl/libwww-mechanize-perl-1.34/t/local/form.t
new file mode 100644 (file)
index 0000000..87e8dbd
--- /dev/null
@@ -0,0 +1,35 @@
+#!perl
+
+use warnings;
+use strict;
+use Test::More tests => 11;
+
+use lib 't/local';
+use LocalServer;
+
+BEGIN {
+    delete @ENV{ grep { lc eq 'http_proxy' } keys %ENV };
+    delete @ENV{ qw( IFS CDPATH ENV BASH_ENV ) };
+    use_ok( 'WWW::Mechanize' );
+}
+
+my $server = LocalServer->spawn;
+isa_ok( $server, 'LocalServer' );
+
+my $mech = WWW::Mechanize->new();
+isa_ok( $mech, 'WWW::Mechanize' ) or die;
+$mech->quiet(1);
+$mech->get($server->url);
+ok( $mech->success, 'Got a page' ) or die 'cannot even get google';
+is( $mech->uri, $server->url, 'Got page' );
+
+my $form_number_1 = $mech->form_number(1);
+isa_ok( $form_number_1, 'HTML::Form', 'Can select the first form');
+is( $mech->current_form(), $mech->{forms}->[0], 'Set the form attribute' );
+
+ok( !$mech->form_number(99), 'cannot select the 99th form');
+is( $mech->current_form(), $mech->{forms}->[0], 'Form is still set to 1' );
+
+my $form_name_f = $mech->form_name('f');
+isa_ok( $form_name_f, 'HTML::Form', 'Can select the form' );
+ok( !$mech->form_name('bargle-snark'), 'cannot select non-existent form' );