X-Git-Url: http://git.maemo.org/git/?p=dh-make-perl;a=blobdiff_plain;f=dev%2Fi386%2Flibwww-mechanize-perl%2Flibwww-mechanize-perl-1.34%2Ft%2Flocal%2Ffailure.t;fp=dev%2Fi386%2Flibwww-mechanize-perl%2Flibwww-mechanize-perl-1.34%2Ft%2Flocal%2Ffailure.t;h=efbe774803cf7783fa4a9ebaf6602322968476e2;hp=0000000000000000000000000000000000000000;hb=8977e561d8a9eae6959218b0306c9df2056a38a9;hpb=df794b845212301ea0d267c919232538bfef356a diff --git a/dev/i386/libwww-mechanize-perl/libwww-mechanize-perl-1.34/t/local/failure.t b/dev/i386/libwww-mechanize-perl/libwww-mechanize-perl-1.34/t/local/failure.t new file mode 100644 index 0000000..efbe774 --- /dev/null +++ b/dev/i386/libwww-mechanize-perl/libwww-mechanize-perl-1.34/t/local/failure.t @@ -0,0 +1,58 @@ +#!perl + +use warnings; +use strict; +use Test::More; + +use lib 't/local'; +use LocalServer; + +BEGIN { + if (gethostbyname('blahblahblah.xx-only-testing.')) { + plan skip_all => 'Found an A record for the non-existent domain'; + } + plan tests => 16; +} + +BEGIN { + delete @ENV{ grep { lc eq 'http_proxy' } keys %ENV }; + delete @ENV{ qw( IFS CDPATH ENV BASH_ENV ) }; + use_ok( 'WWW::Mechanize' ); +} + +my $server = LocalServer->spawn; +isa_ok( $server, 'LocalServer' ); + + +my $mech = WWW::Mechanize->new; +isa_ok( $mech, 'WWW::Mechanize', 'Created object' ); + +GOOD_PAGE: { + my $response = $mech->get($server->url); + isa_ok( $response, 'HTTP::Response' ); + ok( $response->is_success, 'Success' ); + ok( $mech->success, 'Get webpage' ); + ok( $mech->is_html, 'It\'s HTML' ); + is( $mech->title, 'WWW::Mechanize::Shell test page', 'Correct title' ); + + my @links = $mech->links; + is( scalar @links, 10, '10 links, please' ); + my @forms = $mech->forms; + is( scalar @forms, 1, 'One form' ); + isa_ok( $forms[0], 'HTML::Form' ); +} + +BAD_PAGE: { + my $badurl = "http://blahblahblah.xx-only-testing."; + $mech->get( $badurl ); + + ok( !$mech->success, 'Failed the fetch' ); + ok( !$mech->is_html, "Isn't HTML" ); + ok( !defined $mech->title, "No title" ); + + my @links = $mech->links; + is( scalar @links, 0, "No links" ); + + my @forms = $mech->forms; + is( scalar @forms, 0, "No forms" ); +}