4 'HTMLPurifier_AttrCollections',
5 'HTMLPurifier_AttrCollections_TestForConstruct',
6 array('performInclusions', 'expandIdentifiers')
9 class HTMLPurifier_AttrCollectionsTest
extends HTMLPurifier_Harness
12 function testConstruction() {
14 generate_mock_once('HTMLPurifier_AttrTypes');
16 $collections = new HTMLPurifier_AttrCollections_TestForConstruct();
18 $types = new HTMLPurifier_AttrTypesMock();
22 $modules['Module1'] = new HTMLPurifier_HTMLModule();
23 $modules['Module1']->attr_collections
= array(
25 0 => array('Soup', 'Undefined'),
26 'attribute' => 'Type',
27 'attribute-2' => 'Type2',
30 'attribute-3' => 'Type3-old' // overwritten
34 $modules['Module2'] = new HTMLPurifier_HTMLModule();
35 $modules['Module2']->attr_collections
= array(
37 0 => array('Brocolli')
40 'attribute-3' => 'Type3'
45 $collections->__construct($types, $modules);
46 // this is without identifier expansion or inclusions
47 $this->assertIdentical(
51 0 => array('Soup', 'Undefined', 'Brocolli'),
52 'attribute' => 'Type',
53 'attribute-2' => 'Type2'
56 'attribute-3' => 'Type3'
64 function test_performInclusions() {
66 generate_mock_once('HTMLPurifier_AttrTypes');
68 $types = new HTMLPurifier_AttrTypesMock();
69 $collections = new HTMLPurifier_AttrCollections($types, array());
70 $collections->info
= array(
71 'Core' => array(0 => array('Inclusion', 'Undefined'), 'attr-original' => 'Type'),
72 'Inclusion' => array(0 => array('SubInclusion'), 'attr' => 'Type'),
73 'SubInclusion' => array('attr2' => 'Type')
76 $collections->performInclusions($collections->info
['Core']);
77 $this->assertIdentical(
78 $collections->info
['Core'],
80 'attr-original' => 'Type',
87 $collections->info
= array(
88 'One' => array(0 => array('Two'), 'one' => 'Type'),
89 'Two' => array(0 => array('One'), 'two' => 'Type')
91 $collections->performInclusions($collections->info
['One']);
92 $this->assertIdentical(
93 $collections->info
['One'],
102 function test_expandIdentifiers() {
104 generate_mock_once('HTMLPurifier_AttrTypes');
106 $types = new HTMLPurifier_AttrTypesMock();
107 $collections = new HTMLPurifier_AttrCollections($types, array());
113 $c_object = new HTMLPurifier_AttrDef_HTML_Color();
114 $u_object = new HTMLPurifier_AttrDef_URI();
116 $types->setReturnValue('get', $c_object, array('Color'));
117 $types->setReturnValue('get', $u_object, array('URI'));
119 $collections->expandIdentifiers($attr, $types);
121 $u_object->required
= true;
122 $this->assertIdentical(
125 'attr1' => $c_object,