1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-07-31 03:10:09 +02:00

Implement TextAlign and all hooks necessary, but it's kind of useless since CSS validation hasn't been built yet.

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@166 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2006-08-05 02:56:57 +00:00
parent 60f769d088
commit 2deb2fc285
6 changed files with 118 additions and 4 deletions

View File

@@ -0,0 +1,55 @@
<?php
require_once 'HTMLPurifier/AttrTransform/TextAlign.php';
class HTMLPurifier_AttrTransform_TextAlignTest extends HTMLPurifier_AttrTransformHarness
{
function test() {
$this->transform = new HTMLPurifier_AttrTransform_TextAlign();
$inputs = array();
$expect = array();
// leave empty arrays alone
$inputs[0] = array();
$expect[0] = true;
// leave arrays without interesting stuff alone
$inputs[1] = array('style' => 'font-weight:bold;');
$expect[1] = true;
// test each of the conversions
$inputs[2] = array('align' => 'left');
$expect[2] = array('style' => 'text-align:left;');
$inputs[3] = array('align' => 'right');
$expect[3] = array('style' => 'text-align:right;');
$inputs[4] = array('align' => 'center');
$expect[4] = array('style' => 'text-align:center;');
$inputs[5] = array('align' => 'justify');
$expect[5] = array('style' => 'text-align:justify;');
// drop garbage value
$inputs[6] = array('align' => 'invalid');
$expect[6] = array();
// test CSS munging
$inputs[7] = array('align' => 'left', 'style' => 'font-weight:bold;');
$expect[7] = array('style' => 'text-align:left;font-weight:bold;');
// test case insensitivity
$inputs[4] = array('align' => 'CENTER');
$expect[4] = array('style' => 'text-align:center;');
$this->assertTransform($inputs, $expect);
}
}
?>

View File

@@ -59,10 +59,14 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
$inputs[10] = '<acronym title="PHP: Hypertext Preprocessor">PHP</acronym>';
$expect[10] = $inputs[10];
// test lang (NEEDS CORRECTION!)
// test lang
$inputs[11] = '<span lang="fr">La soupe.</span>';
$expect[11] = '<span lang="fr" xml:lang="fr">La soupe.</span>';
// test align (won't work till CSS validation is fixed)
// $inputs[12] = '<h1 align="center">Centered Headline</h1>';
// $expect[12] = '<h1 style="text-align:center;">Centered Headline</h1>';
$this->assertStrategyWorks($strategy, $inputs, $expect, $config);
}

View File

@@ -46,6 +46,7 @@ $test_files[] = 'AttrDef/LangTest.php';
$test_files[] = 'IDAccumulatorTest.php';
$test_files[] = 'TagTransformTest.php';
$test_files[] = 'AttrTransform/LangTest.php';
$test_files[] = 'AttrTransform/TextAlignTest.php';
$test_file_lookup = array_flip($test_files);