From: Reini U. <ru...@us...> - 2004-05-24 17:33:28
|
Update of /cvsroot/phpwiki/phpwiki/tests/unit/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3800/unit/lib Modified Files: InlineParserTest.php Added Files: HtmlParserTest.php Log Message: renamed testbox to .testbox fixed InlineParser link tests added HtmlParser tests enhanced MockRequest --- NEW FILE: HtmlParserTest.php --- <?php rcs_id('$Id: HtmlParserTest.php,v 1.1 2004/05/24 17:33:17 rurban Exp $'); /* Copyright (C) 2004, Reini Urban <ru...@x-...> */ require_once 'lib/HtmlParser.php'; require_once 'PHPUnit.php'; define('USE_GLOBAL_SAX',false); // this seems to be a xml bug class HtmlParserTest extends PHPUnit_TestCase { // constructor of the test suite function HtmlParserTest($name) { $this->PHPUnit_TestCase($name); } function testSimple() { $html2wiki = array( "<B>bold</B>" => "*bold*", "<STRONG>strong</STRONG>" => "*strong*", "<I>italic</I>" => "_italic_", "<EM>emphasized</EM>" => "_emphasized_", "<HR>" => "----", "<DT><DD>Indent</DD></DT>" => ";:Indent", "<NOWIKI>nowiki</NOWIKI>" => "<verbatim>\nnowiki\n</verbatim>", "<DL><DT> Def </DT><DD> List</DD></DL>" => "; Def : List", ); if (USE_GLOBAL_SAX) $parser = new HtmlParser("PhpWiki2"); // will not work! foreach ($html2wiki as $html => $wiki) { if (!USE_GLOBAL_SAX) // redefine it for every run. $parser = new HtmlParser("PhpWiki2"); if (USE_GLOBAL_SAX) $parser->parse($html,false); // is_final is false else $parser->parse($html); $this->assertEquals($wiki, trim($parser->output())); if (USE_GLOBAL_SAX) unset($GLOBALS['xml_parser_root']); else $parser->__destruct(); } } } // (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil // End: ?> Index: InlineParserTest.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/tests/unit/lib/InlineParserTest.php,v retrieving revision 1.1 retrieving revision 1.2 diff -u -2 -b -p -d -r1.1 -r1.2 --- InlineParserTest.php 7 May 2004 20:47:35 -0000 1.1 +++ InlineParserTest.php 24 May 2004 17:33:17 -0000 1.2 @@ -3,4 +3,5 @@ rcs_id('$Id$'); /* Copyright (C) 2004, Dan Frankowski <dfr...@cs...> + * testLinks: Reini Urban */ @@ -38,26 +39,26 @@ class InlineParserTest extends PHPUnit_T } - // todo... function testLinks() { - $tests = array("[label|link]", - "[ label | link.jpg ]", - "[ image.jpg | link ]", - "[ Upload:image.jpg | link ]", - "[ http://server/image.jpg | link ]", - "[ label | http://server/link ]", - "[ label | Upload:link ]", - "[ label | phpwiki:action=link ]", - "Upload:image.jpg", - "http://server/image.jpg", - "http://server/link", - "[http:/server/~name/]", - "http:/server/~name/" + $uplink = 'http://'.(defined('SERVER_NAME')?SERVER_NAME:'').DATA_PATH.'/uploads/image.jpg'; + $tests = array("[label|link]" => 'O:10:"xmlcontent":1:{s:8:"_content";a:3:{i:0;s:0:"";i:1;O:15:"cached_wikilink":2:{s:5:"_page";s:4:"link";s:6:"_label";s:5:"label";}i:2;s:0:"";}}', + "[ label | link.jpg ]" => 'O:10:"xmlcontent":1:{s:8:"_content";a:3:{i:0;s:0:"";i:1;O:15:"cached_wikilink":2:{s:5:"_page";s:8:"link.jpg";s:6:"_label";s:5:"label";}i:2;s:0:"";}}', + "[ image.jpg | link ]" => 'O:10:"xmlcontent":1:{s:8:"_content";a:3:{i:0;s:0:"";i:1;O:15:"cached_wikilink":2:{s:5:"_page";s:4:"link";s:6:"_label";O:11:"htmlelement":4:{s:8:"_content";a:0:{}s:4:"_tag";s:3:"img";s:5:"_attr";a:3:{s:3:"src";b:0;s:3:"alt";s:4:"link";s:5:"class";s:11:"inlineimage";}s:11:"_properties";i:7;}}i:2;s:0:"";}}', + "[ Upload:image.jpg | link ]" => 'O:10:"xmlcontent":1:{s:8:"_content";a:3:{i:0;s:0:"";i:1;O:15:"cached_wikilink":2:{s:5:"_page";s:4:"link";s:6:"_label";O:11:"htmlelement":4:{s:8:"_content";a:0:{}s:4:"_tag";s:3:"img";s:5:"_attr";a:3:{s:3:"src";s:'.strlen($uplink).':"'.$uplink.'";s:3:"alt";s:4:"link";s:5:"class";s:11:"inlineimage";}s:11:"_properties";i:7;}}i:2;s:0:"";}}', + "[ http://server/image.jpg | link ]" => 'O:10:"xmlcontent":1:{s:8:"_content";a:3:{i:0;s:0:"";i:1;O:15:"cached_wikilink":2:{s:5:"_page";s:4:"link";s:6:"_label";O:11:"htmlelement":4:{s:8:"_content";a:0:{}s:4:"_tag";s:3:"img";s:5:"_attr";a:3:{s:3:"src";s:23:"http://server/image.jpg";s:3:"alt";s:4:"link";s:5:"class";s:11:"inlineimage";}s:11:"_properties";i:7;}}i:2;s:0:"";}}', + "[ label | http://server/link ]" => 'O:10:"xmlcontent":1:{s:8:"_content";a:3:{i:0;s:0:"";i:1;O:19:"cached_externallink":2:{s:4:"_url";s:18:"http://server/link";s:6:"_label";s:5:"label";}i:2;s:0:"";}}', + "[ label | Upload:link ]" => 'O:10:"xmlcontent":1:{s:8:"_content";a:3:{i:0;s:0:"";i:1;O:20:"cached_interwikilink":2:{s:5:"_link";s:11:"Upload:link";s:6:"_label";s:5:"label";}i:2;s:0:"";}}', + "[ label | phpwiki:action=link ]" => 'O:10:"xmlcontent":1:{s:8:"_content";a:3:{i:0;s:0:"";i:1;O:17:"cached_phpwikiurl":2:{s:4:"_url";s:19:"phpwiki:action=link";s:6:"_label";s:5:"label";}i:2;s:0:"";}}', + "Upload:image.jpg" => 'O:10:"xmlcontent":1:{s:8:"_content";a:3:{i:0;s:0:"";i:1;O:20:"cached_interwikilink":1:{s:5:"_link";s:16:"Upload:image.jpg";}i:2;s:0:"";}}', + "http://server/image.jpg" => 'O:10:"xmlcontent":1:{s:8:"_content";a:3:{i:0;s:0:"";i:1;O:19:"cached_externallink":1:{s:4:"_url";s:23:"http://server/image.jpg";}i:2;s:0:"";}}', + "http://server/link" => 'O:10:"xmlcontent":1:{s:8:"_content";a:3:{i:0;s:0:"";i:1;O:19:"cached_externallink":1:{s:4:"_url";s:18:"http://server/link";}i:2;s:0:"";}}', + "[http:/server/~name/]" => 'O:10:"xmlcontent":1:{s:8:"_content";a:3:{i:0;s:0:"";i:1;O:19:"cached_externallink":1:{s:4:"_url";s:18:"http:/server/name/";}i:2;s:0:"";}}', + "http:/server/~name/" => 'O:10:"xmlcontent":1:{s:8:"_content";a:3:{i:0;s:0:"";i:1;O:19:"cached_externallink":1:{s:4:"_url";s:18:"http:/server/name/";}i:2;s:0:"";}}' ); - for ($i=0; $i < count($tests); $i++) { - $xml = TransformInline($tests[$i]); + foreach ($tests as $wiki => $dump) { + $xml = TransformInline($wiki); $this->assertTrue(isa($xml, 'XmlContent')); - $cl = $xml->getContent(); - $this->assertEquals(1, count($c1)); - $this->assertTrue(isa($c1[0], 'Cached_WikiLink')); + //echo var_export($xml),"\n"; + //echo serialize($xml),"\n"; + $this->assertEquals($dump, serialize($xml)); } } |