Debian lenny version packages
[pkg-perl] / deb-src / libwww-mechanize-perl / libwww-mechanize-perl-1.34 / t / live / computers4sure.t
1 #!perl -T
2
3 use warnings;
4 use strict;
5
6 use Test::More skip_all => 'Still need to get the error-handling on here working';
7 use Test::More tests => 9;
8
9 BEGIN {
10     use_ok( 'WWW::Mechanize' );
11 }
12
13 # XXX We need tests in here to verify that we're asking for gzip output
14
15 my $mech = WWW::Mechanize->new;
16 isa_ok( $mech, 'WWW::Mechanize', 'Created object' );
17 $mech->agent_alias( 'Linux Mozilla' );
18
19 my $first_page = 'http://www.computers4sure.com/';
20 $mech->get( $first_page );
21 is( $mech->response->code, 200, "Fetched $first_page" );
22 ok( $mech->content =~ /Support/, 'Found a likely word in the first page' );
23
24 my @links = $mech->find_all_links( url_regex => qr{product\.asp\?productid=} );
25 cmp_ok( scalar @links, '>', 10, 'Should have lots of product links' );
26
27 my $link = $links[@links/2]; # Pick one in the middle
28 isa_ok( $link, 'WWW::Mechanize::Link' );
29 my $link_str = $link->url;
30
31 # The problem we're having is that the 2nd get, following a link,
32 # comes back gzipped.
33 $mech->get( $link_str );
34 is( $mech->response->code, 200, "Fetched $link_str" );
35 ok( $mech->content =~ /Your price/i, 'Found a likely phrase in the second page' );
36 #print $mech->content;
37
38 SKIP: {
39     eval 'use Test::Memory::Cycle';
40     skip 'Test::Memory::Cycle not installed', 1 if $@;
41
42     memory_cycle_ok( $mech, 'No memory cycles found' );
43 }
44