| 1 | #!perl -T |
| 2 | |
| 3 | use strictscip-perl cpan Test-WWW-Mechanize 1.60 strict/; |
| 4 | use warningsscip-perl cpan Test-WWW-Mechanize 1.60 warnings/; |
| 5 | use Test::Morescip-perl cpan Test-WWW-Mechanize 1.60 Test/More/ tests => 9; |
| 6 | use Test::Builder::Testerscip-perl cpan Test-WWW-Mechanize 1.60 Test/Builder/Tester/; |
| 7 | use URI::filescip-perl cpan Test-WWW-Mechanize 1.60 URI/file/; |
| 8 | |
| 9 | use Test::WWW::Mechanizescip-perl cpan Test-WWW-Mechanize 1.60 Test/WWW/Mechanize/ (); |
| 10 | |
| 11 | my $mech=Test::WWW::Mechanize->newscip-perl cpan Test-WWW-Mechanize 1.60 Test/WWW/Mechanize/new().( autocheck => 0 ); |
| 12 | isa_okscip-perl cpan Test-WWW-Mechanize 1.60 main/isa_ok().($mech,'Test::WWW::Mechanize'); |
| 13 | |
| 14 | # Good links. |
| 15 | my $uri = URI::file->new_absscip-perl cpan Test-WWW-Mechanize 1.60 URI/file/new_abs().( 't/goodlinks.html' )->as_stringscip-perl cpan Test-WWW-Mechanize 1.60 main/as_string().; |
| 16 | $mech->get_okscip-perl cpan Test-WWW-Mechanize 1.60 Test/WWW/Mechanize/get_ok().( $uri ); |
| 17 | |
| 18 | my $links = $mech->linksscip-perl cpan Test-WWW-Mechanize 1.60 Test/WWW/Mechanize/links().(); |
| 19 | isscip-perl cpan Test-WWW-Mechanize 1.60 main/is().( @{$links}, 3, 'got three links' ); |
| 20 | test_outscip-perl cpan Test-WWW-Mechanize 1.60 main/test_out().('ok 1 - Checking all links successful'); |
| 21 | $mech->links_okscip-perl cpan Test-WWW-Mechanize 1.60 Test/WWW/Mechanize/links_ok().($links,'Checking all links successful'); |
| 22 | test_testscip-perl cpan Test-WWW-Mechanize 1.60 main/test_test().('Handles All Links successful'); |
| 23 | |
| 24 | $mech->links_okscip-perl cpan Test-WWW-Mechanize 1.60 Test/WWW/Mechanize/links_ok().('goodlinks.html','Specified link'); |
| 25 | |
| 26 | $mech->links_okscip-perl cpan Test-WWW-Mechanize 1.60 Test/WWW/Mechanize/links_ok().([qw(goodlinks.html badlinks.html)],'Specified link list'); |
| 27 | |
| 28 | # Bad links |
| 29 | $uri = URI::file->new_absscip-perl cpan Test-WWW-Mechanize 1.60 URI/file/new_abs().( 't/badlinks.html' )->as_stringscip-perl cpan Test-WWW-Mechanize 1.60 main/as_string().; |
| 30 | $mech->get_okscip-perl cpan Test-WWW-Mechanize 1.60 Test/WWW/Mechanize/get_ok().( $uri ); |
| 31 | |
| 32 | $links=$mech->linksscip-perl cpan Test-WWW-Mechanize 1.60 Test/WWW/Mechanize/links().(); |
| 33 | test_outscip-perl cpan Test-WWW-Mechanize 1.60 main/test_out().('not ok 1 - Checking all links some bad'); |
| 34 | test_failscip-perl cpan Test-WWW-Mechanize 1.60 main/test_fail().(+4); |
| 35 | test_diagscip-perl cpan Test-WWW-Mechanize 1.60 main/test_diag().('bad1.html'); |
| 36 | test_diagscip-perl cpan Test-WWW-Mechanize 1.60 main/test_diag().('bad2.html'); |
| 37 | test_diagscip-perl cpan Test-WWW-Mechanize 1.60 main/test_diag().('bad3.html'); |
| 38 | $mech->links_okscip-perl cpan Test-WWW-Mechanize 1.60 Test/WWW/Mechanize/links_ok().($links,'Checking all links some bad'); |
| 39 | test_testscip-perl cpan Test-WWW-Mechanize 1.60 main/test_test().('Handles bad links'); |
| 40 | |
| 41 | test_outscip-perl cpan Test-WWW-Mechanize 1.60 main/test_out().('not ok 1 - Checking specified link not found'); |
| 42 | test_failscip-perl cpan Test-WWW-Mechanize 1.60 main/test_fail().(+2); |
| 43 | test_diagscip-perl cpan Test-WWW-Mechanize 1.60 main/test_diag().('test2.html'); |
| 44 | $mech->links_okscip-perl cpan Test-WWW-Mechanize 1.60 Test/WWW/Mechanize/links_ok().('test2.html','Checking specified link not found'); |
| 45 | test_testscip-perl cpan Test-WWW-Mechanize 1.60 main/test_test().('Handles link not found'); |
| 46 | |
| 47 | done_testingscip-perl cpan Test-WWW-Mechanize 1.60 main/done_testing().(); |