diff options
author | friendica <info@friendica.com> | 2012-05-12 17:57:41 -0700 |
---|---|---|
committer | friendica <info@friendica.com> | 2012-07-18 20:40:31 +1000 |
commit | 7a40f4354b32809af3d0cfd6e3af0eda02ab0e0a (patch) | |
tree | a9c3d91209cff770bb4b613b1b95e61a7bbc5a2b /lib/htmlpurifier/tests/HTMLPurifier/ConfigSchemaTest.php | |
parent | cd727cb26b78a1dade09d510b071446898477356 (diff) | |
download | volse-hubzilla-7a40f4354b32809af3d0cfd6e3af0eda02ab0e0a.tar.gz volse-hubzilla-7a40f4354b32809af3d0cfd6e3af0eda02ab0e0a.tar.bz2 volse-hubzilla-7a40f4354b32809af3d0cfd6e3af0eda02ab0e0a.zip |
some important stuff we'll need
Diffstat (limited to 'lib/htmlpurifier/tests/HTMLPurifier/ConfigSchemaTest.php')
-rw-r--r-- | lib/htmlpurifier/tests/HTMLPurifier/ConfigSchemaTest.php | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchemaTest.php b/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchemaTest.php new file mode 100644 index 000000000..dc3bf99eb --- /dev/null +++ b/lib/htmlpurifier/tests/HTMLPurifier/ConfigSchemaTest.php @@ -0,0 +1,99 @@ +<?php + +class HTMLPurifier_ConfigSchemaTest extends HTMLPurifier_Harness +{ + + protected $schema; + + public function setup() { + $this->schema = new HTMLPurifier_ConfigSchema(); + } + + function test_define() { + $this->schema->add('Car.Seats', 5, 'int', false); + + $this->assertIdentical($this->schema->defaults['Car.Seats'], 5); + $this->assertIdentical($this->schema->info['Car.Seats']->type, HTMLPurifier_VarParser::INT); + + $this->schema->add('Car.Age', null, 'int', true); + + $this->assertIdentical($this->schema->defaults['Car.Age'], null); + $this->assertIdentical($this->schema->info['Car.Age']->type, HTMLPurifier_VarParser::INT); + + } + + function test_defineAllowedValues() { + $this->schema->add('QuantumNumber.Spin', 0.5, 'float', false); + $this->schema->add('QuantumNumber.Current', 's', 'string', false); + $this->schema->add('QuantumNumber.Difficulty', null, 'string', true); + + $this->schema->addAllowedValues( // okay, since default is null + 'QuantumNumber.Difficulty', array('easy' => true, 'medium' => true, 'hard' => true) + ); + + $this->assertIdentical($this->schema->defaults['QuantumNumber.Difficulty'], null); + $this->assertIdentical($this->schema->info['QuantumNumber.Difficulty']->type, HTMLPurifier_VarParser::STRING); + $this->assertIdentical($this->schema->info['QuantumNumber.Difficulty']->allow_null, true); + $this->assertIdentical($this->schema->info['QuantumNumber.Difficulty']->allowed, + array( + 'easy' => true, + 'medium' => true, + 'hard' => true + ) + ); + + } + + function test_defineValueAliases() { + $this->schema->add('Abbrev.HTH', 'Happy to Help', 'string', false); + $this->schema->addAllowedValues( + 'Abbrev.HTH', array( + 'Happy to Help' => true, + 'Hope that Helps' => true, + 'HAIL THE HAND!' => true, + ) + ); + $this->schema->addValueAliases( + 'Abbrev.HTH', array( + 'happy' => 'Happy to Help', + 'hope' => 'Hope that Helps' + ) + ); + $this->schema->addValueAliases( // delayed addition + 'Abbrev.HTH', array( + 'hail' => 'HAIL THE HAND!' + ) + ); + + $this->assertIdentical($this->schema->defaults['Abbrev.HTH'], 'Happy to Help'); + $this->assertIdentical($this->schema->info['Abbrev.HTH']->type, HTMLPurifier_VarParser::STRING); + $this->assertIdentical($this->schema->info['Abbrev.HTH']->allowed, + array( + 'Happy to Help' => true, + 'Hope that Helps' => true, + 'HAIL THE HAND!' => true + ) + ); + $this->assertIdentical($this->schema->info['Abbrev.HTH']->aliases, + array( + 'happy' => 'Happy to Help', + 'hope' => 'Hope that Helps', + 'hail' => 'HAIL THE HAND!' + ) + ); + + } + + function testAlias() { + $this->schema->add('Home.Rug', 3, 'int', false); + $this->schema->addAlias('Home.Carpet', 'Home.Rug'); + + $this->assertTrue(!isset($this->schema->defaults['Home.Carpet'])); + $this->assertIdentical($this->schema->info['Home.Carpet']->key, 'Home.Rug'); + $this->assertIdentical($this->schema->info['Home.Carpet']->isAlias, true); + + } + +} + +// vim: et sw=4 sts=4 |