Test-HTML-W3C-0.04/0000755000175000017500000000000011623635776013126 5ustar victorvictorTest-HTML-W3C-0.04/t/0000755000175000017500000000000011623635776013371 5ustar victorvictorTest-HTML-W3C-0.04/t/99-pod-coverage.t0000755000175000017500000000045211623635576016372 0ustar victorvictor#!/usr/bin/perl use strict; use Test::More; eval "use Test::Pod::Coverage 1.00"; plan skip_all => "Test::Pod::Coverage 1.00 required for testing POD coverage" if $@; plan tests=>1; pod_coverage_ok( "Test::HTML::W3C", { also_private => [ qr/^import.+$/ ], }, "Test::HTML::W3C pod coverage", ); Test-HTML-W3C-0.04/t/98-pod.t0000755000175000017500000000045011623635421014563 0ustar victorvictor#!/usr/bin/perl # $Id: 97-pod.t 7575 2006-02-23 00:19:02Z vfelix $ use strict; use Test::More; use FindBin qw($Bin); eval "use Test::Pod 1.20"; plan skip_all => "Test::Pod 1.20 required for testing POD $@" if $@; my @poddirs = ( "$Bin/../lib" ); all_pod_files_ok( all_pod_files( @poddirs ) ); Test-HTML-W3C-0.04/lib/0000755000175000017500000000000011623635776013674 5ustar victorvictorTest-HTML-W3C-0.04/lib/Test/0000755000175000017500000000000011623635776014613 5ustar victorvictorTest-HTML-W3C-0.04/lib/Test/HTML/0000755000175000017500000000000011623635776015357 5ustar victorvictorTest-HTML-W3C-0.04/lib/Test/HTML/W3C.pm0000644000175000017500000001442611623635344016307 0ustar victorvictorpackage Test::HTML::W3C; use strict; use vars qw($VERSION @EXPORT); $VERSION = "0.04"; =head1 NAME Test::HTML::W3C - Perform W3C HTML validation testing =head1 SYNOPSIS use Test::HTML::W3C tests => $test_count; # or use Test::HTML::W3C 'show_detail'; # or when using both use Test::HTML::W3C tests => $test_count, 'show_detail'; is_valid_markup($my_html_scalar); is_valid_file("/path/to/my/file.html"); is_valid("http://example.com"); # Get the underlying WebService:;Validator::W3C::HTML object my $validator = validator(); =head1 DESCRIPTION The purpose of this module is to provide a wrapper around the W3C that works with the L testing framework. =head1 ABUSE Please keep in mind that the W3C validation pages and services are a shared resource. If you plan to do many many tests, please consider using your own installation of the validation programs, and then use your local install by modifying the local validtor: my $v = validator(); $v->validator_uri($my_own_validator); See the documentation for WebService:;Validator::W3C::HTML and the W3C's site at http://validator.w3.org/ for details =over 4 =cut use WebService::Validator::HTML::W3C; use base qw(Test::Builder::Module); @EXPORT = qw( plan diag_html is_valid_markup is_valid_file is_valid validator ); my $v = WebService::Validator::HTML::W3C->new(); my $not_checked = 1; my $show_detail = 0; sub import_extra { my ($class, $list) = @_; my @other = (); my $idx = 0; while( $idx <= $#{$list} ) { my $item = $list->[$idx]; if( defined $item and $item eq 'show_detail' ) { $show_detail = 1; $v = WebService::Validator::HTML::W3C->new(detailed => 1); } else { push @other, $item; } $idx++; } @$list = @other; } =item validator(); B Returns the underlying WebService::Validator::HTML::W3C object B None. B $validator =cut sub validator { return $v; } =item plan(); B Access to the underlying C method provided by L. B As per L =cut sub plan { __PACKAGE__->builder->plan(@_); } sub _check_plan { $not_checked = 0; if (! __PACKAGE__->builder->has_plan()) { plan("no_plan"); } } =item is_valid_markup($markup[, $name]); B is_valid_markup tests whether the text in the provided scalar value correctly validates according to the W3C specifications. This is useful if you have markup stored in a scalar that you wish to test that you might get from using LWP or WWW::Mechanize for example... B $markup, a scalar containing the data to test, $name, an optional descriptive test name. B None. =cut sub is_valid_markup { _check_plan() if $not_checked; my ($markup, $message) = @_; if ($v->validate_markup($markup)) { _result($v, $message); } else { _validator_err($v, "markup"); } } =item is_valid_file($path[, $name]); B is_valid_file works the same way as is_valid_markup, except that you can specify the text to validate with the path to a filename. This is useful if you have pregenerated all your HTML files locally, and now wish to test them. B $path, a scalar, $name, an optional descriptive test name. B None. =cut sub is_valid_file { my ($file, $message) = @_; _check_plan() if $not_checked; if ($v->validate_file($file)) { _result($v, $message); } else { _validator_err($v, "file"); } } =item is_valid($url[, $name]); B is_valid, again, works very similarly to the is_valid_file and is_valid_file, except you specify a document that is already online with its URL. This can be useful if you wish to periodically test a website or webpage that dynamically changes over time for example, like a blog or a wiki, without first saving the html to a file using your browswer, or a utility such as wget. B $url, a scalar, $name, an optional descriptive test name. B None. =cut sub is_valid { my ($uri, $message) = @_; _check_plan() if $not_checked; if ($v->validate($uri)) { _result($v, $message); } else { _validator_err($v, "URI"); } } sub _validator_err { my ($validator, $type) = @_; __PACKAGE__->builder->ok(0, "Failed to validate $type."); __PACKAGE__->builder->diag($v->validator_error()); } sub _result { my ($validator, $message) = @_; if ($validator->is_valid()) { __PACKAGE__->builder->ok(1, $message); } else { my $num = $validator->num_errors(); my $plurality = ($num == 1) ? "error" : "errors"; __PACKAGE__->builder->ok(0, $message . " ($num $plurality)."); } } =item diag_html($url); B If you want to display the actual errors reported by the service for a particular test, you can use the diag_html function. Please note that you must have imported 'show_detail' for this to work properly. use Test::HTML::W3C 'show_detail'; is_valid_markup(", "My simple test") or diag_html(); B $url, a scalar. B None. =cut sub diag_html { my $tb = __PACKAGE__->builder(); if ($show_detail) { my @errs = $v->errors(); my $e; foreach my $error ( @{$v->errors()} ) { $e .= sprintf("%s at line %d\n", $error->msg, $error->line); } $tb->diag($e); } else { $tb->diag("You need to import 'show_detail' in order to call diag_html\n"); } } 1; __END__ =back =head1 SEE ALSO L for creating your own testing modules. L for another popular testing framework, also based on Test::Builder L for detils about how test results are interpreted. =head1 AUTHORS Victor Evictor73@gmail.comE with inspiration from the authors of the Test::More and WebService::Validator::W3C:HTML modules. =head1 BUGS See F to report and view bugs. =head1 COPYRIGHT Copyright 2006 by Victor Evictor73@gmail.comE. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See F Test-HTML-W3C-0.04/Changes0000644000175000017500000000050111623635361014403 0ustar victorvictor$Id: Changes 4376 2011-08-20 04:41:22Z victor $ 0.04 Saturday 20th Aug 2011 - Improved POD. Applied patch provided by Nicholas Bamber. 0.03 Sunday 18th May 2008 - Fixed POD error (CPAN Bug #35002) 0.02 Monday 27th February 2006 - Fixed minor POD error 0.01 Monday 27th February 2006 - Initial release Test-HTML-W3C-0.04/META.yml0000644000175000017500000000112611623635776014377 0ustar victorvictor--- #YAML:1.0 name: Test-HTML-W3C version: 0.04 abstract: Perform W3C HTML validation testing author: - victor73@gmail.com license: unknown distribution_type: module configure_requires: ExtUtils::MakeMaker: 0 build_requires: ExtUtils::MakeMaker: 0 requires: Test::Builder::Module: 0 WebService::Validator::HTML::W3C: 0.1 no_index: directory: - t - inc generated_by: ExtUtils::MakeMaker version 6.55_02 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 Test-HTML-W3C-0.04/README0000644000175000017500000000232011623634507013772 0ustar victorvictor$Revision: 3768 $ Test::HTML::W3C is a testing module, which uses Test::Builder::Module and is in the spirit Test::More. It simply wraps WebService::Validator::HTML::W3C and provides some convenient functions to detect HTML/XHTML validation problems using services provided by the World Wide Web Consortium (W3C). Please note that, as with WebService::Validator::HTML::W3C, this particular module has absolutely no connection with the good folks at W3C. Please DO NOT report any problems with it to them. In addition, please do not abuse the W3C's validator service. If you need to do lots of validation testing, try downloading and installing the validator software and modifying the validator uri this module uses per the documentation. PREREQUISITES WebService::Validator::HTML::W3C Test::Builder::Module INSTALLATION You should be able to install Test::HTML::W3C in any of the usual ways: perl -MCPAN -e 'install Test::HTML::W3C' or perl -MCPANPLUS -e 'install Test::HTML::W3C' or perl Makefile.PL make make test make install TESTS Currently, the only tests provided test for POD correctness and coverage. More tests will be supplied later... For everything else see the POD documentation. Test-HTML-W3C-0.04/MANIFEST0000644000175000017500000000027411623634507014251 0ustar victorvictorlib/Test/HTML/W3C.pm Changes README Makefile.PL MANIFEST This list of files t/98-pod.t t/99-pod-coverage.t META.yml Module meta-data (added by MakeMaker) Test-HTML-W3C-0.04/Makefile.PL0000755000175000017500000000071511623634507015075 0ustar victorvictor#!/usr/bin/perl use strict; use ExtUtils::MakeMaker; BEGIN { require 5.006_00; } WriteMakefile( NAME => "Test::HTML::W3C", ABSTRACT => "Perform W3C HTML validation testing", AUTHOR => 'victor73@gmail.com', VERSION_FROM => "lib/Test/HTML/W3C.pm", PREREQ_PM => { "WebService::Validator::HTML::W3C" => 0.1, "Test::Builder::Module" => 0, }, );