mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-07-31 11:20:13 +02:00
[1.7.0] Create convenience functions for HTMLModule constructors, HTMLModule_Bdo was hooked up
- Add initial "safe" property for elements, is not set for most though git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1039 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
50
tests/HTMLPurifier/HTMLModuleTest.php
Normal file
50
tests/HTMLPurifier/HTMLModuleTest.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
require_once 'HTMLPurifier/HTMLModule.php';
|
||||
require_once 'HTMLPurifier/AttrDef.php';
|
||||
|
||||
class HTMLPurifier_HTMLModuleTest extends UnitTestCase
|
||||
{
|
||||
|
||||
function test_addElementToContentSet() {
|
||||
|
||||
$module = new HTMLPurifier_HTMLModule();
|
||||
|
||||
$module->addElementToContentSet('b', 'Inline');
|
||||
$this->assertIdentical($module->content_sets, array('Inline' => 'b'));
|
||||
|
||||
$module->addElementToContentSet('i', 'Inline');
|
||||
$this->assertIdentical($module->content_sets, array('Inline' => 'b | i'));
|
||||
|
||||
}
|
||||
|
||||
function test_addElement() {
|
||||
|
||||
$module = new HTMLPurifier_HTMLModule();
|
||||
$module->addElement(
|
||||
'a', true, 'Inline', 'Optional: #PCDATA', array('Common'),
|
||||
array(
|
||||
'href' => 'URI'
|
||||
)
|
||||
);
|
||||
|
||||
$module2 = new HTMLPurifier_HTMLModule();
|
||||
$def = new HTMLPurifier_ElementDef();
|
||||
$def->safe = true;
|
||||
$def->content_model = '#PCDATA';
|
||||
$def->content_model_type = 'optional';
|
||||
$def->attr = array(
|
||||
'href' => 'URI',
|
||||
0 => array('Common')
|
||||
);
|
||||
$module2->info['a'] = $def;
|
||||
$module2->elements = array('a');
|
||||
$module2->content_sets['Inline'] = 'a';
|
||||
|
||||
$this->assertIdentical($module, $module2);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user