]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - tests/unit/lib/HtmlParserTest.php
renamed testbox to .testbox
[SourceForge/phpwiki.git] / tests / unit / lib / HtmlParserTest.php
1 <?php
2 rcs_id('$Id: HtmlParserTest.php,v 1.1 2004-05-24 17:33:17 rurban Exp $');
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 PHPUnit_TestCase {
13
14     // constructor of the test suite
15     function HtmlParserTest($name) {
16        $this->PHPUnit_TestCase($name);
17     }
18
19     function testSimple() {
20         $html2wiki = array(
21                            "<B>bold</B>"              => "*bold*",
22                            "<STRONG>strong</STRONG>"  => "*strong*",
23                            "<I>italic</I>"           => "_italic_",
24                            "<EM>emphasized</EM>"     => "_emphasized_",
25                            "<HR>"                    => "----",
26                            "<DT><DD>Indent</DD></DT>" => ";:Indent",
27                            "<NOWIKI>nowiki</NOWIKI>"  => "<verbatim>\nnowiki\n</verbatim>",
28                            "<DL><DT> Def </DT><DD> List</DD></DL>" => "; Def : List", 
29                            );
30         if (USE_GLOBAL_SAX)
31             $parser = new HtmlParser("PhpWiki2"); // will not work!
32         foreach ($html2wiki as $html => $wiki) {
33             if (!USE_GLOBAL_SAX) // redefine it for every run.
34                 $parser = new HtmlParser("PhpWiki2");
35             if (USE_GLOBAL_SAX)
36                 $parser->parse($html,false); // is_final is false
37             else
38                 $parser->parse($html);
39             $this->assertEquals($wiki, trim($parser->output()));
40             if (USE_GLOBAL_SAX)
41                 unset($GLOBALS['xml_parser_root']);
42             else
43                 $parser->__destruct();
44         }
45     }
46   
47 }
48
49
50 // (c-file-style: "gnu")
51 // Local Variables:
52 // mode: php
53 // tab-width: 8
54 // c-basic-offset: 4
55 // c-hanging-comment-ender-p: nil
56 // indent-tabs-mode: nil
57 // End:   
58 ?>