Whoops, forgot to edit WHATSNEW
[htmlpurifier.git] / tests / HTMLPurifier / StringHashParserTest.php
blob2ccaec22a44eaf27fcb4cd621eec291a7eb4dfdc
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()
16 $this->parser = new HTMLPurifier_StringHashParser();
19 /**
20 * Assert that $file gets parsed into the form of $expect
22 protected function assertParse($file, $expect)
24 $result = $this->parser->parseFile(dirname(__FILE__) . '/StringHashParser/' . $file);
25 $this->assertIdentical($result, $expect);
28 public function testSimple()
30 $this->assertParse('Simple.txt', array(
31 'ID' => 'Namespace.Directive',
32 'TYPE' => 'string',
33 'CHAIN-ME' => '2',
34 'DESCRIPTION' => "Multiline\nstuff\n",
35 'EMPTY' => '',
36 'FOR-WHO' => "Single multiline\n",
37 ));
40 public function testOverrideSingle()
42 $this->assertParse('OverrideSingle.txt', array(
43 'KEY' => 'New',
44 ));
47 public function testAppendMultiline()
49 $this->assertParse('AppendMultiline.txt', array(
50 'KEY' => "Line1\nLine2\n",
51 ));
54 public function testDefault()
56 $this->parser->default = 'NEW-ID';
57 $this->assertParse('Default.txt', array(
58 'NEW-ID' => 'DefaultValue',
59 ));
62 public function testError()
64 try {
65 $this->parser->parseFile('NoExist.txt');
66 } catch (HTMLPurifier_ConfigSchema_Exception $e) {
67 $this->assertIdentical($e->getMessage(), 'File NoExist.txt does not exist');
71 public function testParseMultiple()
73 $result = $this->parser->parseMultiFile(dirname(__FILE__) . '/StringHashParser/Multi.txt');
74 $this->assertIdentical(
75 $result,
76 array(
77 array(
78 'ID' => 'Namespace.Directive',
79 'TYPE' => 'string',
80 'CHAIN-ME' => '2',
81 'DESCRIPTION' => "Multiline\nstuff\n",
82 'FOR-WHO' => "Single multiline\n",
84 array(
85 'ID' => 'Namespace.Directive2',
86 'TYPE' => 'integer',
87 'CHAIN-ME' => '3',
88 'DESCRIPTION' => "M\nstuff\n",
89 'FOR-WHO' => "Single multiline2\n",
97 // vim: et sw=4 sts=4