Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 46160d6cb5
Fetching contributors…

Cannot retrieve contributors at this time

file 171 lines (153 sloc) 5.666 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
# $Id$

use Test::More;
use WebService::Validator::HTML::W3C;

my $test_num = 5;

if ( $ENV{ 'TEST_AUTHOR' } ) {
$test_num = 6;
}

plan tests => $test_num;

my $v = WebService::Validator::HTML::W3C->new(
            http_timeout => 10,
            detailed => 1,
        );

SKIP: {
    skip "XML::XPath not installed", $test_num if -f 't/SKIPXPATH';

    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{<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Body>
<m:markupvalidationresponse env:encodingStyle="http://www.w3.org/
2003/05/soap-encoding" xmlns:m="http://www.w3.org/2005/10/markup-
validator">

<m:uri>http://exo.org.uk/code/www-w3c-validator/invalid.html</m:uri>
<m:checkedby>http://validator.w3.org/</m:checkedby>
<m:doctype>-//W3C//DTD XHTML 1.0 Strict//EN</m:doctype>
<m:charset>utf-8</m:charset>
<m:validity>false</m:validity>
<m:errors>
<m:errorcount>4</m:errorcount>
<m:errorlist>

<m:error>
<m:line>11</m:line>
<m:col>7</m:col>
<m:message>end tag for &quot;div&quot; omitted, but OMITTAG NO was specified</m:message>
<m:messageid>70</m:messageid>
<m:explanation> <![CDATA[
<p class="helpwanted">
<a
href="http://validator.w3.org/feedback.html?uri=http%3A%2F%
2Fexo.org.uk%2Fcode%2Fwww-w3c-validator%
2Finvalid.html;errmsg_id=70#errormsg"
title="Suggest improvements on this error message through
our feedback channels"
>&#x2709;</a>
</p>

<div class="ve mid-70">
<p>
You may have neglected to close an element, or perhaps you
meant to
"self-close" an element, that is, ending it with "/&gt;"
instead of "&gt;".
</p>
</div>

]]>
</m:explanation>
<m:source><![CDATA[&#60;/body<strong title="Position
where error was detected.">&#62;</strong>]]></m:source>
</m:error>
<m:error>
<m:line>11</m:line>
<m:col>7</m:col>
<m:message>XML Parsing Error: Opening and ending
tag mismatch: div line 9 and body</m:message>
<m:messageid>xmlwf</m:messageid>
<m:explanation> <![CDATA[
<p class="helpwanted">
<a
href="http://validator.w3.org/feedback.html?uri=http%3A%2F%
2Fexo.org.uk%2Fcode%2Fwww-w3c-validator%
2Finvalid.html;errmsg_id=xmlwf#errormsg"
title="Suggest improvements on this error message through
our feedback channels"
>&#x2709;</a>
</p>
]]>
</m:explanation>
<m:source><![CDATA[&#60;/body<strong title="Position
where error was detected.">&#62;</strong>]]></m:source>
</m:error>
<m:error>
<m:line>12</m:line>
<m:col>7</m:col>
<m:message>XML Parsing Error: Opening and ending
tag mismatch: body line 7 and html</m:message>
<m:messageid>xmlwf</m:messageid>
<m:explanation> <![CDATA[
<p class="helpwanted">
<a
href="http://validator.w3.org/feedback.html?uri=http%3A%2F%
2Fexo.org.uk%2Fcode%2Fwww-w3c-validator%
2Finvalid.html;errmsg_id=xmlwf#errormsg"
title="Suggest improvements on this error message through
our feedback channels"
>&#x2709;</a>
</p>
]]>
</m:explanation>
<m:source><![CDATA[&#60;/html<strong title="Position
where error was detected.">&#62;</strong>]]></m:source>
</m:error>
<m:error>
<m:line>12</m:line>
<m:col>7</m:col>
<m:message>XML Parsing Error: Premature end of data
in tag html line 3</m:message>
<m:messageid>xmlwf</m:messageid>
<m:explanation> <![CDATA[
<p class="helpwanted">
<a
href="http://validator.w3.org/feedback.html?uri=http%3A%2F%
2Fexo.org.uk%2Fcode%2Fwww-w3c-validator%
2Finvalid.html;errmsg_id=xmlwf#errormsg"
title="Suggest improvements on this error message through
our feedback channels"
>&#x2709;</a>
</p>

]]>
</m:explanation>
<m:source><![CDATA[&#60;/html<strong title="Position
where error was detected.">&#62;</strong>]]></m:source>
</m:error>
</m:errorlist>
</m:errors>
<m:warnings>
<m:warningcount>1</m:warningcount>
<m:warninglist>
<m:warning><m:messageid>W26"></m:messageid><m:message>Mismatch
between Public and System identifiers in the DOCTYPE declaration</m:message></m:warning>
</m:warninglist>
</m:warnings>
</m:markupvalidationresponse>
</env:Body>
</env:Envelope>
}
);
}
    
            
    my $err = $v->errors->[0];
    isa_ok($err, 'WebService::Validator::HTML::W3C::Error');
    is($err->line, 11, 'Correct line number');
    is($err->col, 7, 'Correct column');
    like($err->msg, qr/end tag for "div" omitted, but OMITTAG NO was specified/,
                    'Correct message');
    
}
Something went wrong with that request. Please try again.