Typofix.
[htmlpurifier.git] / tests / HTMLPurifier / StringHashParserTest.php
blob6d357f86ca8fd896f33c8bcc54d2c47b677715c4
1 <?php
3 /**
4 * @note Sample input files are located in the StringHashParser/ directory.
5 */
6 class HTMLPurifier_StringHashParserTest extends UnitTestCase
9 /**
10 * Instance of ConfigSchema_StringHashParser being tested.
12 protected $parser;
14 public function setup() {
15 $this->parser = new HTMLPurifier_StringHashParser();
18 /**
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',
29 'TYPE' => 'string',
30 'CHAIN-ME' => '2',
31 'DESCRIPTION' => "Multiline\nstuff\n",
32 'EMPTY' => '',
33 'FOR-WHO' => "Single multiline\n",
34 ));
37 function testOverrideSingle() {
38 $this->assertParse('OverrideSingle.txt', array(
39 'KEY' => 'New',
40 ));
43 function testAppendMultiline() {
44 $this->assertParse('AppendMultiline.txt', array(
45 'KEY' => "Line1\nLine2\n",
46 ));
49 function testDefault() {
50 $this->parser->default = 'NEW-ID';
51 $this->assertParse('Default.txt', array(
52 'NEW-ID' => 'DefaultValue',
53 ));
56 function testError() {
57 try {
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(
67 $result,
68 array(
69 array(
70 'ID' => 'Namespace.Directive',
71 'TYPE' => 'string',
72 'CHAIN-ME' => '2',
73 'DESCRIPTION' => "Multiline\nstuff\n",
74 'FOR-WHO' => "Single multiline\n",
76 array(
77 'ID' => 'Namespace.Directive2',
78 'TYPE' => 'integer',
79 'CHAIN-ME' => '3',
80 'DESCRIPTION' => "M\nstuff\n",
81 'FOR-WHO' => "Single multiline2\n",
89 // vim: et sw=4 sts=4