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
|
|
|
{
|
|
|
|
|
2006-10-22 03:38:32 +00:00
|
|
|
function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
$this->obj = new HTMLPurifier_AttrTransform_Lang();
|
|
|
|
}
|
|
|
|
|
2006-08-05 01:50:13 +00:00
|
|
|
function test() {
|
|
|
|
|
|
|
|
// leave non-lang'ed elements alone
|
2006-10-22 03:38:32 +00:00
|
|
|
$this->assertResult(array(), true);
|
2006-08-05 01:50:13 +00:00
|
|
|
|
|
|
|
// copy lang to xml:lang
|
2006-10-22 03:38:32 +00:00
|
|
|
$this->assertResult(
|
|
|
|
array('lang' => 'en'),
|
|
|
|
array('lang' => 'en', 'xml:lang' => 'en')
|
|
|
|
);
|
2006-08-05 02:16:28 +00:00
|
|
|
|
|
|
|
// preserve attributes
|
2006-10-22 03:38:32 +00:00
|
|
|
$this->assertResult(
|
|
|
|
array('src' => 'vert.png', 'lang' => 'fr'),
|
|
|
|
array('src' => 'vert.png', 'lang' => 'fr', 'xml:lang' => 'fr')
|
|
|
|
);
|
2006-08-05 01:50:13 +00:00
|
|
|
|
|
|
|
// copy xml:lang to lang
|
2006-10-22 03:38:32 +00:00
|
|
|
$this->assertResult(
|
|
|
|
array('xml:lang' => 'en'),
|
|
|
|
array('lang' => 'en', 'xml:lang' => 'en')
|
|
|
|
);
|
2006-08-05 01:50:13 +00:00
|
|
|
|
|
|
|
// both set, override lang with xml:lang
|
2006-10-22 03:38:32 +00:00
|
|
|
$this->assertResult(
|
|
|
|
array('lang' => 'fr', 'xml:lang' => 'de'),
|
|
|
|
array('lang' => 'de', 'xml:lang' => 'de')
|
|
|
|
);
|
2006-08-05 01:50:13 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|