2006-08-11 20:23:41 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once 'HTMLPurifier/Config.php';
|
|
|
|
|
2007-01-21 04:37:02 +00:00
|
|
|
if (!class_exists('CS')) {
|
|
|
|
class CS extends HTMLPurifier_ConfigSchema {}
|
|
|
|
}
|
|
|
|
|
2006-08-11 20:23:41 +00:00
|
|
|
class HTMLPurifier_ConfigTest extends UnitTestCase
|
|
|
|
{
|
|
|
|
|
2006-08-27 18:49:16 +00:00
|
|
|
var $our_copy, $old_copy;
|
|
|
|
|
|
|
|
function setUp() {
|
2006-09-30 18:55:17 +00:00
|
|
|
// set up a dummy schema object for testing
|
2006-09-16 22:36:58 +00:00
|
|
|
$our_copy = new HTMLPurifier_ConfigSchema();
|
|
|
|
$this->old_copy = HTMLPurifier_ConfigSchema::instance();
|
|
|
|
$this->our_copy =& HTMLPurifier_ConfigSchema::instance($our_copy);
|
2006-08-27 18:49:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function tearDown() {
|
2006-09-16 22:36:58 +00:00
|
|
|
HTMLPurifier_ConfigSchema::instance($this->old_copy);
|
2007-02-17 19:37:48 +00:00
|
|
|
tally_errors($this);
|
2006-08-27 18:49:16 +00:00
|
|
|
}
|
|
|
|
|
2007-01-21 04:37:02 +00:00
|
|
|
// test functionality based on ConfigSchema
|
|
|
|
|
|
|
|
function testNormal() {
|
|
|
|
CS::defineNamespace('Element', 'Chemical substances that cannot be further decomposed');
|
|
|
|
|
|
|
|
CS::define('Element', 'Abbr', 'H', 'string', 'Abbreviation of element name.');
|
|
|
|
CS::define('Element', 'Name', 'hydrogen', 'istring', 'Full name of atoms.');
|
|
|
|
CS::define('Element', 'Number', 1, 'int', 'Atomic number, is identity.');
|
|
|
|
CS::define('Element', 'Mass', 1.00794, 'float', 'Atomic mass.');
|
|
|
|
CS::define('Element', 'Radioactive', false, 'bool', 'Does it have rapid decay?');
|
|
|
|
CS::define('Element', 'Isotopes', array(1 => true, 2 => true, 3 => true), 'lookup',
|
|
|
|
'What numbers of neutrons for this element have been observed?');
|
|
|
|
CS::define('Element', 'Traits', array('nonmetallic', 'odorless', 'flammable'), 'list',
|
|
|
|
'What are general properties of the element?');
|
|
|
|
CS::define('Element', 'IsotopeNames', array(1 => 'protium', 2 => 'deuterium', 3 => 'tritium'), 'hash',
|
|
|
|
'Lookup hash of neutron counts to formal names.');
|
|
|
|
CS::define('Element', 'Object', new stdClass(), 'mixed', 'Model representation.');
|
2006-08-11 20:23:41 +00:00
|
|
|
|
2007-01-21 04:37:02 +00:00
|
|
|
$config = HTMLPurifier_Config::createDefault();
|
2007-05-20 18:06:51 +00:00
|
|
|
$config->autoFinalize = false;
|
2006-08-27 18:49:16 +00:00
|
|
|
|
2007-01-21 04:37:02 +00:00
|
|
|
// test default value retrieval
|
|
|
|
$this->assertIdentical($config->get('Element', 'Abbr'), 'H');
|
|
|
|
$this->assertIdentical($config->get('Element', 'Name'), 'hydrogen');
|
|
|
|
$this->assertIdentical($config->get('Element', 'Number'), 1);
|
|
|
|
$this->assertIdentical($config->get('Element', 'Mass'), 1.00794);
|
|
|
|
$this->assertIdentical($config->get('Element', 'Radioactive'), false);
|
|
|
|
$this->assertIdentical($config->get('Element', 'Isotopes'), array(1 => true, 2 => true, 3 => true));
|
|
|
|
$this->assertIdentical($config->get('Element', 'Traits'), array('nonmetallic', 'odorless', 'flammable'));
|
|
|
|
$this->assertIdentical($config->get('Element', 'IsotopeNames'), array(1 => 'protium', 2 => 'deuterium', 3 => 'tritium'));
|
|
|
|
$this->assertIdentical($config->get('Element', 'Object'), new stdClass());
|
|
|
|
|
|
|
|
// test setting values
|
|
|
|
$config->set('Element', 'Abbr', 'Pu');
|
|
|
|
$config->set('Element', 'Name', 'PLUTONIUM'); // test decaps
|
|
|
|
$config->set('Element', 'Number', '94'); // test parsing
|
|
|
|
$config->set('Element', 'Mass', '244.'); // test parsing
|
|
|
|
$config->set('Element', 'Radioactive', true);
|
|
|
|
$config->set('Element', 'Isotopes', array(238, 239)); // test inversion
|
|
|
|
$config->set('Element', 'Traits', 'nuclear, heavy, actinide'); // test parsing
|
|
|
|
$config->set('Element', 'IsotopeNames', array(238 => 'Plutonium-238', 239 => 'Plutonium-239'));
|
|
|
|
$config->set('Element', 'Object', false); // unmodeled
|
|
|
|
|
2007-06-16 20:21:00 +00:00
|
|
|
$this->expectError('Cannot set undefined directive Element.Metal to value');
|
2007-05-20 18:06:51 +00:00
|
|
|
$config->set('Element', 'Metal', true);
|
|
|
|
|
2007-06-16 20:21:00 +00:00
|
|
|
$this->expectError('Value for Element.Radioactive is of invalid type, should be bool');
|
2007-05-20 18:06:51 +00:00
|
|
|
$config->set('Element', 'Radioactive', 'very');
|
|
|
|
|
2007-01-21 04:37:02 +00:00
|
|
|
// test value retrieval
|
|
|
|
$this->assertIdentical($config->get('Element', 'Abbr'), 'Pu');
|
|
|
|
$this->assertIdentical($config->get('Element', 'Name'), 'plutonium');
|
|
|
|
$this->assertIdentical($config->get('Element', 'Number'), 94);
|
|
|
|
$this->assertIdentical($config->get('Element', 'Mass'), 244.);
|
|
|
|
$this->assertIdentical($config->get('Element', 'Radioactive'), true);
|
|
|
|
$this->assertIdentical($config->get('Element', 'Isotopes'), array(238 => true, 239 => true));
|
|
|
|
$this->assertIdentical($config->get('Element', 'Traits'), array('nuclear', 'heavy', 'actinide'));
|
|
|
|
$this->assertIdentical($config->get('Element', 'IsotopeNames'), array(238 => 'Plutonium-238', 239 => 'Plutonium-239'));
|
|
|
|
$this->assertIdentical($config->get('Element', 'Object'), false);
|
|
|
|
|
2007-06-16 20:21:00 +00:00
|
|
|
$this->expectError('Cannot retrieve value of undefined directive Element.Metal');
|
2007-01-21 04:37:02 +00:00
|
|
|
$config->get('Element', 'Metal');
|
2006-11-12 03:35:41 +00:00
|
|
|
|
2007-01-21 04:37:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testEnumerated() {
|
2006-08-11 20:23:41 +00:00
|
|
|
|
2007-01-21 04:37:02 +00:00
|
|
|
CS::defineNamespace('Instrument', 'Of the musical type.');
|
2006-08-11 20:23:41 +00:00
|
|
|
|
2007-01-21 04:37:02 +00:00
|
|
|
// case sensitive
|
|
|
|
CS::define('Instrument', 'Manufacturer', 'Yamaha', 'string', 'Who made it?');
|
|
|
|
CS::defineAllowedValues('Instrument', 'Manufacturer', array(
|
|
|
|
'Yamaha', 'Conn-Selmer', 'Vandoren', 'Laubin', 'Buffet', 'other'));
|
|
|
|
CS::defineValueAliases('Instrument', 'Manufacturer', array(
|
|
|
|
'Selmer' => 'Conn-Selmer'));
|
2006-08-11 20:23:41 +00:00
|
|
|
|
2007-01-21 04:37:02 +00:00
|
|
|
// case insensitive
|
|
|
|
CS::define('Instrument', 'Family', 'woodwind', 'istring', 'What family is it?');
|
|
|
|
CS::defineAllowedValues('Instrument', 'Family', array(
|
|
|
|
'brass', 'woodwind', 'percussion', 'string', 'keyboard', 'electronic'));
|
|
|
|
CS::defineValueAliases('Instrument', 'Family', array(
|
|
|
|
'synth' => 'electronic'));
|
|
|
|
|
|
|
|
$config = HTMLPurifier_Config::createDefault();
|
2007-05-20 18:06:51 +00:00
|
|
|
$config->autoFinalize = false;
|
2007-01-21 04:37:02 +00:00
|
|
|
|
|
|
|
// case sensitive
|
|
|
|
|
|
|
|
$config->set('Instrument', 'Manufacturer', 'Vandoren');
|
|
|
|
$this->assertIdentical($config->get('Instrument', 'Manufacturer'), 'Vandoren');
|
|
|
|
|
|
|
|
$config->set('Instrument', 'Manufacturer', 'Selmer');
|
|
|
|
$this->assertIdentical($config->get('Instrument', 'Manufacturer'), 'Conn-Selmer');
|
2006-08-11 20:23:41 +00:00
|
|
|
|
2007-06-16 20:21:00 +00:00
|
|
|
$this->expectError('Value not supported, valid values are: Yamaha, Conn-Selmer, Vandoren, Laubin, Buffet, other');
|
2007-01-21 04:37:02 +00:00
|
|
|
$config->set('Instrument', 'Manufacturer', 'buffet');
|
2006-08-27 18:49:16 +00:00
|
|
|
|
2007-01-21 04:37:02 +00:00
|
|
|
// case insensitive
|
|
|
|
|
|
|
|
$config->set('Instrument', 'Family', 'brass');
|
|
|
|
$this->assertIdentical($config->get('Instrument', 'Family'), 'brass');
|
|
|
|
|
|
|
|
$config->set('Instrument', 'Family', 'PERCUSSION');
|
|
|
|
$this->assertIdentical($config->get('Instrument', 'Family'), 'percussion');
|
|
|
|
|
|
|
|
$config->set('Instrument', 'Family', 'synth');
|
|
|
|
$this->assertIdentical($config->get('Instrument', 'Family'), 'electronic');
|
|
|
|
|
|
|
|
$config->set('Instrument', 'Family', 'Synth');
|
|
|
|
$this->assertIdentical($config->get('Instrument', 'Family'), 'electronic');
|
2006-08-27 18:49:16 +00:00
|
|
|
|
2007-01-21 04:37:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testNull() {
|
2006-08-27 18:49:16 +00:00
|
|
|
|
2007-01-21 04:37:02 +00:00
|
|
|
CS::defineNamespace('ReportCard', 'It is for grades.');
|
|
|
|
CS::define('ReportCard', 'English', null, 'string/null', 'Grade from English class.');
|
|
|
|
CS::define('ReportCard', 'Absences', 0, 'int', 'How many times missing from school?');
|
2006-09-01 16:40:14 +00:00
|
|
|
|
2007-01-21 04:37:02 +00:00
|
|
|
$config = HTMLPurifier_Config::createDefault();
|
2007-05-20 18:06:51 +00:00
|
|
|
$config->autoFinalize = false;
|
2006-11-12 03:35:41 +00:00
|
|
|
|
2007-01-21 04:37:02 +00:00
|
|
|
$config->set('ReportCard', 'English', 'B-');
|
|
|
|
$this->assertIdentical($config->get('ReportCard', 'English'), 'B-');
|
2006-11-12 03:35:41 +00:00
|
|
|
|
2007-01-21 04:37:02 +00:00
|
|
|
$config->set('ReportCard', 'English', null); // not yet graded
|
|
|
|
$this->assertIdentical($config->get('ReportCard', 'English'), null);
|
|
|
|
|
|
|
|
// error
|
2007-06-16 20:21:00 +00:00
|
|
|
$this->expectError('Value for ReportCard.Absences is of invalid type, should be int');
|
2007-01-21 04:37:02 +00:00
|
|
|
$config->set('ReportCard', 'Absences', null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function testAliases() {
|
|
|
|
|
2007-05-20 18:06:51 +00:00
|
|
|
CS::defineNamespace('Home', 'Sweet home.');
|
|
|
|
CS::define('Home', 'Rug', 3, 'int', 'ID.');
|
|
|
|
CS::defineAlias('Home', 'Carpet', 'Home', 'Rug');
|
2007-01-21 04:37:02 +00:00
|
|
|
|
|
|
|
$config = HTMLPurifier_Config::createDefault();
|
2007-05-20 18:06:51 +00:00
|
|
|
$config->autoFinalize = false;
|
2007-01-21 04:37:02 +00:00
|
|
|
|
2007-05-05 20:17:04 +00:00
|
|
|
$this->assertIdentical($config->get('Home', 'Rug'), 3);
|
2007-01-21 04:37:02 +00:00
|
|
|
|
2007-06-16 20:21:00 +00:00
|
|
|
$this->expectError('Cannot get value from aliased directive, use real name Home.Rug');
|
2007-01-21 04:37:02 +00:00
|
|
|
$config->get('Home', 'Carpet');
|
|
|
|
|
|
|
|
$config->set('Home', 'Carpet', 999);
|
2007-05-05 20:17:04 +00:00
|
|
|
$this->assertIdentical($config->get('Home', 'Rug'), 999);
|
2007-01-21 04:37:02 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// test functionality based on method
|
|
|
|
|
|
|
|
function test_getBatch() {
|
|
|
|
|
|
|
|
CS::defineNamespace('Variables', 'Changing quantities in equation.');
|
|
|
|
CS::define('Variables', 'TangentialAcceleration', 'a_tan', 'string', 'In m/s^2');
|
|
|
|
CS::define('Variables', 'AngularAcceleration', 'alpha', 'string', 'In rad/s^2');
|
|
|
|
|
|
|
|
$config = HTMLPurifier_Config::createDefault();
|
2007-05-20 18:06:51 +00:00
|
|
|
$config->autoFinalize = false;
|
2006-11-12 03:35:41 +00:00
|
|
|
|
2006-11-24 07:12:16 +00:00
|
|
|
// grab a namespace
|
|
|
|
$this->assertIdentical(
|
2007-01-21 04:37:02 +00:00
|
|
|
$config->getBatch('Variables'),
|
2006-11-24 07:12:16 +00:00
|
|
|
array(
|
2007-01-21 04:37:02 +00:00
|
|
|
'TangentialAcceleration' => 'a_tan',
|
|
|
|
'AngularAcceleration' => 'alpha'
|
2006-11-24 07:12:16 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
// grab a non-existant namespace
|
2007-06-16 20:21:00 +00:00
|
|
|
$this->expectError('Cannot retrieve undefined namespace Constants');
|
2007-01-21 04:37:02 +00:00
|
|
|
$config->getBatch('Constants');
|
2006-11-24 07:12:16 +00:00
|
|
|
|
2006-08-11 20:23:41 +00:00
|
|
|
}
|
|
|
|
|
2007-01-21 14:29:46 +00:00
|
|
|
function test_loadIni() {
|
|
|
|
|
|
|
|
CS::defineNamespace('Shortcut', 'Keyboard shortcuts for commands');
|
|
|
|
CS::define('Shortcut', 'Copy', 'c', 'istring', 'Copy text');
|
|
|
|
CS::define('Shortcut', 'Paste', 'v', 'istring', 'Paste clipboard');
|
|
|
|
CS::define('Shortcut', 'Cut', 'x', 'istring', 'Cut text');
|
|
|
|
|
|
|
|
$config = HTMLPurifier_Config::createDefault();
|
2007-05-20 18:06:51 +00:00
|
|
|
$config->autoFinalize = false;
|
2007-01-21 14:29:46 +00:00
|
|
|
|
|
|
|
$config->loadIni(dirname(__FILE__) . '/ConfigTest-loadIni.ini');
|
|
|
|
|
|
|
|
$this->assertIdentical($config->get('Shortcut', 'Copy'), 'q');
|
|
|
|
$this->assertIdentical($config->get('Shortcut', 'Paste'), 'p');
|
|
|
|
$this->assertIdentical($config->get('Shortcut', 'Cut'), 't');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-02-14 01:44:06 +00:00
|
|
|
function test_getHTMLDefinition() {
|
2006-09-30 18:55:17 +00:00
|
|
|
|
2006-11-16 23:58:33 +00:00
|
|
|
// we actually want to use the old copy, because the definition
|
|
|
|
// generation routines have dependencies on configuration values
|
|
|
|
|
|
|
|
$this->old_copy = HTMLPurifier_ConfigSchema::instance($this->old_copy);
|
|
|
|
|
2006-09-30 18:55:17 +00:00
|
|
|
$config = HTMLPurifier_Config::createDefault();
|
2007-05-24 21:50:43 +00:00
|
|
|
$config->set('HTML', 'Doctype', 'XHTML 1.0 Strict');
|
2007-05-20 18:06:51 +00:00
|
|
|
$config->autoFinalize = false;
|
2007-02-14 01:44:06 +00:00
|
|
|
|
|
|
|
$def = $config->getCSSDefinition();
|
|
|
|
$this->assertIsA($def, 'HTMLPurifier_CSSDefinition');
|
|
|
|
|
2007-05-24 21:50:43 +00:00
|
|
|
$def =& $config->getHTMLDefinition();
|
|
|
|
$def2 =& $config->getHTMLDefinition();
|
2006-09-30 18:55:17 +00:00
|
|
|
$this->assertIsA($def, 'HTMLPurifier_HTMLDefinition');
|
2007-05-24 21:50:43 +00:00
|
|
|
$this->assertReference($def, $def2);
|
2007-02-14 01:44:06 +00:00
|
|
|
$this->assertTrue($def->setup);
|
|
|
|
|
|
|
|
// test re-calculation if HTML changes
|
2007-05-24 21:50:43 +00:00
|
|
|
unset($def, $def2);
|
|
|
|
$def2 = $config->getHTMLDefinition(); // forcibly de-reference
|
|
|
|
|
|
|
|
$config->set('HTML', 'Doctype', 'HTML 4.01 Transitional');
|
2007-02-14 01:44:06 +00:00
|
|
|
$def = $config->getHTMLDefinition();
|
|
|
|
$this->assertIsA($def, 'HTMLPurifier_HTMLDefinition');
|
|
|
|
$this->assertNotEqual($def, $def2);
|
|
|
|
$this->assertTrue($def->setup);
|
|
|
|
|
|
|
|
// test retrieval of raw definition
|
2007-06-16 20:21:00 +00:00
|
|
|
$config->set('HTML', 'DefinitionID', 'HTMLPurifier_ConfigTest->test_getHTMLDefinition()');
|
2007-06-23 14:05:09 +00:00
|
|
|
$config->set('HTML', 'DefinitionRev', 3);
|
2007-02-14 01:44:06 +00:00
|
|
|
$def =& $config->getHTMLDefinition(true);
|
|
|
|
$this->assertNotEqual($def, $def2);
|
2007-06-23 14:05:09 +00:00
|
|
|
$this->assertEqual(false, $def->setup);
|
2007-02-14 01:44:06 +00:00
|
|
|
|
|
|
|
// auto initialization
|
|
|
|
$config->getHTMLDefinition();
|
|
|
|
$this->assertTrue($def->setup);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-06-16 20:21:00 +00:00
|
|
|
function test_getHTMLDefinition_rawError() {
|
|
|
|
$this->old_copy = HTMLPurifier_ConfigSchema::instance($this->old_copy);
|
|
|
|
$config = HTMLPurifier_Config::createDefault();
|
|
|
|
$this->expectError('Cannot retrieve raw version without specifying %HTML.DefinitionID');
|
|
|
|
$def =& $config->getHTMLDefinition(true);
|
|
|
|
}
|
|
|
|
|
2007-02-14 01:44:06 +00:00
|
|
|
function test_getCSSDefinition() {
|
2007-05-25 01:32:29 +00:00
|
|
|
$this->old_copy = HTMLPurifier_ConfigSchema::instance($this->old_copy);
|
2007-02-14 01:44:06 +00:00
|
|
|
$config = HTMLPurifier_Config::createDefault();
|
2006-09-30 18:55:17 +00:00
|
|
|
$def = $config->getCSSDefinition();
|
|
|
|
$this->assertIsA($def, 'HTMLPurifier_CSSDefinition');
|
|
|
|
}
|
|
|
|
|
2007-06-16 20:21:00 +00:00
|
|
|
function test_getDefinition() {
|
2007-06-24 20:29:50 +00:00
|
|
|
CS::defineNamespace('Cache', 'Cache stuff');
|
|
|
|
CS::define('Cache', 'DefinitionImpl', null, 'string/null', 'Cache?');
|
2007-06-16 20:21:00 +00:00
|
|
|
CS::defineNamespace('Crust', 'Krusty Krabs');
|
|
|
|
$config = HTMLPurifier_Config::createDefault();
|
|
|
|
$this->expectError("Definition of Crust type not supported");
|
|
|
|
$config->getDefinition('Crust');
|
|
|
|
}
|
|
|
|
|
2006-10-21 18:18:36 +00:00
|
|
|
function test_loadArray() {
|
|
|
|
// setup a few dummy namespaces/directives for our testing
|
2007-05-20 18:06:51 +00:00
|
|
|
CS::defineNamespace('Zoo', 'Animals we have.');
|
|
|
|
CS::define('Zoo', 'Aadvark', 0, 'int', 'Have?');
|
|
|
|
CS::define('Zoo', 'Boar', 0, 'int', 'Have?');
|
|
|
|
CS::define('Zoo', 'Camel', 0, 'int', 'Have?');
|
|
|
|
CS::define(
|
2006-10-21 18:18:36 +00:00
|
|
|
'Zoo', 'Others', array(), 'list', 'Other animals we have one of.'
|
|
|
|
);
|
|
|
|
|
2007-01-21 04:37:02 +00:00
|
|
|
$config_manual = HTMLPurifier_Config::createDefault();
|
2006-10-21 18:18:36 +00:00
|
|
|
$config_loadabbr = HTMLPurifier_Config::createDefault();
|
|
|
|
$config_loadfull = HTMLPurifier_Config::createDefault();
|
|
|
|
|
|
|
|
$config_manual->set('Zoo', 'Aadvark', 3);
|
|
|
|
$config_manual->set('Zoo', 'Boar', 5);
|
|
|
|
$config_manual->set('Zoo', 'Camel', 2000); // that's a lotta camels!
|
|
|
|
$config_manual->set('Zoo', 'Others', array('Peacock', 'Dodo')); // wtf!
|
|
|
|
|
|
|
|
// condensed form
|
|
|
|
$config_loadabbr->loadArray(array(
|
|
|
|
'Zoo.Aadvark' => 3,
|
|
|
|
'Zoo.Boar' => 5,
|
|
|
|
'Zoo.Camel' => 2000,
|
|
|
|
'Zoo.Others' => array('Peacock', 'Dodo')
|
|
|
|
));
|
|
|
|
|
|
|
|
// fully expanded form
|
|
|
|
$config_loadfull->loadArray(array(
|
|
|
|
'Zoo' => array(
|
|
|
|
'Aadvark' => 3,
|
|
|
|
'Boar' => 5,
|
|
|
|
'Camel' => 2000,
|
|
|
|
'Others' => array('Peacock', 'Dodo')
|
|
|
|
)
|
|
|
|
));
|
|
|
|
|
2007-05-05 20:17:04 +00:00
|
|
|
$this->assertIdentical($config_manual, $config_loadabbr);
|
|
|
|
$this->assertIdentical($config_manual, $config_loadfull);
|
2006-10-21 18:18:36 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2006-12-15 02:12:03 +00:00
|
|
|
function test_create() {
|
|
|
|
|
2007-05-20 18:06:51 +00:00
|
|
|
CS::defineNamespace('Cake', 'Properties of it.');
|
|
|
|
CS::define('Cake', 'Sprinkles', 666, 'int', 'Number of.');
|
|
|
|
CS::define('Cake', 'Flavor', 'vanilla', 'string', 'Flavor of the batter.');
|
2006-12-15 02:12:03 +00:00
|
|
|
|
|
|
|
$config = HTMLPurifier_Config::createDefault();
|
|
|
|
$config->set('Cake', 'Sprinkles', 42);
|
|
|
|
|
|
|
|
// test flat pass-through
|
|
|
|
$created_config = HTMLPurifier_Config::create($config);
|
2007-05-05 20:17:04 +00:00
|
|
|
$this->assertIdentical($config, $created_config);
|
2006-12-15 02:12:03 +00:00
|
|
|
|
|
|
|
// test loadArray
|
|
|
|
$created_config = HTMLPurifier_Config::create(array('Cake.Sprinkles' => 42));
|
2007-05-05 20:17:04 +00:00
|
|
|
$this->assertIdentical($config, $created_config);
|
2006-12-15 02:12:03 +00:00
|
|
|
|
2007-01-21 14:29:46 +00:00
|
|
|
// test loadIni
|
|
|
|
$created_config = HTMLPurifier_Config::create(dirname(__FILE__) . '/ConfigTest-create.ini');
|
2007-05-05 20:17:04 +00:00
|
|
|
$this->assertIdentical($config, $created_config);
|
2007-01-21 14:29:46 +00:00
|
|
|
|
2006-12-15 02:12:03 +00:00
|
|
|
}
|
|
|
|
|
2007-05-20 18:06:51 +00:00
|
|
|
function test_finalize() {
|
|
|
|
|
|
|
|
// test finalization
|
|
|
|
|
|
|
|
CS::defineNamespace('Poem', 'Violets are red, roses are blue...');
|
|
|
|
CS::define('Poem', 'Meter', 'iambic', 'string', 'Rhythm of poem.');
|
|
|
|
|
|
|
|
$config = HTMLPurifier_Config::createDefault();
|
|
|
|
$config->autoFinalize = false;
|
|
|
|
|
|
|
|
$config->set('Poem', 'Meter', 'irregular');
|
|
|
|
|
|
|
|
$config->finalize();
|
|
|
|
|
|
|
|
$this->expectError('Cannot set directive after finalization');
|
|
|
|
$config->set('Poem', 'Meter', 'vedic');
|
|
|
|
|
|
|
|
$this->expectError('Cannot load directives after finalization');
|
|
|
|
$config->loadArray(array('Poem.Meter' => 'octosyllable'));
|
|
|
|
|
|
|
|
$this->expectError('Cannot load directives after finalization');
|
|
|
|
$config->loadIni(dirname(__FILE__) . '/ConfigTest-finalize.ini');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2006-08-11 20:23:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|