4 * @note Sample input files are located in the StringHashParser/ directory.
6 class HTMLPurifier_StringHashParserTest
extends UnitTestCase
10 * Instance of ConfigSchema_StringHashParser being tested.
14 public function setup() {
15 $this->parser
= new HTMLPurifier_StringHashParser();
19 * Assert that $file gets parsed into the form of $expect
21 protected function assertParse($file, $expect) {
22 $result = $this->parser
->parseFile(dirname(__FILE__
) . '/StringHashParser/' . $file);
23 $this->assertIdentical($result, $expect);
26 function testSimple() {
27 $this->assertParse('Simple.txt', array(
28 'ID' => 'Namespace.Directive',
31 'DESCRIPTION' => "Multiline\nstuff\n",
33 'FOR-WHO' => "Single multiline\n",
37 function testOverrideSingle() {
38 $this->assertParse('OverrideSingle.txt', array(
43 function testAppendMultiline() {
44 $this->assertParse('AppendMultiline.txt', array(
45 'KEY' => "Line1\nLine2\n",
49 function testDefault() {
50 $this->parser
->default = 'NEW-ID';
51 $this->assertParse('Default.txt', array(
52 'NEW-ID' => 'DefaultValue',
56 function testError() {
58 $this->parser
->parseFile('NoExist.txt');
59 } catch (HTMLPurifier_ConfigSchema_Exception
$e) {
60 $this->assertIdentical($e->getMessage(), 'File NoExist.txt does not exist');
64 function testParseMultiple() {
65 $result = $this->parser
->parseMultiFile(dirname(__FILE__
) . '/StringHashParser/Multi.txt');
66 $this->assertIdentical(
70 'ID' => 'Namespace.Directive',
73 'DESCRIPTION' => "Multiline\nstuff\n",
74 'FOR-WHO' => "Single multiline\n",
77 'ID' => 'Namespace.Directive2',
80 'DESCRIPTION' => "M\nstuff\n",
81 'FOR-WHO' => "Single multiline2\n",