f3416610209afbc4b18239bb5311f870d60c8226
[dh-make-perl] / dev / i386 / libwww-mechanize-perl / libwww-mechanize-perl-1.34 / t / local / submit.t
1 #!perl -w
2
3 use warnings;
4 use strict;
5 use lib 't/local';
6 use Test::More tests => 13;
7 use LocalServer;
8
9 BEGIN {
10     delete @ENV{ grep { lc eq 'http_proxy' } keys %ENV };
11     delete @ENV{ qw( IFS CDPATH ENV BASH_ENV ) };
12     use_ok( 'WWW::Mechanize' );
13 }
14
15 my $server = LocalServer->spawn;
16 isa_ok( $server, 'LocalServer' );
17
18 my $mech = WWW::Mechanize->new();
19 isa_ok( $mech, 'WWW::Mechanize', 'Created the object' ) or die;
20
21 my $response = $mech->get( $server->url );
22 isa_ok( $response, 'HTTP::Response', 'Got back a response' ) or die;
23 is( $mech->uri, $server->url, "Got the correct page" );
24 ok( $response->is_success, 'Got local page' ) or die 'cannot even fetch local page';
25 ok( $mech->is_html, 'is HTML' );
26
27 is( $mech->value('upload'), '', 'Hopefully no upload happens');
28
29 $mech->field(query => 'foo'); # Filled the 'q' field
30
31 $response = $mech->submit;
32 isa_ok( $response, 'HTTP::Response', 'Got back a response' );
33 ok( $response->is_success, 'Can click "submit" ("submit" button)');
34
35 like($mech->content, qr/\bfoo\b/i, 'Found "Foo"');
36
37 is( $mech->value('upload'), '', 'No upload happens' );
38
39 SKIP: {
40     eval 'use Test::Memory::Cycle';
41     skip 'Test::Memory::Cycle not installed', 1 if $@;
42
43     memory_cycle_ok( $mech, 'Mech: no cycles' );
44 }