3 require_once 'HTMLPurifier/AttrCollections.php';
5 class HTMLPurifier_AttrCollectionsTest_NoConstructor
extends HTMLPurifier_AttrCollections
7 function HTMLPurifier_AttrCollectionsTest_NoConstructor() {}
8 function expandIdentifiers(&$a, $b) {}
9 function performInclusions(&$a) {}
12 class HTMLPurifier_AttrCollectionsTest
extends HTMLPurifier_Harness
15 function testConstruction() {
17 generate_mock_once('HTMLPurifier_AttrTypes');
19 $collections = new HTMLPurifier_AttrCollectionsTest_NoConstructor();
21 $types = new HTMLPurifier_AttrTypesMock();
25 $modules['Module1'] = new HTMLPurifier_HTMLModule();
26 $modules['Module1']->attr_collections
= array(
28 0 => array('Soup', 'Undefined'),
29 'attribute' => 'Type',
30 'attribute-2' => 'Type2',
33 'attribute-3' => 'Type3-old' // overwritten
37 $modules['Module2'] = new HTMLPurifier_HTMLModule();
38 $modules['Module2']->attr_collections
= array(
40 0 => array('Brocolli')
43 'attribute-3' => 'Type3'
48 $collections->HTMLPurifier_AttrCollections($types, $modules);
49 // this is without identifier expansion or inclusions
50 $this->assertIdentical(
54 0 => array('Soup', 'Undefined', 'Brocolli'),
55 'attribute' => 'Type',
56 'attribute-2' => 'Type2'
59 'attribute-3' => 'Type3'
67 function test_performInclusions() {
69 generate_mock_once('HTMLPurifier_AttrTypes');
71 $types = new HTMLPurifier_AttrTypesMock();
72 $collections = new HTMLPurifier_AttrCollections($types, array());
73 $collections->info
= array(
74 'Core' => array(0 => array('Inclusion', 'Undefined'), 'attr-original' => 'Type'),
75 'Inclusion' => array(0 => array('SubInclusion'), 'attr' => 'Type'),
76 'SubInclusion' => array('attr2' => 'Type')
79 $collections->performInclusions($collections->info
['Core']);
80 $this->assertIdentical(
81 $collections->info
['Core'],
83 'attr-original' => 'Type',
90 $collections->info
= array(
91 'One' => array(0 => array('Two'), 'one' => 'Type'),
92 'Two' => array(0 => array('One'), 'two' => 'Type')
94 $collections->performInclusions($collections->info
['One']);
95 $this->assertIdentical(
96 $collections->info
['One'],
105 function test_expandIdentifiers() {
107 generate_mock_once('HTMLPurifier_AttrTypes');
109 $types = new HTMLPurifier_AttrTypesMock();
110 $collections = new HTMLPurifier_AttrCollections($types, array());
116 $c_object = new HTMLPurifier_AttrDef();
117 $c_object->_name
= 'Color'; // for testing purposes only
118 $u_object = new HTMLPurifier_AttrDef();
119 $u_object->_name
= 'URL'; // for testing purposes only
121 $types->setReturnValue('get', $c_object, array('Color'));
122 $types->setReturnValue('get', $u_object, array('URI'));
124 $collections->expandIdentifiers($attr, $types);
126 $u_object->required
= true;
127 $this->assertIdentical(
130 'attr1' => $c_object,