summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChristian Weber2012-03-23 15:28:10 +0000
committerChristian Weber2012-03-23 15:28:10 +0000
commit6c6828a8f0904110a67fe89031f9d4eaedf29213 (patch)
tree3269f6c18dac1eef3bf125e81072b334d27048be /tests
parentb7e99acb4b7f53799751c07ac9aae3de5fabd99e (diff)
downloaditools-6c6828a8f0904110a67fe89031f9d4eaedf29213.tar.gz
itools-6c6828a8f0904110a67fe89031f9d4eaedf29213.tar.bz2
itools-6c6828a8f0904110a67fe89031f9d4eaedf29213.zip
it_xml uses correct target encoding by default, adapt tests to utf-8 deafult
Diffstat (limited to 'tests')
-rwxr-xr-xtests/it_xml.t35
1 files changed, 21 insertions, 14 deletions
diff --git a/tests/it_xml.t b/tests/it_xml.t
index f74c54b..d74fadf 100755
--- a/tests/it_xml.t
+++ b/tests/it_xml.t
@@ -5,13 +5,14 @@
function match($xmldata, $expected, $name, $prefix = "", $p = array())
{
- $classname = $prefix ? ($prefix . "_xml") : "it_xml";
+ $classname = ($prefix ?: "it") . "_xml";
$varname = $prefix . "foo";
$xmldata = "<root>$xmldata</root>";
$xml = new $classname($xmldata, $p);
+ $mod_utf8 = $p['encoding'] != "iso-8859-1" ? "u" : "";
is(
- preg_replace('/[#\s]+/', " ", print_r($xml->$varname, true)),
+ preg_replace('/[#\s]+/' . $mod_utf8, " ", print_r($xml->$varname, true)),
$expected,
"$name (string)"
);
@@ -24,11 +25,10 @@ function match($xmldata, $expected, $name, $prefix = "", $p = array())
fclose($tmpfile);
is(
- preg_replace('/[#\s]+/', " ", print_r($xml->$varname, true)),
+ preg_replace('/[#\s]+/' . $mod_utf8, " ", print_r($xml->$varname, true)),
$expected,
"$name (file)"
);
-
}
match(
@@ -44,8 +44,8 @@ match(
);
match(
- '<foo title="Zürich">Stüssihofstadt</foo>',
- 'foo Object ( [attr] => Array ( [title] => Zürich ) [val] => Stüssihofstadt ) ',
+ '<foo title="Zürich">Stüssihofstadt</foo>',
+ 'foo Object ( [attr] => Array ( [title] => Zürich ) [val] => Stüssihofstadt ) ',
'simple tag with latin1 content and attribute'
);
@@ -62,26 +62,33 @@ match(
);
match(
- '<foo>&amp;amp; &lt;a&gt; &#38;amp; &#60;b&#62; &#x26;amp; &#x3C;c&#x3E; &uuml;</foo>',
- 'foo Object ( [val] => &amp; <a> &amp; <b> &amp; <c> ü ) ',
- 'Predecode illegal entities while keeping properly encoded ones'
+ '<foo>x &uuml; y</foo>',
+ utf8_decode('foo Object ( [val] => x ü y ) '),
+ 'Manual encoding override',
+ "",
+ array('encoding' => "iso-8859-1")
);
match(
'<foo>&amp;amp; &lt;a&gt; &#38;amp; &#60;b&#62; &#x26;amp; &#x3C;c&#x3E; &uuml;</foo>',
- utf8_encode('foo Object ( [val] => &amp; <a> &amp; <b> &amp; <c> ü ) '),
- 'Predecode illegal entities while keeping properly encoded ones (UTF-8)',
- "",
- array('encoding' => "UTF-8")
+ 'foo Object ( [val] => &amp; <a> &amp; <b> &amp; <c> ü ) ',
+ 'Predecode illegal entities while keeping properly encoded ones',
);
+match(
+ '<foo>&amp;amp; &lt;a&gt; &#38;amp; &#60;b&#62; &#x26;amp; &#x3C;c&#x3E; &#xFC;</foo>',
+ utf8_decode('foo Object ( [val] => &amp; <a> &amp; <b> &amp; <c> ü ) '),
+ 'Predecode illegal entities while keeping properly encoded ones (iso-8859-1)',
+ "",
+ array('encoding' => "iso-8859-1")
+);
match(
"<foo>a\x05b</foo>",
'foo Object ( [val] => a b ) ',
'Illegal latin 1 character',
"",
- array('encoding' => "ISO-8859-1")
+ array('encoding' => "iso-8859-1")
);
# Test inheritance