Add ARM files
[dh-make-perl] / dev / arm / libwww-mechanize-perl / libwww-mechanize-perl-1.34 / t / live / computers4sure.t
1 #!perl -T
2
3 use warnings;
4 use strict;
5
6 if ($ENV{NOINTERNET} ) {
7    use Test::More skip_all => "We don't have internet here";
8 }
9
10 use Test::More skip_all => 'Still need to get the error-handling on here working';
11 use Test::More tests => 9;
12
13 BEGIN {
14     use_ok( 'WWW::Mechanize' );
15 }
16
17 # XXX We need tests in here to verify that we're asking for gzip output
18
19 my $mech = WWW::Mechanize->new;
20 isa_ok( $mech, 'WWW::Mechanize', 'Created object' );
21 $mech->agent_alias( 'Linux Mozilla' );
22
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' );
27
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' );
30
31 my $link = $links[@links/2]; # Pick one in the middle
32 isa_ok( $link, 'WWW::Mechanize::Link' );
33 my $link_str = $link->url;
34
35 # The problem we're having is that the 2nd get, following a link,
36 # comes back gzipped.
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;
41
42 SKIP: {
43     eval 'use Test::Memory::Cycle';
44     skip 'Test::Memory::Cycle not installed', 1 if $@;
45
46     memory_cycle_ok( $mech, 'No memory cycles found' );
47 }
48