2006-08-05 01:50:13 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once 'HTMLPurifier/Token.php';
|
2006-08-05 02:16:28 +00:00
|
|
|
require_once 'HTMLPurifier/AttrTransformHarness.php';
|
2006-08-05 01:50:13 +00:00
|
|
|
require_once 'HTMLPurifier/AttrTransform/Lang.php';
|
|
|
|
|
2006-08-05 02:16:28 +00:00
|
|
|
class HTMLPurifier_AttrTransform_LangTest
|
|
|
|
extends HTMLPurifier_AttrTransformHarness
|
2006-08-05 01:50:13 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
function test() {
|
|
|
|
|
2006-08-05 02:16:28 +00:00
|
|
|
$this->transform = new HTMLPurifier_AttrTransform_Lang();
|
2006-08-05 01:50:13 +00:00
|
|
|
|
|
|
|
$inputs = array();
|
|
|
|
$expect = array();
|
|
|
|
|
|
|
|
// leave non-lang'ed elements alone
|
2006-08-05 02:16:28 +00:00
|
|
|
$inputs[0] = array();
|
|
|
|
$expect[0] = true;
|
2006-08-05 01:50:13 +00:00
|
|
|
|
|
|
|
// copy lang to xml:lang
|
2006-08-05 02:16:28 +00:00
|
|
|
$inputs[1] = array('lang' => 'en');
|
|
|
|
$expect[1] = array('lang' => 'en', 'xml:lang' => 'en');
|
|
|
|
|
|
|
|
// preserve attributes
|
|
|
|
$inputs[2] = array('src' => 'vert.png', 'lang' => 'fr');
|
|
|
|
$expect[2] = array('src' => 'vert.png', 'lang' => 'fr', 'xml:lang' => 'fr');
|
2006-08-05 01:50:13 +00:00
|
|
|
|
|
|
|
// copy xml:lang to lang
|
2006-08-05 02:16:28 +00:00
|
|
|
$inputs[3] = array('xml:lang' => 'en');
|
|
|
|
$expect[3] = array('lang' => 'en', 'xml:lang' => 'en');
|
2006-08-05 01:50:13 +00:00
|
|
|
|
|
|
|
// both set, override lang with xml:lang
|
2006-08-05 02:16:28 +00:00
|
|
|
$inputs[4] = array('lang' => 'fr', 'xml:lang' => 'de');
|
|
|
|
$expect[4] = array('lang' => 'de', 'xml:lang' => 'de');
|
|
|
|
|
|
|
|
$this->assertTransform($inputs, $expect);
|
2006-08-05 01:50:13 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|