From 045b6b7a7cc53868b35f930a5f7891b854c27148 Mon Sep 17 00:00:00 2001
From: Chris Smith
Date: Sat, 23 Feb 2008 07:24:28 +0100
Subject: Test cases for 'phpok' & 'htmlok' config settings
darcs-hash:20080223062428-d26fc-59a5f3a4c230c953db1488a829c814f2901180e4.gz
---
_test/cases/inc/parser/xhtml_htmlphp.test.php | 127 ++++++++++++++++++++++++++
1 file changed, 127 insertions(+)
create mode 100644 _test/cases/inc/parser/xhtml_htmlphp.test.php
(limited to '_test/cases/inc/parser/xhtml_htmlphp.test.php')
diff --git a/_test/cases/inc/parser/xhtml_htmlphp.test.php b/_test/cases/inc/parser/xhtml_htmlphp.test.php
new file mode 100644
index 000000000..acd3bbf92
--- /dev/null
+++ b/_test/cases/inc/parser/xhtml_htmlphp.test.php
@@ -0,0 +1,127 @@
+preformatted($text);
+ }
+
+}
+
+/*
+ * test case for parser/xhtml.php _headertolink method
+ * definition: function _headertolink($title,$create)
+ */
+
+class xhtml_htmlphp_test extends TestOfDoku_Parser {
+
+ function _run_parser($modes,$data) {
+
+ foreach ($modes as $mode => $name) {
+ $class = 'Doku_Parser_Mode_'.$name;
+ $this->P->addMode($mode,new $class());
+ }
+
+ $R = new Doku_Renderer_tester();
+ $this->P->parse($data);
+ foreach ( $this->H->calls as $instruction ) {
+ // Execute the callback against the Renderer
+ call_user_func_array(array(&$R, $instruction[0]),$instruction[1]);
+ }
+
+ return str_replace("\n",'',$R->doc);
+ }
+
+ function test_html_off(){
+ $test = array('bold','<b>bold</b>
');
+
+ global $conf;
+ $conf['htmlok'] = 0;
+
+ $result = $this->_run_parser(array('html'=>'html'),$test[0]);
+
+ $this->assertEqual($result,$test[1]);
+ }
+
+ function test_html_on(){
+ $test = array('bold','bold
');
+
+ global $conf;
+ $conf['htmlok'] = 1;
+
+ $result = $this->_run_parser(array('html'=>'html'),$test[0]);
+
+ $this->assertEqual($result,$test[1]);
+ }
+
+ function test_htmlblock_off(){
+ $test = array('bold','<b>bold</b>
');
+
+ global $conf;
+ $conf['htmlok'] = 0;
+
+ $result = $this->_run_parser(array('html'=>'html'),$test[0]);
+
+ $this->assertEqual($result,$test[1]);
+ }
+
+ function test_htmlblock_on(){
+ $test = array('bold','bold');
+
+ global $conf;
+ $conf['htmlok'] = 1;
+
+ $result = $this->_run_parser(array('html'=>'html'),$test[0]);
+
+ $this->assertEqual($result,$test[1]);
+ }
+
+ function test_php_off(){
+ $test = array('echo(1+1);','echo(1+1);
');
+
+ global $conf;
+ $conf['phpok'] = 0;
+
+ $result = $this->_run_parser(array('php'=>'php'),$test[0]);
+
+ $this->assertEqual($result,$test[1]);
+ }
+
+ function test_php_on(){
+ $test = array('echo(1+1);','2
');
+
+ global $conf;
+ $conf['phpok'] = 1;
+
+ $result = $this->_run_parser(array('php'=>'php'),$test[0]);
+
+ $this->assertEqual($result,$test[1]);
+ }
+
+ function test_phpblock_off(){
+ $test = array('echo(1+1);','echo(1+1);
');
+
+ global $conf;
+ $conf['phpok'] = 0;
+
+ $result = $this->_run_parser(array('php'=>'php'),$test[0]);
+
+ $this->assertEqual($result,$test[1]);
+ }
+
+ function test_phpblock_on(){
+ $test = array('echo(1+1);',"2");
+
+ global $conf;
+ $conf['phpok'] = 1;
+
+ $result = $this->_run_parser(array('php'=>'php'),$test[0]);
+
+ $this->assertEqual($result,$test[1]);
+ }
+
+}
--
cgit v1.2.3