3 class HTMLPurifier_ConfigSchemaTest
extends HTMLPurifier_Harness
9 $this->schema
= new HTMLPurifier_ConfigSchema();
12 function test_defineNamespace() {
13 $this->schema
->addNamespace('http');
14 $this->assertIdentical($this->schema
->info
['http'], array());
15 $this->assertIdentical($this->schema
->defaults
['http'], array());
18 function test_define() {
19 $this->schema
->addNamespace('Car');
21 $this->schema
->add('Car', 'Seats', 5, 'int', false);
23 $this->assertIdentical($this->schema
->defaults
['Car']['Seats'], 5);
24 $this->assertIdentical($this->schema
->info
['Car']['Seats'],
25 new HTMLPurifier_ConfigDef_Directive('int')
28 $this->schema
->add('Car', 'Age', null, 'int', true);
30 $this->assertIdentical($this->schema
->defaults
['Car']['Age'], null);
31 $this->assertIdentical($this->schema
->info
['Car']['Age'],
32 new HTMLPurifier_ConfigDef_Directive('int', true)
37 function test_defineAllowedValues() {
38 $this->schema
->addNamespace('QuantumNumber', 'D');
39 $this->schema
->add('QuantumNumber', 'Spin', 0.5, 'float', false);
40 $this->schema
->add('QuantumNumber', 'Current', 's', 'string', false);
41 $this->schema
->add('QuantumNumber', 'Difficulty', null, 'string', true);
43 $this->schema
->addAllowedValues( // okay, since default is null
44 'QuantumNumber', 'Difficulty', array('easy' => true, 'medium' => true, 'hard' => true)
47 $this->assertIdentical($this->schema
->defaults
['QuantumNumber']['Difficulty'], null);
48 $this->assertIdentical($this->schema
->info
['QuantumNumber']['Difficulty'],
49 new HTMLPurifier_ConfigDef_Directive(
62 function test_defineValueAliases() {
63 $this->schema
->addNamespace('Abbrev', 'Stuff on abbreviations.');
64 $this->schema
->add('Abbrev', 'HTH', 'Happy to Help', 'string', false);
65 $this->schema
->addAllowedValues(
66 'Abbrev', 'HTH', array(
67 'Happy to Help' => true,
68 'Hope that Helps' => true,
69 'HAIL THE HAND!' => true,
72 $this->schema
->addValueAliases(
73 'Abbrev', 'HTH', array(
74 'happy' => 'Happy to Help',
75 'hope' => 'Hope that Helps'
78 $this->schema
->addValueAliases( // delayed addition
79 'Abbrev', 'HTH', array(
80 'hail' => 'HAIL THE HAND!'
84 $this->assertIdentical($this->schema
->defaults
['Abbrev']['HTH'], 'Happy to Help');
85 $this->assertIdentical($this->schema
->info
['Abbrev']['HTH'],
86 new HTMLPurifier_ConfigDef_Directive(
90 'Happy to Help' => true,
91 'Hope that Helps' => true,
92 'HAIL THE HAND!' => true
95 'happy' => 'Happy to Help',
96 'hope' => 'Hope that Helps',
97 'hail' => 'HAIL THE HAND!'
104 function testAlias() {
105 $this->schema
->addNamespace('Home');
106 $this->schema
->add('Home', 'Rug', 3, 'int', false);
107 $this->schema
->addAlias('Home', 'Carpet', 'Home', 'Rug');
109 $this->assertTrue(!isset($this->schema
->defaults
['Home']['Carpet']));
110 $this->assertIdentical($this->schema
->info
['Home']['Carpet'],
111 new HTMLPurifier_ConfigDef_DirectiveAlias('Home', 'Rug')