0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-12-23 08:51:53 +00:00
htmlpurifier/tests/ConfigSchema/StringHashAdapterTest.php
Edward Z. Yang 2135597553 - Implement StringHash wrapper ArrayObject
- Implement namespace parsing for StringHashAdapter, as well as rudimentary error-checking

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1529 48356398-32a2-884e-a903-53898d9a118a
2008-02-05 01:54:20 +00:00

56 lines
1.5 KiB
PHP

<?php
class ConfigSchema_StringHashAdapterTest extends UnitTestCase
{
function __construct() {
generate_mock_once('HTMLPurifier_ConfigSchema');
parent::UnitTestCase();
}
function assertAdapt($input, $calls = array()) {
$schema = new HTMLPurifier_ConfigSchemaMock();
foreach ($calls as $func => $params) {
$schema->expectOnce($func, $params);
}
$adapter = new ConfigSchema_StringHashAdapter();
$adapter->adapt($input, $schema);
}
function testBasic() {
$this->assertAdapt(
array(
'ID' => 'Namespace.Directive',
'DEFAULT' => "'default' . 'bar'",
'TYPE' => 'string',
'DESCRIPTION' => "Description of default.\n",
),
array(
'add' => array(
'Namespace', 'Directive', 'defaultbar', 'string',
"Description of default.\n"
)
)
);
}
function testNamespace() {
$this->assertAdapt(
array(
'ID' => 'Namespace',
'DESCRIPTION' => 'Description of namespace'
),
array(
'addNamespace' => array('Namespace', 'Description of namespace'),
)
);
}
function testMissingId() {
$this->expectError('Missing key ID in string hash');
$this->assertAdapt(array());
}
}