1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-11 00:24:03 +02:00

[3.1.0] Make StringHash system-agnostic.

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1621 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2008-03-22 19:30:37 +00:00
parent ec59062a9d
commit 56cfcba5d1
11 changed files with 12 additions and 63 deletions

View File

@@ -1,4 +0,0 @@
--KEY--
Line1
--KEY--
Line2

View File

@@ -1 +0,0 @@
DefaultValue

View File

@@ -1,2 +0,0 @@
KEY: Original
KEY: New

View File

@@ -1,8 +0,0 @@
Namespace.Directive
TYPE: string
CHAIN-ME: 2
--DESCRIPTION--
Multiline
stuff
--FOR-WHO--
Single multiline

View File

@@ -1,63 +0,0 @@
<?php
/**
* @note Sample input files are located in the StringHashParser/ directory.
*/
class HTMLPurifier_ConfigSchema_StringHashParserTest extends UnitTestCase
{
/**
* Instance of ConfigSchema_StringHashParser being tested.
*/
protected $parser;
function setup() {
$this->parser = new HTMLPurifier_ConfigSchema_StringHashParser();
}
/**
* Assert that $file gets parsed into the form of $expect
*/
function assertParse($file, $expect) {
$result = $this->parser->parseFile(dirname(__FILE__) . '/StringHashParser/' . $file);
$this->assertIdentical($result, $expect);
}
function testSimple() {
$this->assertParse('Simple.txt', array(
'ID' => 'Namespace.Directive',
'TYPE' => 'string',
'CHAIN-ME' => '2',
'DESCRIPTION' => "Multiline\nstuff\n",
'FOR-WHO' => "Single multiline\n",
));
}
function testOverrideSingle() {
$this->assertParse('OverrideSingle.txt', array(
'KEY' => 'New',
));
}
function testAppendMultiline() {
$this->assertParse('AppendMultiline.txt', array(
'KEY' => "Line1\nLine2\n",
));
}
function testDefault() {
$this->parser->default = 'NEW-ID';
$this->assertParse('Default.txt', array(
'NEW-ID' => 'DefaultValue',
));
}
function testError() {
try {
$this->parser->parseFile('NoExist.txt');
} catch (HTMLPurifier_ConfigSchema_Exception $e) {
$this->assertIdentical($e->getMessage(), 'File NoExist.txt does not exist');
}
}
}

View File

@@ -1,18 +0,0 @@
<?php
class HTMLPurifier_ConfigSchema_StringHashTest extends UnitTestCase
{
public function testUsed() {
$hash = new HTMLPurifier_ConfigSchema_StringHash(array(
'key' => 'value',
'key2' => 'value2'
));
$this->assertIdentical($hash->getAccessed(), array());
$t = $hash->offsetGet('key');
$this->assertIdentical($hash->getAccessed(), array('key' => true));
$hash->resetAccessed();
$this->assertIdentical($hash->getAccessed(), array());
}
}