summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--_test/cases/inc/html_hilight.test.php10
-rw-r--r--_test/cases/inc/init_getbaseurl.test.php (renamed from _test/cases/inc/init_getBaseURL.test.php)0
-rw-r--r--_test/cases/inc/pageutils_getid.test.php (renamed from _test/cases/inc/pageutils_getID.test.php)2
-rw-r--r--_test/cases/inc/parser/lexer.group.php2
-rw-r--r--_test/cases/inc/parser/lexer.test.php122
-rw-r--r--_test/cases/inc/parser/parser.group.php27
-rw-r--r--_test/cases/inc/parser/parser_links.test.php5
-rw-r--r--_test/cases/inc/parser/parser_unformatted.test.php1
-rw-r--r--_test/index.php3
-rw-r--r--inc/init.php4
-rw-r--r--inc/parser/handler.php24
-rw-r--r--inc/utf8.php5
12 files changed, 121 insertions, 84 deletions
diff --git a/_test/cases/inc/html_hilight.test.php b/_test/cases/inc/html_hilight.test.php
index 450e8d6d5..1baec416a 100644
--- a/_test/cases/inc/html_hilight.test.php
+++ b/_test/cases/inc/html_hilight.test.php
@@ -15,11 +15,17 @@ function html_hilight_test_unslash($string,$char="'"){
class html_hilight_test extends UnitTestCase{
function setup() {
+ if ( function_exists('unslash') ) {
+ runkit_function_rename('unslash','html_hilight_test_unslash_real');
+ }
runkit_function_rename('html_hilight_test_unslash','unslash');
}
function teardown() {
- runkit_function_rename('unslash','html_hilight_test_unslash');
+ runkit_function_rename('unslash','html_hilight_test_unslash');
+ if ( function_exists('html_hilight_test_unslash_real') ) {
+ runkit_function_rename('html_hilight_test_unslash_real','unslash');
+ }
}
function testHighlightOneWord() {
@@ -93,6 +99,6 @@ class html_hilight_test extends UnitTestCase{
html_hilight($html,'x/')
);
}
-
+
}
diff --git a/_test/cases/inc/init_getBaseURL.test.php b/_test/cases/inc/init_getbaseurl.test.php
index 5dec4a954..5dec4a954 100644
--- a/_test/cases/inc/init_getBaseURL.test.php
+++ b/_test/cases/inc/init_getbaseurl.test.php
diff --git a/_test/cases/inc/pageutils_getID.test.php b/_test/cases/inc/pageutils_getid.test.php
index e6ddb5e3b..9e115acdb 100644
--- a/_test/cases/inc/pageutils_getID.test.php
+++ b/_test/cases/inc/pageutils_getid.test.php
@@ -1,5 +1,5 @@
<?php
-
+require_once DOKU_INC.'inc/utf8.php';
require_once DOKU_INC.'inc/pageutils.php';
class init_getID_test extends UnitTestCase {
diff --git a/_test/cases/inc/parser/lexer.group.php b/_test/cases/inc/parser/lexer.group.php
index 99ec993be..6e9ef0742 100644
--- a/_test/cases/inc/parser/lexer.group.php
+++ b/_test/cases/inc/parser/lexer.group.php
@@ -13,7 +13,7 @@ class LexerGroupTest extends GroupTest {
function LexerGroupTest() {
$this->GroupTest('LexerGroupTest');
- $this->addTestFile('lexer.test.php');
+ $this->addTestFile(dirname(__FILE__).'/lexer.test.php');
}
}
diff --git a/_test/cases/inc/parser/lexer.test.php b/_test/cases/inc/parser/lexer.test.php
index 818009f92..75fa32ee0 100644
--- a/_test/cases/inc/parser/lexer.test.php
+++ b/_test/cases/inc/parser/lexer.test.php
@@ -355,7 +355,7 @@ class TestParserByteIndex {
function ignore() {}
- function catch() {}
+ function caught() {}
}
Mock::generate('TestParserByteIndex');
@@ -371,41 +371,41 @@ class TestOfLexerByteIndices extends UnitTestCase {
$handler = &new MockTestParserByteIndex($this);
$handler->setReturnValue("ignore", true);
- $handler->setReturnValue("catch", true);
+ $handler->setReturnValue("caught", true);
$handler->expectArgumentsAt(
0,
- "catch",
+ "caught",
array("<file>", DOKU_LEXER_ENTER, strpos($doc,'<file>'))
);
$handler->expectArgumentsAt(
1,
- "catch",
+ "caught",
array("b", DOKU_LEXER_SPECIAL, strpos($doc,'b'))
);
$handler->expectArgumentsAt(
2,
- "catch",
+ "caught",
array("c", DOKU_LEXER_MATCHED, strpos($doc,'c'))
);
$handler->expectArgumentsAt(
3,
- "catch",
+ "caught",
array("d", DOKU_LEXER_UNMATCHED, strpos($doc,'d'))
);
$handler->expectArgumentsAt(
4,
- "catch",
+ "caught",
array("</file>", DOKU_LEXER_EXIT, strpos($doc,'</file>'))
);
- $handler->expectCallCount("catch", 5);
+ $handler->expectCallCount("caught", 5);
$lexer = &new Doku_Lexer($handler, "ignore");
- $lexer->addEntryPattern("<file>", "ignore", "catch");
- $lexer->addExitPattern("</file>", "catch");
- $lexer->addSpecialPattern('b','catch','special');
- $lexer->mapHandler('special','catch');
- $lexer->addPattern('c','catch');
+ $lexer->addEntryPattern("<file>", "ignore", "caught");
+ $lexer->addExitPattern("</file>", "caught");
+ $lexer->addSpecialPattern('b','caught','special');
+ $lexer->mapHandler('special','caught');
+ $lexer->addPattern('c','caught');
$this->assertTrue($lexer->parse($doc));
$handler->tally();
@@ -416,41 +416,41 @@ class TestOfLexerByteIndices extends UnitTestCase {
$handler = &new MockTestParserByteIndex($this);
$handler->setReturnValue("ignore", true);
- $handler->setReturnValue("catch", true);
+ $handler->setReturnValue("caught", true);
$handler->expectArgumentsAt(
0,
- "catch",
+ "caught",
array("<file>", DOKU_LEXER_ENTER, strpos($doc,'<file>'))
);
$handler->expectArgumentsAt(
1,
- "catch",
+ "caught",
array("b", DOKU_LEXER_SPECIAL, strpos($doc,'b'))
);
$handler->expectArgumentsAt(
2,
- "catch",
+ "caught",
array("c", DOKU_LEXER_MATCHED, strpos($doc,'c'))
);
$handler->expectArgumentsAt(
3,
- "catch",
+ "caught",
array("d", DOKU_LEXER_UNMATCHED, strpos($doc,'d'))
);
$handler->expectArgumentsAt(
4,
- "catch",
+ "caught",
array("</file>", DOKU_LEXER_EXIT, strpos($doc,'</file>'))
);
- $handler->expectCallCount("catch", 5);
+ $handler->expectCallCount("caught", 5);
$lexer = &new Doku_Lexer($handler, "ignore");
- $lexer->addEntryPattern('<file>(?=.*\x3C/file\x3E)', "ignore", "catch");
- $lexer->addExitPattern("</file>", "catch");
- $lexer->addSpecialPattern('b','catch','special');
- $lexer->mapHandler('special','catch');
- $lexer->addPattern('c','catch');
+ $lexer->addEntryPattern('<file>(?=.*\x3C/file\x3E)', "ignore", "caught");
+ $lexer->addExitPattern("</file>", "caught");
+ $lexer->addSpecialPattern('b','caught','special');
+ $lexer->mapHandler('special','caught');
+ $lexer->addPattern('c','caught');
$this->assertTrue($lexer->parse($doc));
$handler->tally();
@@ -461,41 +461,41 @@ class TestOfLexerByteIndices extends UnitTestCase {
$handler = &new MockTestParserByteIndex($this);
$handler->setReturnValue("ignore", true);
- $handler->setReturnValue("catch", true);
+ $handler->setReturnValue("caught", true);
$handler->expectArgumentsAt(
0,
- "catch",
+ "caught",
array("<file>", DOKU_LEXER_ENTER, strpos($doc,'<file>'))
);
$handler->expectArgumentsAt(
1,
- "catch",
+ "caught",
array("b", DOKU_LEXER_SPECIAL, strpos($doc,'b'))
);
$handler->expectArgumentsAt(
2,
- "catch",
+ "caught",
array("c", DOKU_LEXER_MATCHED, strpos($doc,'c'))
);
$handler->expectArgumentsAt(
3,
- "catch",
+ "caught",
array("d", DOKU_LEXER_UNMATCHED, strpos($doc,'d'))
);
$handler->expectArgumentsAt(
4,
- "catch",
+ "caught",
array("</file>", DOKU_LEXER_EXIT, strpos($doc,'</file>'))
);
- $handler->expectCallCount("catch", 5);
+ $handler->expectCallCount("caught", 5);
$lexer = &new Doku_Lexer($handler, "ignore");
- $lexer->addEntryPattern('<file>(?!foo)', "ignore", "catch");
- $lexer->addExitPattern("</file>", "catch");
- $lexer->addSpecialPattern('b','catch','special');
- $lexer->mapHandler('special','catch');
- $lexer->addPattern('c','catch');
+ $lexer->addEntryPattern('<file>(?!foo)', "ignore", "caught");
+ $lexer->addExitPattern("</file>", "caught");
+ $lexer->addSpecialPattern('b','caught','special');
+ $lexer->mapHandler('special','caught');
+ $lexer->addPattern('c','caught');
$this->assertTrue($lexer->parse($doc));
$handler->tally();
@@ -506,41 +506,41 @@ class TestOfLexerByteIndices extends UnitTestCase {
$handler = &new MockTestParserByteIndex($this);
$handler->setReturnValue("ignore", true);
- $handler->setReturnValue("catch", true);
+ $handler->setReturnValue("caught", true);
$handler->expectArgumentsAt(
0,
- "catch",
+ "caught",
array("<file>", DOKU_LEXER_ENTER, strpos($doc,'<file>'))
);
$handler->expectArgumentsAt(
1,
- "catch",
+ "caught",
array("b", DOKU_LEXER_SPECIAL, strpos($doc,'b'))
);
$handler->expectArgumentsAt(
2,
- "catch",
+ "caught",
array("c", DOKU_LEXER_MATCHED, strpos($doc,'c'))
);
$handler->expectArgumentsAt(
3,
- "catch",
+ "caught",
array("d", DOKU_LEXER_UNMATCHED, strpos($doc,'d'))
);
$handler->expectArgumentsAt(
4,
- "catch",
+ "caught",
array("</file>", DOKU_LEXER_EXIT, strpos($doc,'</file>'))
);
- $handler->expectCallCount("catch", 5);
+ $handler->expectCallCount("caught", 5);
$lexer = &new Doku_Lexer($handler, "ignore");
- $lexer->addEntryPattern('<file>', "ignore", "catch");
- $lexer->addExitPattern("(?<=d)</file>", "catch");
- $lexer->addSpecialPattern('b','catch','special');
- $lexer->mapHandler('special','catch');
- $lexer->addPattern('c','catch');
+ $lexer->addEntryPattern('<file>', "ignore", "caught");
+ $lexer->addExitPattern("(?<=d)</file>", "caught");
+ $lexer->addSpecialPattern('b','caught','special');
+ $lexer->mapHandler('special','caught');
+ $lexer->addPattern('c','caught');
$this->assertTrue($lexer->parse($doc));
$handler->tally();
@@ -551,41 +551,41 @@ class TestOfLexerByteIndices extends UnitTestCase {
$handler = &new MockTestParserByteIndex($this);
$handler->setReturnValue("ignore", true);
- $handler->setReturnValue("catch", true);
+ $handler->setReturnValue("caught", true);
$handler->expectArgumentsAt(
0,
- "catch",
+ "caught",
array("<file>", DOKU_LEXER_ENTER, strpos($doc,'<file>'))
);
$handler->expectArgumentsAt(
1,
- "catch",
+ "caught",
array("b", DOKU_LEXER_SPECIAL, strpos($doc,'b'))
);
$handler->expectArgumentsAt(
2,
- "catch",
+ "caught",
array("c", DOKU_LEXER_MATCHED, strpos($doc,'c'))
);
$handler->expectArgumentsAt(
3,
- "catch",
+ "caught",
array("d", DOKU_LEXER_UNMATCHED, strpos($doc,'d'))
);
$handler->expectArgumentsAt(
4,
- "catch",
+ "caught",
array("</file>", DOKU_LEXER_EXIT, strpos($doc,'</file>'))
);
- $handler->expectCallCount("catch", 5);
+ $handler->expectCallCount("caught", 5);
$lexer = &new Doku_Lexer($handler, "ignore");
- $lexer->addEntryPattern('<file>', "ignore", "catch");
- $lexer->addExitPattern("(?<!c)</file>", "catch");
- $lexer->addSpecialPattern('b','catch','special');
- $lexer->mapHandler('special','catch');
- $lexer->addPattern('c','catch');
+ $lexer->addEntryPattern('<file>', "ignore", "caught");
+ $lexer->addExitPattern("(?<!c)</file>", "caught");
+ $lexer->addSpecialPattern('b','caught','special');
+ $lexer->mapHandler('special','caught');
+ $lexer->addPattern('c','caught');
$this->assertTrue($lexer->parse($doc));
$handler->tally();
diff --git a/_test/cases/inc/parser/parser.group.php b/_test/cases/inc/parser/parser.group.php
index bfd086999..a295f6882 100644
--- a/_test/cases/inc/parser/parser.group.php
+++ b/_test/cases/inc/parser/parser.group.php
@@ -12,20 +12,21 @@
class ParserGroupTest extends GroupTest {
function ParserGroupTest() {
+ $dir = dirname(__FILE__).'/';
$this->GroupTest('ParserGroupTest');
- $this->addTestFile('parser_eol.test.php');
- $this->addTestFile('parser_footnote.test.php');
- $this->addTestFile('parser_formatting.test.php');
- $this->addTestFile('parser_headers.test.php');
- $this->addTestFile('parser_i18n.test.php');
- $this->addTestFile('parser_links.test.php');
- $this->addTestFile('parser_lists.test.php');
- $this->addTestFile('parser_preformatted.test.php');
- $this->addTestFile('parser_quote.test.php');
- $this->addTestFile('parser_replacements.test.php');
- $this->addTestFile('parser_table.test.php');
- $this->addTestFile('parser_tocsections.test.php');
- $this->addTestFile('parser_unformatted.test.php');
+ $this->addTestFile($dir . 'parser_eol.test.php');
+ $this->addTestFile($dir . 'parser_footnote.test.php');
+ $this->addTestFile($dir .'parser_formatting.test.php');
+ $this->addTestFile($dir .'parser_headers.test.php');
+ $this->addTestFile($dir .'parser_i18n.test.php');
+ $this->addTestFile($dir .'parser_links.test.php');
+ $this->addTestFile($dir .'parser_lists.test.php');
+ $this->addTestFile($dir .'parser_preformatted.test.php');
+ $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_unformatted.test.php');
}
}
diff --git a/_test/cases/inc/parser/parser_links.test.php b/_test/cases/inc/parser/parser_links.test.php
index 1bcdcd461..ff0389a8c 100644
--- a/_test/cases/inc/parser/parser_links.test.php
+++ b/_test/cases/inc/parser/parser_links.test.php
@@ -80,8 +80,9 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
-
function testEmail() {
+ $this->fail('The emaillink mode seems to cause php 5.0.5 to segfault');
+ return;
$this->P->addMode('email',new Doku_Parser_Mode_Emaillink());
$this->P->parse("Foo <bugs@php.net> Bar");
$calls = array (
@@ -95,7 +96,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
-
+
function testInternalLinkOneChar() {
$this->P->addMode('internallink',new Doku_Parser_Mode_InternalLink());
$this->P->parse("Foo [[l]] Bar");
diff --git a/_test/cases/inc/parser/parser_unformatted.test.php b/_test/cases/inc/parser/parser_unformatted.test.php
index 5a7d956a9..28f6e50cb 100644
--- a/_test/cases/inc/parser/parser_unformatted.test.php
+++ b/_test/cases/inc/parser/parser_unformatted.test.php
@@ -19,6 +19,7 @@ class TestOfDoku_Parser_Unformatted extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
+
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
diff --git a/_test/index.php b/_test/index.php
index 9b20cee39..7410cf461 100644
--- a/_test/index.php
+++ b/_test/index.php
@@ -1,5 +1,8 @@
<?php
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/');
+define('DOKU_CONF',realpath(dirname(__FILE__).'/../conf').'/' );
+require_once DOKU_CONF . 'dokuwiki.php';
+$conf['lang'] = 'en';
define('TEST_ROOT', dirname(__FILE__));
define('TMPL_FILESCHEME_PATH', TEST_ROOT . '/filescheme/');
error_reporting(E_ALL);
diff --git a/inc/init.php b/inc/init.php
index f9e095533..fb02ab15d 100644
--- a/inc/init.php
+++ b/inc/init.php
@@ -26,7 +26,9 @@
//load the language files
require_once(DOKU_INC.'inc/lang/en/lang.php');
- require_once(DOKU_INC.'inc/lang/'.$conf['lang'].'/lang.php');
+ if ( defined($conf['lang']) ) {
+ require_once(DOKU_INC.'inc/lang/'.$conf['lang'].'/lang.php');
+ }
// define baseURL
if(!defined('DOKU_BASE')) define('DOKU_BASE',getBaseURL());
diff --git a/inc/parser/handler.php b/inc/parser/handler.php
index 61185b046..a1f2fe4c7 100644
--- a/inc/parser/handler.php
+++ b/inc/parser/handler.php
@@ -593,6 +593,9 @@ function Doku_Handler_Parse_Media($match) {
if(preg_match('#(\d+)(x(\d+))?#i',$param,$size)){
($size[1]) ? $w = $size[1] : $w = NULL;
($size[3]) ? $h = $size[3] : $h = NULL;
+ } else {
+ $w = NULL;
+ $h = NULL;
}
//get linking command
@@ -1511,10 +1514,25 @@ class Doku_Handler_Toc {
#FIXME can this be done better?
global $conf;
- $toplevel = $conf['toptoclevel']; // retrieve vars once to save time
- $maxlevel = $conf['maxtoclevel'];
+
+ if ( isset($conf['toptoclevel']) ) {
+ // retrieve vars once to save time
+ $toplevel = $conf['toptoclevel'];
+ } else {
+ $toplevel = 0;
+ }
+
+ if ( isset($conf['maxtoclevel']) ) {
+ $maxlevel = $conf['maxtoclevel'];
+ } else {
+ $maxlevel = 0;
+ }
foreach ( $calls as $call ) {
+ if ( !isset($call[1][1]) ) {
+ $this->calls[] = $call;
+ continue;
+ }
$level = $call[1][1];
if ( $call[0] == 'header' && $level >= $toplevel && $level <= $maxlevel ) {
$this->numHeaders++;
@@ -1639,7 +1657,7 @@ class Doku_Handler_Toc {
function finalizeToc($call) {
global $conf;
- if ( $this->numHeaders < $conf['maxtoclevel'] ) {
+ if ( isset($conf['maxtoclevel']) && $this->numHeaders < $conf['maxtoclevel'] ) {
return;
}
if ( count ($this->tocStack) > 0 ) {
diff --git a/inc/utf8.php b/inc/utf8.php
index 7e82e7cd2..3c1f361f7 100644
--- a/inc/utf8.php
+++ b/inc/utf8.php
@@ -409,6 +409,11 @@ function utf8_to_unicode( &$str ) {
* @see utf8_to_unicode()
*/
function unicode_to_utf8( &$str ) {
+ // init_getID_test causes something to get
+ // passed to this function that isn't a string
+ if ( !is_string($str) ) {
+ return;
+ }
$utf8 = '';
foreach( $str as $unicode ) {
if ( $unicode < 128 ) {