# $Id$ use Test::More; BEGIN { my $num_tests = 3; if ( $ENV{ 'TEST_AUTHOR' } ) { $num_tests = 4; } # XML::XPath must be installed in order to get detailed errors plan tests => $num_tests; SKIP: { skip "no Test::Without::Module", $num_tests, if -f 't/SKIPWITHOUT'; require Test::Without::Module; import Test::Without::Module qw( XML::XPath ); use WebService::Validator::HTML::W3C; my $v = WebService::Validator::HTML::W3C->new( http_timeout => 10, detailed => 1, ); ok($v, 'object created'); if ( $ENV{ 'TEST_AUTHOR' } ) { my $r = $v->validate('http://exo.org.uk/code/www-w3c-validator/invalid.html'); unless ($r) { if ($v->validator_error eq "Could not contact validator") { skip "failed to contact validator", 5; } } ok ($r, 'page validated'); } else { $v->num_errors( 1 ); $v->_content( qq{ http://exo.org.uk/code/www-w3c-validator/invalid.html Sat Oct 4 14:53:18 2003 Apache/1.3.28 (Unix) (Red-Hat/Linux) mod_ssl/2.8.15 OpenSSL/0.9.7a PHP/4.0.6 mod_perl/1.26 FrontPage/4.0.4.3 256 utf-8 -//W3C//DTD XHTML 1.0 Strict//EN <em>Note</em>: The Validator XML support has <a href="http://openjade.sf.net/doc/xml.htm" title="Limitations in Validator XML support">some limitations</a>. This interface is highly experimental and the output *will* change -- probably even several times -- before finished. Do *not* rely on it! See http://validator.w3.org:8001/docs/users.html#api-warning end tag for "div" omitted, but OMITTAG NO was specified start tag was here } ); } { my $warning = ''; local $SIG{__WARN__} = sub { $warning = shift; $warning =~ s/ at .*\n$//; }; $v->errors(); is $warning, "XML::XPath must be installed in order to get detailed errors", "missing XML::XPath error"; ok(!$v->errors(), 'no errors returned if no XML::XPath'); } } }