]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - tests/unit/lib/HtmlParserTest.php
Remove rcs_id
[SourceForge/phpwiki.git] / tests / unit / lib / HtmlParserTest.php
1 <?php
2 // $Id$
3
4 /* Copyright (C) 2004, Reini Urban <rurban@x-ray.at>
5  */
6
7 require_once 'lib/HtmlParser.php';
8 require_once 'PHPUnit.php';
9
10 define('USE_GLOBAL_SAX',false); // this seems to be a xml bug
11
12 class HtmlParserTest extends phpwiki_TestCase {
13
14     function testSimple() {
15         $html2wiki = array(
16                            "<B>bold</B>"              => "*bold*",
17                            "<STRONG>strong</STRONG>"  => "*strong*",
18                            "<I>italic</I>"           => "_italic_",
19                            "<EM>emphasized</EM>"     => "_emphasized_",
20                            "<HR>"                    => "----",
21                            "<DT><DD>Indent</DD></DT>" => ";:Indent",
22                            "<NOWIKI>nowiki</NOWIKI>"  => "<verbatim>\nnowiki\n</verbatim>",
23                            "<DL><DT> Def </DT><DD> List</DD></DL>" => "; Def : List",
24                            );
25         if (USE_GLOBAL_SAX)
26             $parser = new HtmlParser("PhpWiki2"); // will not work!
27         foreach ($html2wiki as $html => $wiki) {
28             if (!USE_GLOBAL_SAX) // redefine it for every run.
29                 $parser = new HtmlParser("PhpWiki2");
30             if (USE_GLOBAL_SAX)
31                 $parser->parse($html,false); // is_final is false
32             else
33                 $parser->parse($html);
34             $this->assertEquals($wiki, trim($parser->output()));
35             if (USE_GLOBAL_SAX)
36                 unset($GLOBALS['xml_parser_root']);
37             else
38                 $parser->__destruct();
39         }
40     }
41
42 }
43
44 // Local Variables:
45 // mode: php
46 // tab-width: 8
47 // c-basic-offset: 4
48 // c-hanging-comment-ender-p: nil
49 // indent-tabs-mode: nil
50 // End: 
51 ?>