3 class HTMLPurifier_ConfigSchemaTest
extends HTMLPurifier_Harness
8 public function setup()
10 $this->schema
= new HTMLPurifier_ConfigSchema();
13 public function test_define()
15 $this->schema
->add('Car.Seats', 5, 'int', false);
17 $this->assertIdentical($this->schema
->defaults
['Car.Seats'], 5);
18 $this->assertIdentical($this->schema
->info
['Car.Seats']->type
, HTMLPurifier_VarParser
::C_INT
);
20 $this->schema
->add('Car.Age', null, 'int', true);
22 $this->assertIdentical($this->schema
->defaults
['Car.Age'], null);
23 $this->assertIdentical($this->schema
->info
['Car.Age']->type
, HTMLPurifier_VarParser
::C_INT
);
27 public function test_defineAllowedValues()
29 $this->schema
->add('QuantumNumber.Spin', 0.5, 'float', false);
30 $this->schema
->add('QuantumNumber.Current', 's', 'string', false);
31 $this->schema
->add('QuantumNumber.Difficulty', null, 'string', true);
33 $this->schema
->addAllowedValues( // okay, since default is null
34 'QuantumNumber.Difficulty', array('easy' => true, 'medium' => true, 'hard' => true)
37 $this->assertIdentical($this->schema
->defaults
['QuantumNumber.Difficulty'], null);
38 $this->assertIdentical($this->schema
->info
['QuantumNumber.Difficulty']->type
, HTMLPurifier_VarParser
::C_STRING
);
39 $this->assertIdentical($this->schema
->info
['QuantumNumber.Difficulty']->allow_null
, true);
40 $this->assertIdentical($this->schema
->info
['QuantumNumber.Difficulty']->allowed
,
50 public function test_defineValueAliases()
52 $this->schema
->add('Abbrev.HTH', 'Happy to Help', 'string', false);
53 $this->schema
->addAllowedValues(
55 'Happy to Help' => true,
56 'Hope that Helps' => true,
57 'HAIL THE HAND!' => true,
60 $this->schema
->addValueAliases(
62 'happy' => 'Happy to Help',
63 'hope' => 'Hope that Helps'
66 $this->schema
->addValueAliases( // delayed addition
68 'hail' => 'HAIL THE HAND!'
72 $this->assertIdentical($this->schema
->defaults
['Abbrev.HTH'], 'Happy to Help');
73 $this->assertIdentical($this->schema
->info
['Abbrev.HTH']->type
, HTMLPurifier_VarParser
::C_STRING
);
74 $this->assertIdentical($this->schema
->info
['Abbrev.HTH']->allowed
,
76 'Happy to Help' => true,
77 'Hope that Helps' => true,
78 'HAIL THE HAND!' => true
81 $this->assertIdentical($this->schema
->info
['Abbrev.HTH']->aliases
,
83 'happy' => 'Happy to Help',
84 'hope' => 'Hope that Helps',
85 'hail' => 'HAIL THE HAND!'
91 public function testAlias()
93 $this->schema
->add('Home.Rug', 3, 'int', false);
94 $this->schema
->addAlias('Home.Carpet', 'Home.Rug');
96 $this->assertTrue(!isset($this->schema
->defaults
['Home.Carpet']));
97 $this->assertIdentical($this->schema
->info
['Home.Carpet']->key
, 'Home.Rug');
98 $this->assertIdentical($this->schema
->info
['Home.Carpet']->isAlias
, true);
104 // vim: et sw=4 sts=4