or tag'
);
$x = $mech->find_link( text => 'Rebuild Index' );
isa_ok( $x, 'WWW::Mechanize::Link' );
is_deeply(
[ @{$x}[ 0 .. 3 ] ],
[ '/cgi-bin/MT/mt.cgi', 'Rebuild Index', undef, 'a' ],
'Got the JavaScript link'
);
$x = $mech->find_link( url => 'blongo.html' );
isa_ok( $x, 'WWW::Mechanize::Link' );
$x = $mech->find_link( url_abs => 'blongo.html' );
ok( !defined $x, 'No match' );
$x = $mech->find_link( url_abs_regex => qr[t/blongo\.html$] );
isa_ok( $x, 'WWW::Mechanize::Link' );
$x = $mech->find_link( text_regex => qr/click/i );
isa_ok( $x, 'WWW::Mechanize::Link' );
is( $x->[0], 'http://www.yahoo.com/', 'Got js url link' );
is( $x->url, 'http://www.yahoo.com/', 'Got js url link' );
$x = $mech->find_link( rel => 'icon' );
isa_ok( $x, 'WWW::Mechanize::Link' );
is( $x->[0], 'foo.png', 'Got icon url link' );
$x = $mech->find_link( rel_regex => qr/sheet/i );
isa_ok( $x, 'WWW::Mechanize::Link' );
is( $x->[0], 'styles.css', 'Got stylesheet url link' );
$mech->get( URI::file->new_abs('t/refresh.html') );
my $link = $mech->find_link( tag => 'meta' );
is(
$link->url, 'http://www.mysite.com/',
'got link from meta tag via tag search'
);
done_testing();
frames.html 100644 001750 001750 570 15076225326 15530 0 ustar 00olaf olaf 000000 000000 WWW-Mechanize-2.20/t
google.html 100644 001750 001750 5470 15076225326 15553 0 ustar 00olaf olaf 000000 000000 WWW-Mechanize-2.20/t Google
Want more from Google? Try these expert search tips
Advertise with Us - Business Solutions - Services & Tools - Jobs, Press, & Help
©2003 Google - Searching 3,083,324,652 web pages
image-new.t 100644 001750 001750 3101 15076225326 15434 0 ustar 00olaf olaf 000000 000000 WWW-Mechanize-2.20/t #!perl
use warnings;
use strict;
use Test::More tests => 15;
BEGIN {
use_ok('WWW::Mechanize::Image');
}
# test new style API
my $img = WWW::Mechanize::Image->new(
{
url => 'url.html',
base => 'http://base.example.com/',
name => 'name',
alt => 'alt',
tag => 'a',
height => 2112,
width => 5150,
attrs => { id => 'id', class => 'foo bar' },
}
);
is( $img->url, 'url.html', 'url() works' );
is( $img->base, 'http://base.example.com/', 'base() works' );
is( $img->name, 'name', 'name() works' );
is( $img->alt, 'alt', 'alt() works' );
is( $img->tag, 'a', 'tag() works' );
is( $img->height, 2112, 'height works' );
is( $img->width, 5150, 'width works' );
is( $img->attrs->{id}, 'id', 'attrs/id works' );
is( $img->attrs->{class}, 'foo bar', 'attrs/class works' );
is( $img->url_abs, 'http://base.example.com/url.html', 'url_abs works' );
isa_ok( $img->URI, 'URI::URL', 'Returns an object' );
my $img_no_src = WWW::Mechanize::Image->new(
{
url => undef,
base => 'http://base.example.com/',
tag => 'img',
height => 123,
width => 321,
}
);
isa_ok( $img_no_src, 'WWW::Mechanize::Image' );
is( $img_no_src->url, undef, 'url() without url is undef' );
isa_ok( $img_no_src->URI, 'URI::URL', 'Returns an object' );
link-base.t 100644 001750 001750 735 15076225326 15422 0 ustar 00olaf olaf 000000 000000 WWW-Mechanize-2.20/t #!perl
use warnings;
use strict;
use Test::More tests => 5;
BEGIN {
use_ok('WWW::Mechanize::Link');
}
NO_BASE: {
my $link
= WWW::Mechanize::Link->new( 'url.html', 'Click here', undef, undef );
isa_ok( $link, 'WWW::Mechanize::Link', 'constructor OK' );
my $URI = $link->URI;
isa_ok( $URI, 'URI::URL', 'URI is proper type' );
is( $URI->rel, 'url.html', 'Short form of the url' );
is( $link->url_abs, 'url.html', 'url_abs works' );
}
local 000755 001750 001750 0 15076225326 14335 5 ustar 00olaf olaf 000000 000000 WWW-Mechanize-2.20/t get.t 100644 001750 001750 5022 15076225326 15440 0 ustar 00olaf olaf 000000 000000 WWW-Mechanize-2.20/t/local use warnings;
use strict;
use Test::More tests => 34;
use lib qw( t/local );
use LocalServer ();
use Test::Memory::Cycle;
BEGIN {
delete @ENV{qw( IFS CDPATH ENV BASH_ENV )};
use_ok('WWW::Mechanize');
}
my $server = LocalServer->spawn;
isa_ok( $server, 'LocalServer' );
my $agent = WWW::Mechanize->new;
isa_ok( $agent, 'WWW::Mechanize', 'Created object' );
my $response = $agent->get( $server->url );
isa_ok( $response, 'HTTP::Response' );
isa_ok( $agent->response, 'HTTP::Response' );
ok( $response->is_success, 'Page read OK' );
ok( $agent->success, "Get webpage" );
is( $agent->ct, "text/html", "Got the content-type..." );
ok( $agent->is_html, "... and the is_html wrapper" );
is( $agent->title, 'WWW::Mechanize test page', 'Titles match' );
$agent->get('/foo/');
ok( $agent->success, 'Got the /foo' );
is( $agent->uri, sprintf( '%sfoo/', $server->url ), 'Got relative OK' );
ok( $agent->is_html, 'Got HTML back' );
is( $agent->title, 'WWW::Mechanize test page', 'Got the right page' );
$agent->get('../bar/');
ok( $agent->success, 'Got the /bar page' );
is( $agent->uri, sprintf( '%sbar/', $server->url ), 'Got relative OK' );
ok( $agent->is_html, 'is HTML' );
is( $agent->title, 'WWW::Mechanize test page', 'Got the right page' );
$agent->get('basics.html');
ok( $agent->success, 'Got the basics page' );
is(
$agent->uri, sprintf( '%sbar/basics.html', $server->url ),
'Got relative OK'
);
ok( $agent->is_html, 'is HTML' );
is( $agent->title, 'WWW::Mechanize test page', 'Title matches' );
like( $agent->content, qr/WWW::Mechanize test page/, 'Got the right page' );
$agent->get('./refinesearch.html');
ok( $agent->success, 'Got the "refine search" page' );
is(
$agent->uri, sprintf( '%sbar/refinesearch.html', $server->url ),
'Got relative OK'
);
ok( $agent->is_html, 'is HTML' );
is( $agent->title, 'WWW::Mechanize test page', 'Title matches' );
like( $agent->content, qr/WWW::Mechanize test page/, 'Got the right page' );
my $rslength = do { use bytes; length $agent->content };
my $tempfile = './temp';
unlink $tempfile;
ok( !-e $tempfile, 'tempfile not there right now' );
$agent->get( './refinesearch.html', ':content_file' => $tempfile );
ok( -e $tempfile, 'File exists' );
is( -s $tempfile, $rslength, 'Did all the bytes get saved?' );
unlink $tempfile;
memory_cycle_ok( $agent, 'Mech: no cycles' );
$agent->get('/foo/');
ok( !$agent->redirects, 'redirects is false before we have a redirect' );
$agent->get( $server->redirect('/foo/') );
is( scalar $agent->redirects, 1, 'redirects picks up a redirect' );
select.html 100644 001750 001750 1235 15076225326 15551 0 ustar 00olaf olaf 000000 000000 WWW-Mechanize-2.20/t
Like a hole