Files
admin
doz
html2pdf_v4.03
htmlpurifier-4.10.0
art
benchmarks
configdoc
docs
extras
library
maintenance
plugins
smoketests
tests
FSTools
HTMLPurifier
AttrDef
AttrTransform
ChildDef
ConfigSchema
DefinitionCache
Filter
HTMLModule
HTMLT
Injector
Lexer
PHPT
SimpleTest
Strategy
StringHashParser
URIFilter
VarParser
AttrCollectionsTest.php
AttrDefHarness.php
AttrDefTest.php
AttrTransformHarness.php
AttrTransformTest.php
AttrTypesTest.php
AttrValidator_ErrorsTest.php
ChildDefHarness.php
ComplexHarness.php
ConfigSchemaTest.php
ConfigTest-create.ini
ConfigTest-finalize.ini
ConfigTest-loadIni.ini
ConfigTest.php
ContextTest.php
DefinitionCacheFactoryTest.php
DefinitionCacheHarness.php
DefinitionCacheTest.php
DefinitionTest.php
DefinitionTestable.php
DoctypeRegistryTest.php
ElementDefTest.php
EncoderTest.php
EntityLookupTest.php
EntityParserTest.php
ErrorCollectorEMock.php
ErrorCollectorTest.php
ErrorsHarness.php
GeneratorTest.php
HTMLDefinitionTest.php
HTMLModuleHarness.php
HTMLModuleManagerTest.php
HTMLModuleTest.php
HTMLT.php
Harness.php
IDAccumulatorTest.php
InjectorHarness.php
LanguageFactoryTest.php
LanguageTest.php
LengthTest.php
LexerTest.php
PercentEncoderTest.php
PropertyListTest.php
StrategyHarness.php
StringHashParserTest.php
StringHashTest.php
TagTransformTest.php
TokenFactoryTest.php
TokenTest.php
URIDefinitionTest.php
URIFilterHarness.php
URIHarness.php
URIParserTest.php
URISchemeRegistryTest.php
URISchemeTest.php
URITest.php
UnitConverterTest.php
VarParserHarness.php
ZipperTest.php
PHPT
tmp
CliTestCase.php
Debugger.php
HTMLPurifierTest.php
common.php
default_load.php
generate_mock_once.func.php
index.php
multitest.php
path2class.func.php
test_files.php
.gitattributes
.gitignore
.travis.yml
CREDITS
Doxyfile
INSTALL
INSTALL.fr.utf8
LICENSE
NEWS
README.md
TODO
VERSION
WHATSNEW
WYSIWYG
composer.json
phpdoc.ini
images
prints
prints3
stud
Kennwortwechsel.php
hauptframe.php
htmlpurifier-4.10.0.zip
index.php
index_alt.php
index_db.php
index_frame.htm
index_ldap.php
login.php
logout.php
menuframe.htm
styles_pc.css
testpdf.php
topframe.php
skik/htmlpurifier-4.10.0/tests/HTMLPurifier/AttrCollectionsTest.php
2023-02-27 10:20:09 +01:00

135 lines
4.0 KiB
PHP
Executable File

<?php
Mock::generatePartial(
'HTMLPurifier_AttrCollections',
'HTMLPurifier_AttrCollections_TestForConstruct',
array('performInclusions', 'expandIdentifiers')
);
class HTMLPurifier_AttrCollectionsTest extends HTMLPurifier_Harness
{
public function testConstruction()
{
generate_mock_once('HTMLPurifier_AttrTypes');
$collections = new HTMLPurifier_AttrCollections_TestForConstruct();
$types = new HTMLPurifier_AttrTypesMock();
$modules = array();
$modules['Module1'] = new HTMLPurifier_HTMLModule();
$modules['Module1']->attr_collections = array(
'Core' => array(
0 => array('Soup', 'Undefined'),
'attribute' => 'Type',
'attribute-2' => 'Type2',
),
'Soup' => array(
'attribute-3' => 'Type3-old' // overwritten
)
);
$modules['Module2'] = new HTMLPurifier_HTMLModule();
$modules['Module2']->attr_collections = array(
'Core' => array(
0 => array('Brocolli')
),
'Soup' => array(
'attribute-3' => 'Type3'
),
'Brocolli' => array()
);
$collections->doConstruct($types, $modules);
// this is without identifier expansion or inclusions
$this->assertIdentical(
$collections->info,
array(
'Core' => array(
0 => array('Soup', 'Undefined', 'Brocolli'),
'attribute' => 'Type',
'attribute-2' => 'Type2'
),
'Soup' => array(
'attribute-3' => 'Type3'
),
'Brocolli' => array()
)
);
}
public function test_performInclusions()
{
generate_mock_once('HTMLPurifier_AttrTypes');
$types = new HTMLPurifier_AttrTypesMock();
$collections = new HTMLPurifier_AttrCollections($types, array());
$collections->info = array(
'Core' => array(0 => array('Inclusion', 'Undefined'), 'attr-original' => 'Type'),
'Inclusion' => array(0 => array('SubInclusion'), 'attr' => 'Type'),
'SubInclusion' => array('attr2' => 'Type')
);
$collections->performInclusions($collections->info['Core']);
$this->assertIdentical(
$collections->info['Core'],
array(
'attr-original' => 'Type',
'attr' => 'Type',
'attr2' => 'Type'
)
);
// test recursive
$collections->info = array(
'One' => array(0 => array('Two'), 'one' => 'Type'),
'Two' => array(0 => array('One'), 'two' => 'Type')
);
$collections->performInclusions($collections->info['One']);
$this->assertIdentical(
$collections->info['One'],
array(
'one' => 'Type',
'two' => 'Type'
)
);
}
public function test_expandIdentifiers()
{
generate_mock_once('HTMLPurifier_AttrTypes');
$types = new HTMLPurifier_AttrTypesMock();
$collections = new HTMLPurifier_AttrCollections($types, array());
$attr = array(
'attr1' => 'Color',
'attr2*' => 'URI'
);
$c_object = new HTMLPurifier_AttrDef_HTML_Color();
$u_object = new HTMLPurifier_AttrDef_URI();
$types->returns('get', $c_object, array('Color'));
$types->returns('get', $u_object, array('URI'));
$collections->expandIdentifiers($attr, $types);
$u_object->required = true;
$this->assertIdentical(
$attr,
array(
'attr1' => $c_object,
'attr2' => $u_object
)
);
}
}
// vim: et sw=4 sts=4