6 if ($ENV{NOINTERNET} ) {
7 use Test::More skip_all => "We don't have internet here";
10 use Test::More skip_all => 'Still need to get the error-handling on here working';
11 use Test::More tests => 9;
14 use_ok( 'WWW::Mechanize' );
17 # XXX We need tests in here to verify that we're asking for gzip output
19 my $mech = WWW::Mechanize->new;
20 isa_ok( $mech, 'WWW::Mechanize', 'Created object' );
21 $mech->agent_alias( 'Linux Mozilla' );
23 my $first_page = 'http://www.computers4sure.com/';
24 $mech->get( $first_page );
25 is( $mech->response->code, 200, "Fetched $first_page" );
26 ok( $mech->content =~ /Support/, 'Found a likely word in the first page' );
28 my @links = $mech->find_all_links( url_regex => qr{product\.asp\?productid=} );
29 cmp_ok( scalar @links, '>', 10, 'Should have lots of product links' );
31 my $link = $links[@links/2]; # Pick one in the middle
32 isa_ok( $link, 'WWW::Mechanize::Link' );
33 my $link_str = $link->url;
35 # The problem we're having is that the 2nd get, following a link,
37 $mech->get( $link_str );
38 is( $mech->response->code, 200, "Fetched $link_str" );
39 ok( $mech->content =~ /Your price/i, 'Found a likely phrase in the second page' );
40 #print $mech->content;
43 eval 'use Test::Memory::Cycle';
44 skip 'Test::Memory::Cycle not installed', 1 if $@;
46 memory_cycle_ok( $mech, 'No memory cycles found' );