diff options
author | Chris Smith <chris.eureka@jalakai.co.uk> | 2008-03-29 20:52:13 +0100 |
---|---|---|
committer | Chris Smith <chris.eureka@jalakai.co.uk> | 2008-03-29 20:52:13 +0100 |
commit | 25d9aa935195ffab4f4baf5f81184d3698177a20 (patch) | |
tree | 16320f77e286f8df5e80efe5339665d0e6cfc899 | |
parent | 5d568b990e8fc3c849ba1d694019eae8e42763e4 (diff) | |
download | rpg-25d9aa935195ffab4f4baf5f81184d3698177a20.tar.gz rpg-25d9aa935195ffab4f4baf5f81184d3698177a20.tar.bz2 |
Updates to unit tests for FS#1350 patch
darcs-hash:20080329195213-f07c6-e3899c9ea9a3d6b238a4bae1c57babc7251873bc.gz
-rw-r--r-- | _test/cases/inc/parser/xhtml_htmlphp.test.php | 94 |
1 files changed, 86 insertions, 8 deletions
diff --git a/_test/cases/inc/parser/xhtml_htmlphp.test.php b/_test/cases/inc/parser/xhtml_htmlphp.test.php index acd3bbf92..3493bab4d 100644 --- a/_test/cases/inc/parser/xhtml_htmlphp.test.php +++ b/_test/cases/inc/parser/xhtml_htmlphp.test.php @@ -1,14 +1,31 @@ <?php if (!defined('DOKU_BASE')) define('DOKU_BASE','./'); + require_once 'parser.inc.php'; require_once DOKU_INC.'inc/parser/xhtml.php'; +require_once DOKU_INC.'inc/geshi.php'; + +if ( !extension_loaded('runkit') && + !@dl('runkit.dll') && + !@dl('runkit.so' ) ){ + SimpleTestOptions::ignore('xhtml_htmlphp_test'); + trigger_error('Skipping xhtml_htmlphp_test - http://www.php.net/runkit required'); +} + +function xhtml_htmlphp_test_io_makefiledir() { + return; +} +function xhtml_htmlphp_test_io_savefile() { + return true; +} + class Doku_Renderer_tester extends Doku_Renderer_xhtml { - // simplify to avoid GeSHi - function code($text, $language = NULL) { - $this->preformatted($text); - } +/* + changes to these tests remove the need to redefine any xhtml methods + class left for future use + */ } @@ -19,6 +36,67 @@ class Doku_Renderer_tester extends Doku_Renderer_xhtml { class xhtml_htmlphp_test extends TestOfDoku_Parser { + var $purge; + var $cachedir; + + function setup() { + global $conf; + + // set purge to avoid trying to retrieve from cache + $this->purge = isset($_REQUEST['purge']) ? $_REQUEST['purge'] : null; + $_REQUEST['purge'] = 1; + + if (!isset($conf['cachedir'])) { + $conf['cachedir'] = ''; + $this->cachedir = false; + } else { + $this->cachedir = true; + } + + if (function_exists('io_makefiledir')) { + runkit_function_rename('io_makefiledir', 'io_makefiledir_real'); + } + runkit_function_rename('xhtml_htmlphp_test_io_makefiledir','io_makefiledir'); + + if (function_exists('io_savefile')) { + runkit_function_rename('io_savefile', 'io_savefile_real'); + } + runkit_function_rename('xhtml_htmlphp_test_io_savefile','io_savefile'); + + runkit_method_rename('GeSHi','parse_code','parse_code_real'); + runkit_method_add('GeSHi','parse_code','', '{ return hsc($this->source); }'); + + parent::setup(); + } + + function teardown() { + global $conf; + + // restore purge + if (is_null($this->purge)) unset($_REQUEST['purge']); + else $_REQUEST['purge'] = $this->purge; + + // restore $conf['cachedir'] if necessary + if (!$this->cachedir) unset($conf['cachedir']); + + // restore io_functions + runkit_function_rename('io_makefiledir','xhtml_htmlphp_test_io_makefiledir'); + if (function_exists('io_makefiledir_real')) { + runkit_function_rename('io_makefiledir_real', 'io_makefiledir'); + } + + runkit_function_rename('io_savefile','xhtml_htmlphp_test_io_savefile'); + if (function_exists('io_savefile_real')) { + runkit_function_rename('io_savefile_real', 'io_savefile'); + } + + // restore GeSHi::parse_code + runkit_method_remove('GeSHi','parse_code'); + runkit_method_rename('GeSHi','parse_code_real','parse_code'); + + parent::setup(); + } + function _run_parser($modes,$data) { foreach ($modes as $mode => $name) { @@ -37,7 +115,7 @@ class xhtml_htmlphp_test extends TestOfDoku_Parser { } function test_html_off(){ - $test = array('<html><b>bold</b></html>','<p><pre class="code"><b>bold</b></pre></p>'); + $test = array('<html><b>bold</b></html>','<p><code class="code html4strict"><b>bold</b></code></p>'); global $conf; $conf['htmlok'] = 0; @@ -59,7 +137,7 @@ class xhtml_htmlphp_test extends TestOfDoku_Parser { } function test_htmlblock_off(){ - $test = array('<HTML><b>bold</b></HTML>','<pre class="code"><b>bold</b></pre>'); + $test = array('<HTML><b>bold</b></HTML>','<pre class="code html4strict"><b>bold</b></pre>'); global $conf; $conf['htmlok'] = 0; @@ -81,7 +159,7 @@ class xhtml_htmlphp_test extends TestOfDoku_Parser { } function test_php_off(){ - $test = array('<php>echo(1+1);</php>','<p><pre class="code">echo(1+1);</pre></p>'); + $test = array('<php>echo(1+1);</php>','<p><code class="code php">echo(1+1);</code></p>'); global $conf; $conf['phpok'] = 0; @@ -103,7 +181,7 @@ class xhtml_htmlphp_test extends TestOfDoku_Parser { } function test_phpblock_off(){ - $test = array('<PHP>echo(1+1);</PHP>','<pre class="code">echo(1+1);</pre>'); + $test = array('<PHP>echo(1+1);</PHP>','<pre class="code php">echo(1+1);</pre>'); global $conf; $conf['phpok'] = 0; |