diff options
Diffstat (limited to '_test/cases')
-rw-r--r-- | _test/cases/inc/IXR_Library_IXR_Message.test.php | 139 | ||||
-rw-r--r-- | _test/cases/inc/IXR_Library_date.test.php | 34 | ||||
-rw-r--r-- | _test/cases/inc/auth_admincheck.test.php | 12 | ||||
-rw-r--r-- | _test/cases/inc/html_hilight.test.php | 4 | ||||
-rw-r--r-- | _test/cases/inc/indexer_idx_indexlengths.test.php | 121 | ||||
-rw-r--r-- | _test/cases/inc/pageutils_getid.test.php | 38 | ||||
-rw-r--r-- | _test/cases/inc/parser/parser_footnote.test.php | 4 | ||||
-rw-r--r-- | _test/cases/inc/parser/parser_formatting.test.php | 42 | ||||
-rw-r--r-- | _test/cases/inc/parser/parser_headers.test.php | 21 | ||||
-rw-r--r-- | _test/cases/inc/parser/parser_i18n.test.php | 7 | ||||
-rw-r--r-- | _test/cases/inc/parser/parser_table.test.php | 58 | ||||
-rw-r--r-- | _test/cases/inc/parser/xhtml_htmlphp.test.php | 4 | ||||
-rw-r--r-- | _test/cases/inc/safefn.test.php | 33 | ||||
-rw-r--r-- | _test/cases/lib/exe/js_js_compress.test.php | 4 |
14 files changed, 450 insertions, 71 deletions
diff --git a/_test/cases/inc/IXR_Library_IXR_Message.test.php b/_test/cases/inc/IXR_Library_IXR_Message.test.php new file mode 100644 index 000000000..2a8133230 --- /dev/null +++ b/_test/cases/inc/IXR_Library_IXR_Message.test.php @@ -0,0 +1,139 @@ +<?php +require_once DOKU_INC.'inc/IXR_Library.php'; + +class ixr_library_ixr_message_test extends UnitTestCase { + + + + + + function test_untypedvalue1(){ + $xml = '<?xml version="1.0" encoding="UTF-8"?><methodCall><methodName>wiki.getBackLinks</methodName><params><param><value> change </value></param></params></methodCall>'; + + $ixrmsg = new IXR_Message($xml); + $ixrmsg->parse(); + + $this->assertEqual($ixrmsg->messageType,'methodCall'); + $this->assertEqual($ixrmsg->methodName,'wiki.getBackLinks'); + $this->assertEqual($ixrmsg->params,array(' change ')); + } + + function test_untypedvalue2(){ + $xml = '<?xml version="1.0" encoding="UTF-8"?> + <methodCall> + <methodName>wiki.getBackLinks</methodName> + <params> + <param> + <value> change </value> + </param> + </params> + </methodCall>'; + + $ixrmsg = new IXR_Message($xml); + $ixrmsg->parse(); + + $this->assertEqual($ixrmsg->messageType,'methodCall'); + $this->assertEqual($ixrmsg->methodName,'wiki.getBackLinks'); + $this->assertEqual($ixrmsg->params,array(' change ')); + } + + function test_stringvalue1(){ + $xml = '<?xml version="1.0" encoding="UTF-8"?><methodCall><methodName>wiki.getBackLinks</methodName><params><param><value><string> change </string></value></param></params></methodCall>'; + + $ixrmsg = new IXR_Message($xml); + $ixrmsg->parse(); + + $this->assertEqual($ixrmsg->messageType,'methodCall'); + $this->assertEqual($ixrmsg->methodName,'wiki.getBackLinks'); + $this->assertEqual($ixrmsg->params,array(' change ')); + } + + function test_stringvalue2(){ + $xml = '<?xml version="1.0" encoding="UTF-8"?> + <methodCall> + <methodName>wiki.getBackLinks</methodName> + <params> + <param> + <value> + <string> change </string> + </value> + </param> + </params> + </methodCall>'; + + $ixrmsg = new IXR_Message($xml); + $ixrmsg->parse(); + + $this->assertEqual($ixrmsg->messageType,'methodCall'); + $this->assertEqual($ixrmsg->methodName,'wiki.getBackLinks'); + $this->assertEqual($ixrmsg->params,array(' change ')); + } + + function test_emptyvalue1(){ + $xml = '<?xml version="1.0" encoding="UTF-8"?><methodCall><methodName>wiki.getBackLinks</methodName><params><param><value><string></string></value></param></params></methodCall>'; + + $ixrmsg = new IXR_Message($xml); + $ixrmsg->parse(); + + $this->assertEqual($ixrmsg->messageType,'methodCall'); + $this->assertEqual($ixrmsg->methodName,'wiki.getBackLinks'); + $this->assertEqual($ixrmsg->params,array('')); + } + + function test_emptyvalue2(){ + $xml = '<?xml version="1.0" encoding="UTF-8"?> + <methodCall> + <methodName>wiki.getBackLinks</methodName> + <params> + <param> + <value> + <string></string> + </value> + </param> + </params> + </methodCall>'; + + $ixrmsg = new IXR_Message($xml); + $ixrmsg->parse(); + + $this->assertEqual($ixrmsg->messageType,'methodCall'); + $this->assertEqual($ixrmsg->methodName,'wiki.getBackLinks'); + $this->assertEqual($ixrmsg->params,array('')); + } + + function test_struct(){ + $xml = '<?xml version=\'1.0\'?> + <methodCall> + <methodName>wiki.putPage</methodName> + <params> + <param> + <value><string>start</string></value> + </param> + <param> + <value><string>test text</string></value> + </param> + <param> + <value><struct> + <member> + <name>sum</name> + <value><string>xmlrpc edit</string></value> + </member> + <member> + <name>minor</name> + <value><string>1</string></value> + </member> + </struct></value> + </param> + </params> + </methodCall>'; + + $ixrmsg = new IXR_Message($xml); + $ixrmsg->parse(); + + $this->assertEqual($ixrmsg->messageType,'methodCall'); + $this->assertEqual($ixrmsg->methodName,'wiki.putPage'); + $this->assertEqual($ixrmsg->params,array('start','test text',array('sum'=>'xmlrpc edit','minor'=>'1'))); + } + +} +//Setup VIM: ex: et ts=4 enc=utf-8 : diff --git a/_test/cases/inc/IXR_Library_date.test.php b/_test/cases/inc/IXR_Library_date.test.php new file mode 100644 index 000000000..a2b6154d8 --- /dev/null +++ b/_test/cases/inc/IXR_Library_date.test.php @@ -0,0 +1,34 @@ +<?php +require_once DOKU_INC.'inc/IXR_Library.php'; + +class ixr_library_date_test extends UnitTestCase { + + + function test_parseIso(){ + // multiple tests + $tests = array( + // full datetime, different formats + array('2010-08-17T09:23:14', 1282036994), + array('20100817T09:23:14', 1282036994), + array('2010-08-17 09:23:14', 1282036994), + array('20100817 09:23:14', 1282036994), + array('2010-08-17T09:23:14Z', 1282036994), + array('20100817T09:23:14Z', 1282036994), + + // no seconds + array('2010-08-17T09:23', 1282036980), + array('20100817T09:23', 1282036980), + + // no time + array('2010-08-17', 1282003200), + //array('20100817', 1282003200), #this will NOT be parsed, but is assumed to be timestamp + ); + + foreach($tests as $test){ + $dt = new IXR_Date($test[0]); + $this->assertEqual($dt->getTimeStamp(),$test[1]); + } + } + +} +//Setup VIM: ex: et ts=4 enc=utf-8 : diff --git a/_test/cases/inc/auth_admincheck.test.php b/_test/cases/inc/auth_admincheck.test.php index c00271a26..f14d6369e 100644 --- a/_test/cases/inc/auth_admincheck.test.php +++ b/_test/cases/inc/auth_admincheck.test.php @@ -19,11 +19,11 @@ class auth_admin_test extends UnitTestCase { $conf['manager'] = 'john,@managers,doe'; // anonymous user - $this->assertEqual(auth_ismanager('jill', '',false), false); + $this->assertEqual(auth_ismanager('jill', null,false), false); // admin or manager users - $this->assertEqual(auth_ismanager('john', '',false), true); - $this->assertEqual(auth_ismanager('doe', '',false), true); + $this->assertEqual(auth_ismanager('john', null,false), true); + $this->assertEqual(auth_ismanager('doe', null,false), true); // admin or manager groups $this->assertEqual(auth_ismanager('jill', array('admin'),false), true); @@ -35,11 +35,11 @@ class auth_admin_test extends UnitTestCase { $conf['superuser'] = 'john,@admin,doe,@roots'; // anonymous user - $this->assertEqual(auth_ismanager('jill', '',true), false); + $this->assertEqual(auth_ismanager('jill', null,true), false); // admin user - $this->assertEqual(auth_ismanager('john', '',true), true); - $this->assertEqual(auth_ismanager('doe', '',true), true); + $this->assertEqual(auth_ismanager('john', null,true), true); + $this->assertEqual(auth_ismanager('doe', null,true), true); // admin groups $this->assertEqual(auth_ismanager('jill', array('admin'),true), true); diff --git a/_test/cases/inc/html_hilight.test.php b/_test/cases/inc/html_hilight.test.php index 85f224b6e..cc5579c71 100644 --- a/_test/cases/inc/html_hilight.test.php +++ b/_test/cases/inc/html_hilight.test.php @@ -2,9 +2,7 @@ require_once DOKU_INC.'inc/html.php'; -if ( !extension_loaded('runkit') && - !@dl('runkit.dll') && - !@dl('runkit.so' ) ){ +if (!extension_loaded('runkit')) { SimpleTestOptions::ignore('html_hilight_test'); trigger_error('Skipping html_hilight_test - http://www.php.net/runkit required'); } diff --git a/_test/cases/inc/indexer_idx_indexlengths.test.php b/_test/cases/inc/indexer_idx_indexlengths.test.php new file mode 100644 index 000000000..d1339a111 --- /dev/null +++ b/_test/cases/inc/indexer_idx_indexlengths.test.php @@ -0,0 +1,121 @@ +<?php + +require_once DOKU_INC.'inc/indexer.php'; + +class indexer_idx_indexlengths_test extends UnitTestCase { + + /** + * Test the function with an array of one value + */ + function test_oneWord(){ + global $conf; + $filter[8] = array('dokuwiki'); + // one word should return the index + $ref[] = 8; + sort($ref); + $result = idx_indexLengths(&$filter); + sort($result); + $this->assertIdentical($result, $ref); + } + + /** + * Test the function with an array of values + */ + function test_moreWords() { + global $conf; + $filter = array( 4 => array('test'), 8 => array('dokuwiki'), 7 => array('powered')); + // more words should return the indexes + $ref = array(4, 7, 8); + sort($ref); + $result = idx_indexLengths(&$filter); + sort($result); + $this->assertIdentical($result, $ref); + } + + /** + * Test a minimal value in case of wildcard search + */ + function test_minValue() { + global $conf; + $filter = 5; + // construction of the list of the index to compare + $dir = @opendir($conf['indexdir']); + $ref = array(); + while (($f = readdir($dir)) !== false) { + if (substr($f,0,1) == 'i' && substr($f,-4) == '.idx'){ + $i = substr($f,1,-4); + if (is_numeric($i) && $i >= $filter) + $ref[] = (int)$i; + } + } + closedir($dir); + sort($ref); + $result = idx_indexLengths(&$filter); + sort($result); + $this->assertIdentical($result, $ref); + } +} + +class indexer_idx_indexlengths_time extends UnitTestCase { + + /** + * Test the time improvments of the new function + * Time reference for 10000 call oneWords: 4,6s + * It's 90% faster + */ + function test_oneWord(){ + global $conf; + $filter[8] = array('dokuwiki'); + $start = microtime(true); + for ($i = 0; $i < 10000; $i++) { + $result = idx_indexLengths(&$filter); + } + $end = microtime(true); + $time = $end - $start; + $timeref = 4.6*0.10; // actual execution time of 4,6s for 10000 calls + echo "1) 10% ref : $timeref -> $time \n"; + $this->assertTrue($time < $timeref); + } + + /** + * Test the time improvments of the new function + * Time reference for 10000 call moreWords: 4,6s + * It's 90% faster + */ + function test_moreWords() { + global $conf; + $filter = array( 4 => array('test'), 8 => array('dokuwiki'), 7 => array('powered')); + // more words should return the indexes + $start = microtime(true); + for ($i = 0; $i < 10000; $i++) { + $result = idx_indexLengths(&$filter); + } + $end = microtime(true); + $time = $end - $start; + $timeref = 4.6*0.10; // actual execution time of 4,6s for 10000 calls + echo "2) 10% ref : $timeref -> $time \n"; + $this->assertTrue($time < $timeref); + } + + /** + * Test the time improvments of the new function + * Time reference for 10000 call on minValue: 4,9s + * Sould be at least 65% faster + * Test fail with no cache + */ + function test_minValue() { + global $conf; + $filter = 5; + $start = microtime(true); + for ($i = 0; $i < 10000; $i++) { + $result = idx_indexLengths(&$filter); + } + $end = microtime(true); + $time = $end - $start; + $timeref = 4.9 * 0.35; // actual execution time of 4,9s for 10000 calls + echo "3) 35% ref : $timeref -> $time \n"; + $this->assertTrue($time < $timeref); + } +} + +//Setup VIM: ex: et ts=4 enc=utf-8 : diff --git a/_test/cases/inc/pageutils_getid.test.php b/_test/cases/inc/pageutils_getid.test.php index 8233ffb42..e3932a579 100644 --- a/_test/cases/inc/pageutils_getid.test.php +++ b/_test/cases/inc/pageutils_getid.test.php @@ -64,5 +64,43 @@ class init_getID_test extends UnitTestCase { $this->assertEqual(getID(), 'wiki:dokuwiki'); } + /** + * getID with given id in url and userewrite=2, no basedir set, Apache and CGI. + */ + function test4() { + global $conf; + $conf['basedir'] = ''; + $conf['userewrite'] = '2'; + $conf['baseurl'] = ''; + $_SERVER['DOCUMENT_ROOT'] = '/var/www/vhosts/example.com/htdocs'; + $_SERVER['SCRIPT_FILENAME'] = '/var/www/vhosts/example.com/htdocs/doku.php'; + $_SERVER['SCRIPT_NAME'] = '/doku.php'; + $_SERVER['REQUEST_URI'] = '/doku.php/wiki/dokuwiki'; + $_SERVER['PATH_INFO'] = '/wiki/dokuwiki'; + $_SERVER['PATH_TRANSLATED'] = '/var/www/vhosts/example.com/htdocs/doku.php'; + $_SERVER['PHP_SELF'] = '/doku.php/wiki/dokuwiki'; + + $this->assertEqual(getID(), 'wiki:dokuwiki'); + } + + /** + * getID with given id / in url and userewrite=2, no basedir set, Apache and CGI. + */ + function test5() { + global $conf; + $conf['basedir'] = ''; + $conf['userewrite'] = '2'; + $conf['baseurl'] = ''; + $_SERVER['DOCUMENT_ROOT'] = '/var/www/'; + $_SERVER['SCRIPT_FILENAME'] = '/var/www/dokuwiki/doku.php'; + $_SERVER['SCRIPT_NAME'] = '/dokuwiki/doku.php'; + $_SERVER['REQUEST_URI'] = '/dokuwiki/doku.php/?do=debug'; + $_SERVER['PATH_INFO'] = '/'; + $_SERVER['PATH_TRANSLATED'] = '/var/www/index.html'; + $_SERVER['PHP_SELF'] = '/dokuwiki/doku.php/'; + + $this->assertEqual(getID(), 'start'); + } + } //Setup VIM: ex: et ts=4 enc=utf-8 : diff --git a/_test/cases/inc/parser/parser_footnote.test.php b/_test/cases/inc/parser/parser_footnote.test.php index 2b00a0b2e..a1da2ab06 100644 --- a/_test/cases/inc/parser/parser_footnote.test.php +++ b/_test/cases/inc/parser/parser_footnote.test.php @@ -259,7 +259,7 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser { array('cdata',array("\n".'Foo ')), array('nest', array ( array ( array('footnote_open',array()), - array('table_open',array(3,2)), + array('table_open',array(3, 2, 8)), array('tablerow_open',array()), array('tablecell_open',array(1,'left',1)), array('cdata',array(' Row 0 Col 1 ')), @@ -282,7 +282,7 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser { array('cdata',array(' Row 1 Col 3 ')), array('tablecell_close',array()), array('tablerow_close',array()), - array('table_close',array()), + array('table_close',array(123)), array('cdata',array(' ')), array('footnote_close',array()), ))), diff --git a/_test/cases/inc/parser/parser_formatting.test.php b/_test/cases/inc/parser/parser_formatting.test.php index 35bb41a6a..79509f40b 100644 --- a/_test/cases/inc/parser/parser_formatting.test.php +++ b/_test/cases/inc/parser/parser_formatting.test.php @@ -168,6 +168,48 @@ class TestOfDoku_Parser_Formatting extends TestOfDoku_Parser { $this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls); } + function testEmWithMultiOccurence() { + // Case from #763 + $this->P->addMode('emphasis',new Doku_Parser_Mode_Formatting('emphasis')); + $this->P->parse('//text:// Blablabla Blablabla + +//text:// another Blablabla Blablabla'); + $calls = array ( + array('document_start',array()), + array('p_open',array()), + array('cdata',array("\n")), + array('emphasis_open',array()), + array('cdata',array('text:')), + array('emphasis_close',array()), + array('cdata',array(" Blablabla Blablabla\n\n")), + array('emphasis_open',array()), + array('cdata',array('text:')), + array('emphasis_close',array()), + array('cdata',array(" another Blablabla Blablabla\n")), + array('p_close',array()), + array('document_end',array()), + ); + $this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls); + } + + function testEmWithUnicode() { + // Case from #1468 + $this->P->addMode('emphasis',new Doku_Parser_Mode_Formatting('emphasis')); + $this->P->parse('//Тест://'); + $calls = array ( + array('document_start',array()), + array('p_open',array()), + array('cdata',array("\n")), + array('emphasis_open',array()), + array('cdata',array('Тест:')), + array('emphasis_close',array()), + array('cdata',array("\n")), + array('p_close',array()), + array('document_end',array()), + ); + $this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls); + } + function testUnderline() { $this->P->addMode('underline',new Doku_Parser_Mode_Formatting('underline')); $this->P->parse('abc __bar__ def'); diff --git a/_test/cases/inc/parser/parser_headers.test.php b/_test/cases/inc/parser/parser_headers.test.php index 8e6517123..e1c6783f5 100644 --- a/_test/cases/inc/parser/parser_headers.test.php +++ b/_test/cases/inc/parser/parser_headers.test.php @@ -15,14 +15,12 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser { array('p_open',array()), array('cdata',array("\nabc \n")), array('p_close',array()), - array('section_edit',array(-1,5,1,'')), array('header',array('Header',1,6)), array('section_open',array(1)), array('p_open',array()), array('cdata',array("\n def\n")), array('p_close',array()), array('section_close',array()), - array('section_edit',array (6,0,1,'Header')), array('document_end',array()), ); $this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls); @@ -36,14 +34,12 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser { array('p_open',array()), array('cdata',array("\nabc \n")), array('p_close',array()), - array('section_edit',array(-1,5,1,'')), array('header',array('Header',2,6)), array('section_open',array(2)), array('p_open',array()), array('cdata',array("\n def\n")), array('p_close',array()), array('section_close',array()), - array('section_edit',array(6,0,2,'Header')), array('document_end',array()), ); $this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls); @@ -57,14 +53,12 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser { array('p_open',array()), array('cdata',array("\nabc \n")), array('p_close',array()), - array('section_edit',array(-1,5,1,'')), array('header',array('Header',3,6)), array('section_open',array(3)), array('p_open',array()), array('cdata',array("\n def\n")), array('p_close',array()), array('section_close',array()), - array('section_edit',array(6,0,3,'Header')), array('document_end',array()), ); $this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls); @@ -116,14 +110,12 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser { array('p_open',array()), array('cdata',array("\nabc \n")), array('p_close',array()), - array('section_edit',array(-1,5,1,'')), array('header',array('Header',2,6)), array('section_open',array(2)), array('p_open',array()), array('cdata',array("\n def\n")), array('p_close',array()), array('section_close',array()), - array('section_edit',array(6,0,2,'Header')), array('document_end',array()), ); $this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls); @@ -137,14 +129,12 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser { array('p_open',array()), array('cdata',array("\nabc \n")), array('p_close',array()), - array('section_edit',array(-1,5,1,'')), array('header',array('Header',2,6)), array('section_open',array(2)), array('p_open',array()), array('cdata',array("\n def\n")), array('p_close',array()), array('section_close',array()), - array('section_edit',array(6,0,2,'Header')), array('document_end',array()), ); $this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls); @@ -158,14 +148,12 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser { array('p_open',array()), array('cdata',array("\nabc \n")), array('p_close',array()), - array('section_edit',array(-1,5,1,'')), array('header',array('Header',1,6)), array('section_open',array(1)), array('p_open',array()), array('cdata',array("\n def\n")), array('p_close',array()), array('section_close',array()), - array('section_edit',array(6,0,1,'Header')), array('document_end',array()), ); $this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls); @@ -193,14 +181,12 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser { array('p_open',array()), array('cdata',array("\nabc \n")), array('p_close',array()), - array('section_edit',array(-1,5,1,'')), array('header',array('== Header ==',1,6)), array('section_open',array(1)), array('p_open',array()), array('cdata',array("\n def\n")), array('p_close',array()), array('section_close',array()), - array('section_edit',array(6,0,1,'== Header ==')), array('document_end',array()), ); $this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls); @@ -233,14 +219,12 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser { array('p_open',array()), array('cdata',array("\nabc \n== ====== Header\n")), array('p_close',array()), - array('section_edit',array(-1,22,1,'')), array('header',array('',1,23)), array('section_open',array(1)), array('p_open',array()), array('cdata',array("\n def\n")), array('p_close',array()), array('section_close',array()), - array('section_edit',array(23,0,1,'')), array('document_end',array()), ); $this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls); @@ -261,14 +245,12 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser { array('p_open',array()), array('cdata',array('abc '.DOKU_PARSER_EOL)), array('p_close',array()), - array('section_edit',array(-1,5,1,'')), array('header',array('Header',1, 6)), array('section_open',array(1)), array('p_open',array()), array('cdata',array(' def'.DOKU_PARSER_EOL)), array('p_close',array()), array('section_close',array()), - array('section_edit',array(6,0,1,'Header')), array('document_end',array()), ); $this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls); @@ -283,21 +265,18 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser { array('p_open',array()), array('cdata',array("\nabc \n")), array('p_close',array()), - array('section_edit',array(-1,5,1,'')), array('header',array('Header',1,6)), array('section_open',array(1)), array('p_open',array()), array('cdata',array("\n def abc \n")), array('p_close',array()), array('section_close',array()), - array('section_edit',array(6,38,1,'Header')), array('header',array('Header2',2,39)), array('section_open',array(2)), array('p_open',array()), array('cdata',array("\n def\n")), array('p_close',array()), array('section_close',array()), - array('section_edit',array(39,0,2,'Header2')), array('document_end',array()) ); $this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls); diff --git a/_test/cases/inc/parser/parser_i18n.test.php b/_test/cases/inc/parser/parser_i18n.test.php index 8d587fe0e..f0cceb69e 100644 --- a/_test/cases/inc/parser/parser_i18n.test.php +++ b/_test/cases/inc/parser/parser_i18n.test.php @@ -62,14 +62,12 @@ class TestOfDoku_Parser_i18n extends TestOfDoku_Parser { array('p_open',array()), array('cdata',array("\nFoo\n")), array('p_close',array()), - array('section_edit',array(-1,4,1,'')), array('header',array('Iñtërnâtiônàlizætiøn',3,5)), array('section_open',array(3)), array('p_open',array()), array('cdata',array("\n Bar\n")), array('p_close',array()), array('section_close',array()), - array('section_edit',array(5,0,3,'Iñtërnâtiônàlizætiøn')), array('document_end',array()), ); $this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls); @@ -87,7 +85,7 @@ def'); array('p_open',array()), array('cdata',array("\n\nabc")), array('p_close',array()), - array('table_open',array(3,2)), + array('table_open',array(3, 2, 6)), array('tablerow_open',array()), array('tablecell_open',array(1,'left',1)), array('cdata',array(' Row 0 Col 1 ')), @@ -110,13 +108,12 @@ def'); array('cdata',array(' Row 1 Col 3 ')), array('tablecell_close',array()), array('tablerow_close',array()), - array('table_close',array()), + array('table_close',array(153)), array('p_open',array()), array('cdata',array('def'."\n")), array('p_close',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 f84923dfd..099909495 100644 --- a/_test/cases/inc/parser/parser_table.test.php +++ b/_test/cases/inc/parser/parser_table.test.php @@ -19,7 +19,7 @@ def'); array('p_open',array()), array('cdata',array("\n\nabc")), array('p_close',array()), - array('table_open',array(3,2)), + array('table_open',array(3, 2, 6)), array('tablerow_open',array()), array('tablecell_open',array(1,'left',1)), array('cdata',array(' Row 0 Col 1 ')), @@ -42,7 +42,7 @@ def'); array('cdata',array(' Row 1 Col 3 ')), array('tablecell_close',array()), array('tablerow_close',array()), - array('table_close',array()), + array('table_close',array(121)), array('p_open',array()), array('cdata',array('def'."\n")), array('p_close',array()), @@ -59,7 +59,7 @@ def'); array('p_open',array()), array('cdata',array("\n\nabc")), array('p_close',array()), - array('table_open',array(3,2)), + array('table_open',array(3, 2, 6)), array('tablerow_open',array()), array('tablecell_open',array(1,'left',1)), array('cdata',array(' Row 0 Col 1 ')), @@ -82,7 +82,7 @@ def'); array('cdata',array(' Row 1 Col 3 ')), array('tablecell_close',array()), array('tablerow_close',array()), - array('table_close',array()), + array('table_close',array(121)), array('p_open',array()), array('cdata',array('def'."\n")), array('p_close',array()), @@ -103,16 +103,16 @@ def'); array('p_open',array()), array('cdata',array("\n\nabc")), array('p_close',array()), - array('table_open',array(0,1)), + array('table_open',array(0, 1, 6)), array('tablerow_open',array()), array('tablerow_close',array()), - array('table_close',array()), + array('table_close',array(7)), array('p_open',array()), array('cdata',array('def'."\n")), array('p_close',array()), array('document_end',array()), ); - + $this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls); } @@ -128,7 +128,7 @@ def'); array('p_open',array()), array('cdata',array("\n\nabc")), array('p_close',array()), - array('table_open',array(3,1)), + array('table_open',array(3, 1, 6)), array('tablerow_open',array()), array('tableheader_open',array(1,NULL,1)), array('cdata',array(' X ')), @@ -140,13 +140,13 @@ def'); array('cdata',array(' Z ')), array('tableheader_close',array()), array('tablerow_close',array()), - array('table_close',array()), + array('table_close',array(19)), array('p_open',array()), array('cdata',array('def'."\n")), array('p_close',array()), array('document_end',array()), ); - + $this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls); } @@ -163,7 +163,7 @@ def'); array('p_open',array()), array('cdata',array("\n\nabc")), array('p_close',array()), - array('table_open',array(3,1)), + array('table_open',array(3, 1, 6)), array('tablerow_open',array()), array('tablecell_open',array(1,'right',1)), array('cdata',array(' X ')), @@ -175,13 +175,13 @@ def'); array('cdata',array(' Z ')), array('tableheader_close',array()), array('tablerow_close',array()), - array('table_close',array()), + array('table_close',array(23)), array('p_open',array()), array('cdata',array('def'."\n")), array('p_close',array()), array('document_end',array()), ); - + $this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls); } @@ -199,7 +199,7 @@ def'); array('p_open',array()), array('cdata',array("\n\nabc")), array('p_close',array()), - array('table_open',array(3,3)), + array('table_open',array(3, 3, 6)), array('tablerow_open',array()), array('tablecell_open',array(2,'right',1)), array('cdata',array(' d ')), @@ -218,7 +218,7 @@ def'); array('tablerow_close',array()), array('tablerow_open',array()), array('tablerow_close',array()), - array('table_close',array()), + array('table_close',array(31)), array('p_open',array()), array('cdata',array('def'."\n")), array('p_close',array()), @@ -241,7 +241,7 @@ def'); array('p_open',array()), array('cdata',array("\n\nabc")), array('p_close',array()), - array('table_open',array(3,3)), + array('table_open',array(3, 3, 6)), array('tablerow_open',array()), array('tablecell_open',array(1,NULL,2)), array('cdata',array(' a ')), @@ -266,7 +266,7 @@ def'); array('cdata',array(':::f')), array('tablecell_close',array()), array('tablerow_close',array()), - array('table_close',array()), + array('table_close',array(51)), array('p_open',array()), array('cdata',array('def'."\n")), array('p_close',array()), @@ -288,7 +288,7 @@ def'); array('p_open',array()), array('cdata',array("\n\nabc")), array('p_close',array()), - array('table_open',array(3,1)), + array('table_open',array(3, 1, 6)), array('tablerow_open',array()), array('tablecell_open',array(1,'right',1)), array('cdata',array(' ')), @@ -304,7 +304,7 @@ def'); array('cdata',array(' Z ')), array('tableheader_close',array()), array('tablerow_close',array()), - array('table_close',array()), + array('table_close',array(27)), array('p_open',array()), array('cdata',array('def'."\n")), array('p_close',array()), @@ -328,7 +328,7 @@ def'); array('p_open',array()), array('cdata',array(DOKU_PARSER_EOL."abc")), array('p_close',array()), - array('table_open',array(3,2)), + array('table_open',array(3, 2, 6)), array('tablerow_open',array()), array('tablecell_open',array(1,'left',1)), array('cdata',array(' Row 0 Col 1 ')), @@ -351,7 +351,7 @@ def'); array('cdata',array(' Row 1 Col 3 ')), array('tablecell_close',array()), array('tablerow_close',array()), - array('table_close',array()), + array('table_close',array(121)), array('p_open',array()), array('cdata',array('def'.DOKU_PARSER_EOL)), array('p_close',array()), @@ -375,7 +375,7 @@ def'); array('p_open',array()), array('cdata',array("\n\nabc")), array('p_close',array()), - array('table_open',array(3,2)), + array('table_open',array(3, 2, 6)), array('tablerow_open',array()), array('tablecell_open',array(1,'left',1)), array('cdata',array(' ')), @@ -403,7 +403,7 @@ def'); array('cdata',array(' Row 1 Col 3 ')), array('tablecell_close',array()), array('tablerow_close',array()), - array('table_close',array()), + array('table_close',array(129)), array('p_open',array()), array('cdata',array('def'."\n")), array('p_close',array()), @@ -427,7 +427,7 @@ def'); array('p_open',array()), array('cdata',array("\n\nabc")), array('p_close',array()), - array('table_open',array(3,2)), + array('table_open',array(3, 2, 6)), array('tablerow_open',array()), array('tablecell_open',array(1,'left',1)), array('cdata',array(' ')), @@ -451,7 +451,7 @@ def'); array('cdata',array(' Row 1 Col 3 ')), array('tablecell_close',array()), array('tablerow_close',array()), - array('table_close',array()), + array('table_close',array(155)), array('p_open',array()), array('cdata',array('def'."\n")), array('p_close',array()), @@ -473,7 +473,7 @@ def'); array('p_open',array()), array('cdata',array("\n\nabc")), array('p_close',array()), - array('table_open',array(3,2)), + array('table_open',array(3, 2, 6)), array('tablerow_open',array()), array('tablecell_open',array(1,'left',1)), array('cdata',array(' Row 0')), @@ -498,7 +498,7 @@ def'); array('cdata',array(' Row 1 Col 3 ')), array('tablecell_close',array()), array('tablerow_close',array()), - array('table_close',array()), + array('table_close',array(123)), array('p_open',array()), array('cdata',array('def'."\n")), array('p_close',array()), @@ -523,7 +523,7 @@ def'); array('p_open',array()), array('cdata',array("\n\nabc")), array('p_close',array()), - array('table_open',array(3,2)), + array('table_open',array(3, 2, 6)), array('tablerow_open',array()), array('tablecell_open',array(1,'left',1)), array('cdata',array(' ')), @@ -555,7 +555,7 @@ def'); array('cdata',array(' Row 1 Col 3 ')), array('tablecell_close',array()), array('tablerow_close',array()), - array('table_close',array()), + array('table_close',array(129)), array('p_open',array()), array('cdata',array('def'."\n")), array('p_close',array()), diff --git a/_test/cases/inc/parser/xhtml_htmlphp.test.php b/_test/cases/inc/parser/xhtml_htmlphp.test.php index 3493bab4d..65d64e579 100644 --- a/_test/cases/inc/parser/xhtml_htmlphp.test.php +++ b/_test/cases/inc/parser/xhtml_htmlphp.test.php @@ -5,9 +5,7 @@ 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' ) ){ +if (!extension_loaded('runkit')) { SimpleTestOptions::ignore('xhtml_htmlphp_test'); trigger_error('Skipping xhtml_htmlphp_test - http://www.php.net/runkit required'); } diff --git a/_test/cases/inc/safefn.test.php b/_test/cases/inc/safefn.test.php new file mode 100644 index 000000000..fb0d812d7 --- /dev/null +++ b/_test/cases/inc/safefn.test.php @@ -0,0 +1,33 @@ +<?php +// use no mbstring help here +if(!defined('UTF8_NOMBSTRING')) define('UTF8_NOMBSTRING',1); +require_once DOKU_INC.'inc/utf8.php'; +require_once DOKU_INC.'inc/SafeFN.class.php'; + +class safeFN_test extends UnitTestCase { + + + function test1(){ + // we test multiple cases here - format: string, repl, additional, test + $tests = array(); + $tests[] = array('asciistring','asciistring'); + $tests[] = array('ascii-_/.string','ascii-_/.string'); + $tests[] = array('AName','%x%1a.ame'); + $tests[] = array('A Name','%x%0%1a.ame'); + $tests[] = array('Another...Name','%x.nother...%1a.ame'); + $tests[] = array('Aß∂ƒName','%x%5b%6oy%aa%1a.ame'); + $tests[] = array('A%ß-∂_.ƒName','%x%%5b.-%6oy._.%aa%1a.ame'); + $tests[] = array('A%%ß-∂_.ƒName','%x%%%5b.-%6oy._.%aa%1a.ame'); + $tests[] = array('데이터도 함께 복원됩니다. 강력한','%zf4%13dg%15ao%zhg%0%164o%yig%0%11at%138w%zk9%zag%zb8..%0%xyt%10cl%164c'); + $tests[] = array('совместимая','%td%ta%sy%t8%t1%td%te%t4%t8%sw%tr'); + $tests[] = array('нехватка_файлового_пространства_на_сервере_p0-squid.some.domain.1270211897.txt.gz','%t9%t1%th%sy%sw%te%t6%sw._%tg%sw%t5%t7%ta%sy%ta%sz%ta._%tb%tc%ta%td%te%tc%sw%t9%td%te%sy%sw._%t9%sw._%td%t1%tc%sy%t1%tc%t1._p0-squid.some.domain.1270211897.txt.gz'); + + foreach($tests as $test){ + list($utf8,$safe) = $test; + $this->assertEqual(SafeFN::encode($utf8),$safe); + $this->assertEqual(SafeFN::decode($safe),$utf8); + } + } + +} +//Setup VIM: ex: et ts=4 enc=utf-8 : diff --git a/_test/cases/lib/exe/js_js_compress.test.php b/_test/cases/lib/exe/js_js_compress.test.php index b7de9257d..9051dfb01 100644 --- a/_test/cases/lib/exe/js_js_compress.test.php +++ b/_test/cases/lib/exe/js_js_compress.test.php @@ -71,7 +71,7 @@ class js_js_compress_test extends UnitTestCase { function test_dquotrunaway(){ $text = 'var foo="Now where does it end'; - $this->assertEqual(js_compress($text), "$text"); + $this->assertEqual(js_compress($text), $text); } function test_squot1(){ @@ -81,7 +81,7 @@ class js_js_compress_test extends UnitTestCase { function test_squotrunaway(){ $text = "var foo='Now where does it end"; - $this->assertEqual(js_compress($text), "$text"); + $this->assertEqual(js_compress($text), $text); } function test_nl1(){ |