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
1 #!perl
2
3 use warnings;
4 use strict;
5 use Test::More tests => 11;
6
7 use lib 't/local';
8 use LocalServer;
9
10 BEGIN {
11     delete @ENV{ grep { lc eq 'http_proxy' } keys %ENV };
12     delete @ENV{ qw( IFS CDPATH ENV BASH_ENV ) };
13     use_ok( 'WWW::Mechanize' );
14 }
15
16 my $server = LocalServer->spawn;
17 isa_ok( $server, 'LocalServer' );
18
19 my $mech = WWW::Mechanize->new();
20 isa_ok( $mech, 'WWW::Mechanize' ) or die;
21 $mech->quiet(1);
22 $mech->get($server->url);
23 ok( $mech->success, 'Got a page' ) or die 'cannot even get google';
24 is( $mech->uri, $server->url, 'Got page' );
25
26 my $form_number_1 = $mech->form_number(1);
27 isa_ok( $form_number_1, 'HTML::Form', 'Can select the first form');
28 is( $mech->current_form(), $mech->{forms}->[0], 'Set the form attribute' );
29
30 ok( !$mech->form_number(99), 'cannot select the 99th form');
31 is( $mech->current_form(), $mech->{forms}->[0], 'Form is still set to 1' );
32
33 my $form_name_f = $mech->form_name('f');
34 isa_ok( $form_name_f, 'HTML::Form', 'Can select the form' );
35 ok( !$mech->form_name('bargle-snark'), 'cannot select non-existent form' );