mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-05 21:57:26 +02:00
Commit TagTransform_Font and associated test-cases.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@143 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
@@ -32,6 +32,10 @@ class HTMLPurifier_Strategy_RemoveForeignElementsTest
|
||||
$inputs[4] = '<center>Look I am Centered!</center>';
|
||||
$expect[4] = '<div style="text-align:center;">Look I am Centered!</div>';
|
||||
|
||||
// test font transform
|
||||
$inputs[5] = '<font color="red" face="Arial" size="6">Big Warning!</font>';
|
||||
$expect[5] = '<span style="color:red;font-family:Arial;font-size:xx-large;">Big Warning!</span>';
|
||||
|
||||
$this->assertStrategyWorks($strategy, $inputs, $expect);
|
||||
}
|
||||
|
||||
|
@@ -81,6 +81,53 @@ class HTMLPurifier_TagTransformTest extends UnitTestCase
|
||||
|
||||
}
|
||||
|
||||
function assertSizeToStyle($transformer, $size, $style) {
|
||||
$this->assertTransformation(
|
||||
$transformer,
|
||||
'font', array('size' => $size),
|
||||
'span', array('style' => 'font-size:' . $style . ';')
|
||||
);
|
||||
}
|
||||
|
||||
function testFont() {
|
||||
|
||||
$transformer = new HTMLPurifier_TagTransform_Font();
|
||||
|
||||
// test a font-face transformation
|
||||
$this->assertTransformation(
|
||||
$transformer,
|
||||
'font', array('face' => 'Arial'),
|
||||
'span', array('style' => 'font-family:Arial;')
|
||||
);
|
||||
|
||||
// test a color transformation
|
||||
$this->assertTransformation(
|
||||
$transformer,
|
||||
'font', array('color' => 'red'),
|
||||
'span', array('style' => 'color:red;')
|
||||
);
|
||||
|
||||
// test the size transforms
|
||||
$this->assertSizeToStyle($transformer, '1', 'xx-small');
|
||||
$this->assertSizeToStyle($transformer, '2', 'small');
|
||||
$this->assertSizeToStyle($transformer, '3', 'medium');
|
||||
$this->assertSizeToStyle($transformer, '4', 'large');
|
||||
$this->assertSizeToStyle($transformer, '5', 'x-large');
|
||||
$this->assertSizeToStyle($transformer, '6', 'xx-large');
|
||||
$this->assertSizeToStyle($transformer, '7', '300%');
|
||||
$this->assertSizeToStyle($transformer, '-1', 'smaller');
|
||||
$this->assertSizeToStyle($transformer, '+1', 'larger');
|
||||
$this->assertSizeToStyle($transformer, '-2', '60%');
|
||||
$this->assertSizeToStyle($transformer, '+2', '150%');
|
||||
$this->assertSizeToStyle($transformer, '+4', '300%');
|
||||
|
||||
// test multiple transforms, the alphabetical ordering is important
|
||||
$this->assertTransformation(
|
||||
$transformer,
|
||||
'font', array('color' => 'red', 'face' => 'Arial', 'size' => '6'),
|
||||
'span', array('style' => 'color:red;font-family:Arial;font-size:xx-large;')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user