use strict; use Test::More tests => 16; use vars qw( $display $captured_html ); { package HTML::Display::Capture; use parent 'HTML::Display::Common'; sub display_html { $::captured_html = $_[1]; }; }; sub display_ok { my ($html,$base,$expected,$name) = @_; undef $captured_html; $display->display( html => $html, location => $base); is($captured_html,$expected,$name); }; SKIP: { use_ok("HTML::Display"); $display = HTML::Display->new(); isa_ok($display,"HTML::Display::Common","Default class"); $display = HTML::Display->new( class => 'HTML::Display::Capture' ); isa_ok($display,"HTML::Display::Common"); # Now check our published API : for my $meth (qw( display )) { can_ok($display,$meth); }; # Now check the handling of base tags : display_ok("

","http://example.com",'

',"Empty head"); display_ok("

","http://example.com",'

',"Empty head without trailing slash"); display_ok('

',"http://example.com",'

',"Existing head"); display_ok('

',"http://example.com",'

',"Existing head"); display_ok('

',"http://example.com/file.html",'

',"Existing head 2"); display_ok('

',"http://example.com/file.html",'

',"Filename in base"); display_ok('

',"http://example.com:666/file.html",'

',"Port"); display_ok('

','http://super:secret@example.com/file.html','

',"Basic authentification"); display_ok('

','http://example.com/','

',"'target' attribute"); display_ok('

','http://example.com/','

',"No tag"); display_ok('foo

','http://example.com/','foo

',"No tag"); display_ok('

','http://example.com/','

',"Single tag"); };