3 class HTMLPurifier_ConfigSchemaTest
extends HTMLPurifier_Harness
8 public function setup() {
9 $this->schema
= new HTMLPurifier_ConfigSchema();
12 function test_define() {
13 $this->schema
->add('Car.Seats', 5, 'int', false);
15 $this->assertIdentical($this->schema
->defaults
['Car.Seats'], 5);
16 $this->assertIdentical($this->schema
->info
['Car.Seats']->type
, HTMLPurifier_VarParser
::INT);
18 $this->schema
->add('Car.Age', null, 'int', true);
20 $this->assertIdentical($this->schema
->defaults
['Car.Age'], null);
21 $this->assertIdentical($this->schema
->info
['Car.Age']->type
, HTMLPurifier_VarParser
::INT);
25 function test_defineAllowedValues() {
26 $this->schema
->add('QuantumNumber.Spin', 0.5, 'float', false);
27 $this->schema
->add('QuantumNumber.Current', 's', 'string', false);
28 $this->schema
->add('QuantumNumber.Difficulty', null, 'string', true);
30 $this->schema
->addAllowedValues( // okay, since default is null
31 'QuantumNumber.Difficulty', array('easy' => true, 'medium' => true, 'hard' => true)
34 $this->assertIdentical($this->schema
->defaults
['QuantumNumber.Difficulty'], null);
35 $this->assertIdentical($this->schema
->info
['QuantumNumber.Difficulty']->type
, HTMLPurifier_VarParser
::STRING);
36 $this->assertIdentical($this->schema
->info
['QuantumNumber.Difficulty']->allow_null
, true);
37 $this->assertIdentical($this->schema
->info
['QuantumNumber.Difficulty']->allowed
,
47 function test_defineValueAliases() {
48 $this->schema
->add('Abbrev.HTH', 'Happy to Help', 'string', false);
49 $this->schema
->addAllowedValues(
51 'Happy to Help' => true,
52 'Hope that Helps' => true,
53 'HAIL THE HAND!' => true,
56 $this->schema
->addValueAliases(
58 'happy' => 'Happy to Help',
59 'hope' => 'Hope that Helps'
62 $this->schema
->addValueAliases( // delayed addition
64 'hail' => 'HAIL THE HAND!'
68 $this->assertIdentical($this->schema
->defaults
['Abbrev.HTH'], 'Happy to Help');
69 $this->assertIdentical($this->schema
->info
['Abbrev.HTH']->type
, HTMLPurifier_VarParser
::STRING);
70 $this->assertIdentical($this->schema
->info
['Abbrev.HTH']->allowed
,
72 'Happy to Help' => true,
73 'Hope that Helps' => true,
74 'HAIL THE HAND!' => true
77 $this->assertIdentical($this->schema
->info
['Abbrev.HTH']->aliases
,
79 'happy' => 'Happy to Help',
80 'hope' => 'Hope that Helps',
81 'hail' => 'HAIL THE HAND!'
87 function testAlias() {
88 $this->schema
->add('Home.Rug', 3, 'int', false);
89 $this->schema
->addAlias('Home.Carpet', 'Home.Rug');
91 $this->assertTrue(!isset($this->schema
->defaults
['Home.Carpet']));
92 $this->assertIdentical($this->schema
->info
['Home.Carpet']->key
, 'Home.Rug');
93 $this->assertIdentical($this->schema
->info
['Home.Carpet']->isAlias
, true);