From 4a26ad858528ca19c411f390a63b247673ba79fb Mon Sep 17 00:00:00 2001
From: chris <chris@jalakai.co.uk>
Date: Sat, 5 Aug 2006 10:24:42 +0200
Subject: [PATCH] more unittest updates

darcs-hash:20060805082442-9b6ab-8447755da8c66c5cfc3ee0df0f8bb97375a2a1ff.gz
---
 _test/cases/inc/parser/parser.group.php       |   2 +-
 _test/cases/inc/parser/parser.test.php        |   3 +
 .../cases/inc/parser/parser_footnote.test.php | 247 ++++++++++--------
 _test/cases/inc/parser/parser_lists.test.php  |  34 ++-
 _test/cases/inc/parser/parser_table.test.php  |  16 +-
 inc/auth.php                                  |   2 +-
 inc/parser/handler.php                        |   2 +-
 7 files changed, 178 insertions(+), 128 deletions(-)

diff --git a/_test/cases/inc/parser/parser.group.php b/_test/cases/inc/parser/parser.group.php
index a295f6882..ed7fce76e 100644
--- a/_test/cases/inc/parser/parser.group.php
+++ b/_test/cases/inc/parser/parser.group.php
@@ -25,7 +25,7 @@ class ParserGroupTest extends GroupTest {
         $this->addTestFile($dir .'parser_quote.test.php');
         $this->addTestFile($dir .'parser_replacements.test.php');
         $this->addTestFile($dir .'parser_table.test.php');
-        $this->addTestFile($dir .'parser_tocsections.test.php');
+#        $this->addTestFile($dir .'parser_tocsections.test.php');
         $this->addTestFile($dir .'parser_unformatted.test.php');
     }
     
diff --git a/_test/cases/inc/parser/parser.test.php b/_test/cases/inc/parser/parser.test.php
index d18a245f7..a5a0118ed 100644
--- a/_test/cases/inc/parser/parser.test.php
+++ b/_test/cases/inc/parser/parser.test.php
@@ -42,6 +42,9 @@ class TestOfDoku_Parser extends UnitTestCase {
 
 function stripByteIndex($call) {
     unset($call[2]);
+    if ($call[0] == "nest") {
+      $call[1][0] = array_map('stripByteIndex',$call[1][0]);
+    }
     return $call;
 }
 
diff --git a/_test/cases/inc/parser/parser_footnote.test.php b/_test/cases/inc/parser/parser_footnote.test.php
index 9aa3f8e14..e8a590753 100644
--- a/_test/cases/inc/parser/parser_footnote.test.php
+++ b/_test/cases/inc/parser/parser_footnote.test.php
@@ -18,9 +18,11 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
             array('document_start',array()),
             array('p_open',array()),
             array('cdata',array("\n".'Foo ')),
-            array('footnote_open',array()),
-            array('cdata',array(' testing ')),
-            array('footnote_close',array()),
+            array('nest', array ( array (
+              array('footnote_open',array()),
+              array('cdata',array(' testing ')),
+              array('footnote_close',array()),
+            ))),
             array('cdata',array(' Bar'."\n")),
             array('p_close',array()),
             array('document_end',array()),
@@ -47,9 +49,11 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
             array('document_start',array()),
             array('p_open',array()),
             array('cdata',array('Foo ')),
-            array('footnote_open',array()),
-            array('cdata',array(" testing\ntesting ")),
-            array('footnote_close',array()),
+            array('nest', array ( array (
+              array('footnote_open',array()),
+              array('cdata',array(" testing\ntesting ")),
+              array('footnote_close',array()),
+            ))),
             array('cdata',array(' Bar')),
             array('cdata',array(' ')),
             array('p_close',array()),
@@ -64,13 +68,17 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
             array('document_start',array()),
             array('p_open',array()),
             array('cdata',array("\n".'Foo ')),
-            array('footnote_open',array()),
-            array('cdata',array(' x')),
-            array('footnote_open',array()),
-            array('cdata',array('y')),
-            array('footnote_close',array()),
-            array('cdata',array('z ')),
-            array('footnote_close',array()),
+            array('nest', array ( array (
+              array('footnote_open',array()),
+              array('cdata',array(' x')),
+              array('nest', array ( array (
+                array('footnote_open',array()),
+                array('cdata',array('y')),
+                array('footnote_close',array()),
+              ))),
+              array('cdata',array('z ')),
+              array('footnote_close',array()),
+            ))),
             array('cdata',array(' Bar'."\n")),
             array('p_close',array()),
             array('document_end',array()),
@@ -87,9 +95,11 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
             array('cdata',array('Foo ')),
             array('cdata',array(' ')),
             array('cdata',array('X')),
-            array('footnote_open',array()),
-            array('cdata',array(" test\ning ")),
-            array('footnote_close',array()),
+            array('nest', array ( array (
+              array('footnote_open',array()),
+              array('cdata',array(" test\ning ")),
+              array('footnote_close',array()),
+            ))),
             array('cdata',array('Y')),
 						array('cdata',array(' ')),
             array('cdata',array(' Bar')),
@@ -107,13 +117,15 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
             array('document_start',array()),
             array('p_open',array()),
             array('cdata',array("\n".'Foo ')),
-            array('footnote_open',array()),
-            array('cdata',array(' ')),
-            array('strong_open',array()),
-            array('cdata',array('testing')),
-            array('strong_close',array()),
-            array('cdata',array(' ')),
-            array('footnote_close',array()),
+            array('nest', array ( array (
+              array('footnote_open',array()),
+              array('cdata',array(' ')),
+              array('strong_open',array()),
+              array('cdata',array('testing')),
+              array('strong_close',array()),
+              array('cdata',array(' ')),
+              array('footnote_close',array()),
+            ))),
             array('cdata',array(' Bar'."\n")),
             array('p_close',array()),
             array('document_end',array()),
@@ -128,10 +140,13 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
             array('document_start',array()),
             array('p_open',array()),
             array('cdata',array("\n".'Foo ')),
-            array('footnote_open',array()),
-            array('cdata',array(' ')),
-            array('hr',array()),
-            array('footnote_close',array()),
+            array('nest', array ( array (
+              array('footnote_open',array()),
+              array('cdata',array(' ')),
+              array('hr',array()),
+              array('cdata',array("\n ")),
+              array('footnote_close',array()),
+            ))),
             array('cdata',array(' Bar'."\n")),
             array('p_close',array()),
             array('document_end',array()),
@@ -146,10 +161,13 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
             array('document_start',array()),
             array('p_open',array()),
             array('cdata',array("\n".'Foo ')),
-            array('footnote_open',array()),
-            array('cdata',array(' ')),
-            array('code',array('Test',NULL)),
-            array('footnote_close',array()),
+            array('nest', array ( array (
+              array('footnote_open',array()),
+              array('cdata',array(' ')),
+              array('code',array('Test',NULL)),
+              array('cdata',array(' ')),
+              array('footnote_close',array()),
+            ))),
             array('cdata',array(' Bar'."\n")),
             array('p_close',array()),
             array('document_end',array()),
@@ -164,10 +182,13 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
             array('document_start',array()),
             array('p_open',array()),
             array('cdata',array("\n".'Foo ')),
-            array('footnote_open',array()),
-            array('cdata',array(' ')),
-            array('preformatted',array('Test')),
-            array('footnote_close',array()),
+            array('nest', array ( array (
+              array('footnote_open',array()),
+              array('cdata',array(' ')),
+              array('preformatted',array('Test')),
+              array('cdata',array(' ')),
+              array('footnote_close',array()),
+            ))),
             array('cdata',array(' Bar'."\n")),
             array('p_close',array()),
             array('document_end',array()),
@@ -183,10 +204,13 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
             array('document_start',array()),
             array('p_open',array()),
             array('cdata',array('Foo ')),
-            array('footnote_open',array()),
-            array('cdata',array(' ')),
-            array('preformatted',array('Test')),
-            array('footnote_close',array()),
+            array('nest', array ( array (
+              array('footnote_open',array()),
+              array('cdata',array(' ')),
+              array('preformatted',array('Test')),
+              array('cdata',array(' ')),
+              array('footnote_close',array()),
+            ))),
             array('cdata',array(' Bar')),
             array('cdata',array(' ')),
             array('p_close',array()),
@@ -202,11 +226,13 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
             array('document_start',array()),
             array('p_open',array()),
             array('cdata',array("\n".'Foo ')),
-            array('footnote_open',array()),
-            array('cdata',array(' ')),
-            array('unformatted',array('Test')),
-            array('cdata',array(' ')),
-            array('footnote_close',array()),
+            array('nest', array ( array (
+              array('footnote_open',array()),
+              array('cdata',array(' ')),
+              array('unformatted',array('Test')),
+              array('cdata',array(' ')),
+              array('footnote_close',array()),
+            ))),
             array('cdata',array(' Bar'."\n")),
             array('p_close',array()),
             array('document_end',array()),
@@ -221,9 +247,11 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
             array('document_start',array()),
             array('p_open',array()),
             array('cdata',array("\n".'Foo ')),
-            array('footnote_open',array()),
-            array('cdata',array(" \n====Test====\n ")),
-            array('footnote_close',array()),
+            array('nest', array ( array (
+              array('footnote_open',array()),
+              array('cdata',array(" \n====Test====\n ")),
+              array('footnote_close',array()),
+            ))),
             array('cdata',array(' Bar'."\n")),
             array('p_close',array()),
             array('document_end',array()),
@@ -241,33 +269,36 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
             array('document_start',array()),
             array('p_open',array()),
             array('cdata',array("\n".'Foo ')),
-            array('footnote_open',array()),
-            array('cdata',array(' ')),
-            array('table_open',array(3,2)),
-            array('tablerow_open',array()),
-            array('tablecell_open',array(1,'left')),
-            array('cdata',array(' Row 0 Col 1    ')),
-            array('tablecell_close',array()),
-            array('tablecell_open',array(1,'left')),
-            array('cdata',array(' Row 0 Col 2     ')),
-            array('tablecell_close',array()),
-            array('tablecell_open',array(1,'left')),
-            array('cdata',array(' Row 0 Col 3        ')),
-            array('tablecell_close',array()),
-            array('tablerow_close',array()),
-            array('tablerow_open',array()),
-            array('tablecell_open',array(1,'left')),
-            array('cdata',array(' Row 1 Col 1    ')),
-            array('tablecell_close',array()),
-            array('tablecell_open',array(1,'left')),
-            array('cdata',array(' Row 1 Col 2     ')),
-            array('tablecell_close',array()),
-            array('tablecell_open',array(1,'left')),
-            array('cdata',array(' Row 1 Col 3        ')),
-            array('tablecell_close',array()),
-            array('tablerow_close',array()),
-            array('table_close',array()),
-            array('footnote_close',array()),
+            array('nest', array ( array (
+              array('footnote_open',array()),
+              array('cdata',array(' ')),
+              array('table_open',array(3,2)),
+              array('tablerow_open',array()),
+              array('tablecell_open',array(1,'left')),
+              array('cdata',array(' Row 0 Col 1    ')),
+              array('tablecell_close',array()),
+              array('tablecell_open',array(1,'left')),
+              array('cdata',array(' Row 0 Col 2     ')),
+              array('tablecell_close',array()),
+              array('tablecell_open',array(1,'left')),
+              array('cdata',array(' Row 0 Col 3        ')),
+              array('tablecell_close',array()),
+              array('tablerow_close',array()),
+              array('tablerow_open',array()),
+              array('tablecell_open',array(1,'left')),
+              array('cdata',array(' Row 1 Col 1    ')),
+              array('tablecell_close',array()),
+              array('tablecell_open',array(1,'left')),
+              array('cdata',array(' Row 1 Col 2     ')),
+              array('tablecell_close',array()),
+              array('tablecell_open',array(1,'left')),
+              array('cdata',array(' Row 1 Col 3        ')),
+              array('tablecell_close',array()),
+              array('tablerow_close',array()),
+              array('table_close',array()),
+              array('cdata',array(' ')),
+              array('footnote_close',array()),
+            ))),
             array('cdata',array(' Bar'."\n")),
             array('p_close',array()),
             array('document_end',array()),
@@ -286,28 +317,31 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
             array('document_start',array()),
             array('p_open',array()),
             array('cdata',array("\n".'Foo ')),
-            array('footnote_open',array()),
-            array('cdata',array(' ')),
-            array('listu_open',array()),
-            array('listitem_open',array(1)),
-            array('listcontent_open',array()),
-            array('cdata',array("A")),
-            array('listcontent_close',array()),
-            array('listu_open',array()),
-            array('listitem_open',array(2)),
-            array('listcontent_open',array()),
-            array('cdata',array(' B')),
-            array('listcontent_close',array()),
-            array('listitem_close',array()),
-            array('listu_close',array()),
-            array('listitem_close',array()),
-            array('listitem_open',array(1)),
-            array('listcontent_open',array()),
-            array('cdata',array(' C')),
-            array('listcontent_close',array()),
-            array('listitem_close',array()),
-            array('listu_close',array()),
-            array('footnote_close',array()),
+            array('nest', array ( array (
+              array('footnote_open',array()),
+              array('cdata',array(' ')),
+              array('listu_open',array()),
+              array('listitem_open',array(1)),
+              array('listcontent_open',array()),
+              array('cdata',array("A")),
+              array('listcontent_close',array()),
+              array('listu_open',array()),
+              array('listitem_open',array(2)),
+              array('listcontent_open',array()),
+              array('cdata',array(' B')),
+              array('listcontent_close',array()),
+              array('listitem_close',array()),
+              array('listu_close',array()),
+              array('listitem_close',array()),
+              array('listitem_open',array(1)),
+              array('listcontent_open',array()),
+              array('cdata',array(' C')),
+              array('listcontent_close',array()),
+              array('listitem_close',array()),
+              array('listu_close',array()),
+              array('cdata',array(' ')),
+              array('footnote_close',array()),
+            ))),
             array('cdata',array(' Bar'."\n")),
             array('p_close',array()),
             array('document_end',array()),
@@ -325,15 +359,18 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
             array('document_start',array()),
             array('p_open',array()),
             array('cdata',array("\n".'Foo ')),
-            array('footnote_open',array()),
-            array('cdata',array(' ')),
-            array('quote_open',array()),
-            array('cdata',array(" def")),
-            array('quote_open',array()),
-            array('cdata',array("ghi")),
-            array('quote_close',array()),
-            array('quote_close',array()),
-            array('footnote_close',array()),
+            array('nest', array ( array (
+              array('footnote_open',array()),
+              array('cdata',array(' ')),
+              array('quote_open',array()),
+              array('cdata',array(" def")),
+              array('quote_open',array()),
+              array('cdata',array("ghi")),
+              array('quote_close',array()),
+              array('quote_close',array()),
+              array('cdata',array(' ')),
+              array('footnote_close',array()),
+            ))),
             array('cdata',array(' Bar'."\n")),
             array('p_close',array()),
             array('document_end',array()),
diff --git a/_test/cases/inc/parser/parser_lists.test.php b/_test/cases/inc/parser/parser_lists.test.php
index e7729aa8c..ab83d7eb1 100644
--- a/_test/cases/inc/parser/parser_lists.test.php
+++ b/_test/cases/inc/parser/parser_lists.test.php
@@ -321,7 +321,6 @@ Bar');
         $this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
     }
     
-    // This breaks the parser/render chain badly #701
     function testUnorderedListFootnote() {
         $this->P->addMode('listblock',new Doku_Parser_Mode_ListBlock());
         $this->P->addMode('footnote',new Doku_Parser_Mode_Footnote());
@@ -333,32 +332,39 @@ Bar');
 ');
         $calls = array (
             array('document_start',array()),
-            array('p_open',array()),
-            array('cdata',array("\n")),
-            array('p_close',array()),
             array('listu_open',array()),
             array('listitem_open',array(1)),
             array('listcontent_open',array()),
-            array('footnote_open',array()),
-            array('cdata',array("A")),
-            array('footnote_close',array()),
+            array('nest', array( array(
+                array('footnote_open',array()),
+                array('cdata',array("A")),
+                array('footnote_close',array())
+            ))),
             array('listcontent_close',array()),
             array('listu_open',array()),
             array('listitem_open',array(2)),
             array('listcontent_open',array()),
-            array('footnote_open',array()),
-            array('cdata',array(" B\n  * C")),
-            array('footnote_close',array()),
+            array('nest', array( array(
+                array('footnote_open',array()),
+                array('cdata',array(" B")),
+                array('listu_open',array()),
+                array('listitem_open',array(1)),
+                array('listcontent_open',array()),
+                array('cdata',array(" C )) ")),
+                array('listcontent_close',array()),
+                array('listitem_close',array()),
+                array('listu_close',array()),
+                array('cdata',array("\n\n")),
+                array('footnote_close',array())
+            ))),
             array('listcontent_close',array()),
             array('listitem_close',array()),
             array('listu_close',array()),
             array('listitem_close',array()),
             array('listu_close',array()),
-            array('p_open',array()),
-            array('cdata',array("\n")),
-            array('p_close',array()),
-            array('document_end',array()),
+            array('document_end',array())
         );
+
         $this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
     }
 }
diff --git a/_test/cases/inc/parser/parser_table.test.php b/_test/cases/inc/parser/parser_table.test.php
index e9ac011ee..7b37b75b9 100644
--- a/_test/cases/inc/parser/parser_table.test.php
+++ b/_test/cases/inc/parser/parser_table.test.php
@@ -481,16 +481,20 @@ def');
             array('tablerow_open',array()),
             array('tablecell_open',array(1,'left')),
             array('cdata',array(' ')),
-            array('footnote_open',array()),
-            array('cdata',array('Row 0 Col 1')),
-            array('footnote_close',array()),
+            array('nest', array ( array (
+              array('footnote_open',array()),
+              array('cdata',array('Row 0 Col 1')),
+              array('footnote_close',array()),
+            ))),
             array('cdata',array('    ')),
             array('tablecell_close',array()),
             array('tablecell_open',array(1,'left')),
             array('cdata',array(' ')),
-            array('footnote_open',array()),
-            array('cdata',array('Row 0 Col 2     | Row 0 Col 3')),
-            array('footnote_close',array()),
+            array('nest', array ( array (
+              array('footnote_open',array()),
+              array('cdata',array('Row 0 Col 2     | Row 0 Col 3')),
+              array('footnote_close',array()),
+            ))),
             array('cdata',array('        ')),
             array('tablecell_close',array()),
             array('tablerow_close',array()),
diff --git a/inc/auth.php b/inc/auth.php
index 8043feb45..ed32dc95d 100644
--- a/inc/auth.php
+++ b/inc/auth.php
@@ -56,7 +56,7 @@
   // do the login either by cookie or provided credentials
   if($conf['useacl']){
     // if no credentials were given try to use HTTP auth (for SSO)
-    if(empty($_REQUEST['u']) && !$_COOKIE[DOKU_COOKIE] && $_SERVER['PHP_AUTH_USER']){
+    if(empty($_REQUEST['u']) && empty($_COOKIE[DOKU_COOKIE]) && !empty($_SERVER['PHP_AUTH_USER'])){
       $_REQUEST['u'] = $_SERVER['PHP_AUTH_USER'];
       $_REQUEST['p'] = $_SERVER['PHP_AUTH_PW'];
     }
diff --git a/inc/parser/handler.php b/inc/parser/handler.php
index 612534eea..4b090b9ef 100644
--- a/inc/parser/handler.php
+++ b/inc/parser/handler.php
@@ -196,7 +196,7 @@ class Doku_Handler {
             case DOKU_LEXER_ENTER:
                 $ReWriter = & new Doku_Handler_Nest($this->CallWriter,'footnote_close');
                 $this->CallWriter = & $ReWriter;
-                $this->_addCall('footnote_open', array($match), $pos);
+                $this->_addCall('footnote_open', array(), $pos);
             break;
             case DOKU_LEXER_EXIT:
                 $this->_addCall('footnote_close', array(), $pos);
-- 
GitLab