diff options
Diffstat (limited to '_test/tests/inc')
-rw-r--r-- | _test/tests/inc/PageUtilsIsHiddenPage.test.php | 95 | ||||
-rw-r--r-- | _test/tests/inc/html_hilight.test.php | 32 | ||||
-rw-r--r-- | _test/tests/inc/indexer_histogram.test.php | 19 | ||||
-rw-r--r-- | _test/tests/inc/input.test.php | 19 | ||||
-rw-r--r-- | _test/tests/inc/parserutils_set_metadata_during_rendering.test.php | 3 | ||||
-rw-r--r-- | _test/tests/inc/subscription_set.test.php | 20 | ||||
-rw-r--r-- | _test/tests/inc/tar.test.php | 319 | ||||
-rw-r--r-- | _test/tests/inc/tar/foobar/testdata2.txt | 1 | ||||
-rw-r--r-- | _test/tests/inc/tar/longpath-gnu.tgz | bin | 0 -> 413 bytes | |||
-rw-r--r-- | _test/tests/inc/tar/longpath-ustar.tgz | bin | 0 -> 311 bytes | |||
-rw-r--r-- | _test/tests/inc/tar/tarbomb.tgz | bin | 0 -> 183 bytes | |||
-rw-r--r-- | _test/tests/inc/tar/test.tar | bin | 0 -> 10240 bytes | |||
-rw-r--r-- | _test/tests/inc/tar/test.tbz | bin | 0 -> 217 bytes | |||
-rw-r--r-- | _test/tests/inc/tar/test.tgz | bin | 0 -> 220 bytes | |||
-rw-r--r-- | _test/tests/inc/tar/testdata1.txt | 1 | ||||
-rw-r--r-- | _test/tests/inc/template_include_page.test.php (renamed from _test/tests/inc/template_sidebar.test.php) | 16 | ||||
-rw-r--r-- | _test/tests/inc/utf8_basename.test.php | 91 |
17 files changed, 606 insertions, 10 deletions
diff --git a/_test/tests/inc/PageUtilsIsHiddenPage.test.php b/_test/tests/inc/PageUtilsIsHiddenPage.test.php new file mode 100644 index 000000000..a7077862e --- /dev/null +++ b/_test/tests/inc/PageUtilsIsHiddenPage.test.php @@ -0,0 +1,95 @@ +<?php + +class PageUtilsIsHiddenPageTest extends DokuWikiTest { + + function prepare($hidePages = '^:test$', $act = 'show') { + global $conf; + global $ACT; + $conf['hidepages'] = $hidePages; + $ACT = $act; + } + + function testHiddenOff(){ + $this->prepare(''); + + $this->assertFalse(isHiddenPage('test')); + } + + function testHiddenOffAdmin(){ + $this->prepare('^:test$', 'admin'); + + $this->assertFalse(isHiddenPage('test')); + } + + function testHiddenOnMatch(){ + $this->prepare(); + + $this->assertTrue(isHiddenPage('test')); + } + + function testHiddenOnNoMatch(){ + $this->prepare(); + + $this->assertFalse(isHiddenPage('another')); + } + + function testEventHandlerBefore() { + global $EVENT_HANDLER; + $this->prepare(); + $EVENT_HANDLER->register_hook('PAGEUTILS_ID_HIDEPAGE', 'BEFORE', $this, 'alwaysHide'); + + $this->assertTrue(isHiddenPage('another')); + } + + function alwaysHide(Doku_Event &$event, $params) { + $event->data['hidden'] = true; + } + + function testEventHandlerBeforeAndPrevent() { + global $EVENT_HANDLER; + $this->prepare(); + $EVENT_HANDLER->register_hook('PAGEUTILS_ID_HIDEPAGE', 'BEFORE', $this, 'showBefore'); + + $this->assertFalse(isHiddenPage('test')); + } + + function showBefore(Doku_Event &$event, $params) { + $event->data['hidden'] = false; + $event->preventDefault(); + $event->stopPropagation(); + } + + function testEventHandlerAfter() { + global $EVENT_HANDLER; + $this->prepare(); + $EVENT_HANDLER->register_hook('PAGEUTILS_ID_HIDEPAGE', 'AFTER', $this, 'alwaysHide'); + + $this->assertTrue(isHiddenPage('another')); + } + + function testEventHandlerAfterHide() { + global $EVENT_HANDLER; + $this->prepare(); + $EVENT_HANDLER->register_hook('PAGEUTILS_ID_HIDEPAGE', 'AFTER', $this, 'hideBeforeWithoutPrevent'); + + $this->assertTrue(isHiddenPage('another')); + } + + function hideBeforeWithoutPrevent(Doku_Event &$event, $params) { + $event->data['hidden'] = true; + } + + function testEventHandlerAfterShow() { + global $EVENT_HANDLER; + $this->prepare(); + $EVENT_HANDLER->register_hook('PAGEUTILS_ID_HIDEPAGE', 'AFTER', $this, 'showAfter'); + + $this->assertFalse(isHiddenPage('test')); + } + + function showAfter(Doku_Event &$event, $params) { + $event->data['hidden'] = false; + } + +} +//Setup VIM: ex: et ts=4 : diff --git a/_test/tests/inc/html_hilight.test.php b/_test/tests/inc/html_hilight.test.php index bb0cdd424..fc4eced67 100644 --- a/_test/tests/inc/html_hilight.test.php +++ b/_test/tests/inc/html_hilight.test.php @@ -97,4 +97,36 @@ class html_hilight_test extends DokuWikiTest { html_hilight($html,'x/') ); } + + function testMB() { + $html = 'foo ДокуВики bar'; + $this->assertRegExp( + '/foo <span.*>ДокуВики<\/span> bar/', + html_hilight($html,'ДокуВики') + ); + } + + function testMBright() { + $html = 'foo ДокуВики bar'; + $this->assertRegExp( + '/foo <span.*>Доку<\/span>Вики bar/', + html_hilight($html,'Доку*') + ); + } + + function testMBleft() { + $html = 'foo ДокуВики bar'; + $this->assertRegExp( + '/foo Доку<span.*>Вики<\/span> bar/', + html_hilight($html,'*Вики') + ); + } + + function testMBboth() { + $html = 'foo ДокуВики bar'; + $this->assertRegExp( + '/foo До<span.*>куВи<\/span>ки bar/', + html_hilight($html,'*куВи*') + ); + } } diff --git a/_test/tests/inc/indexer_histogram.test.php b/_test/tests/inc/indexer_histogram.test.php new file mode 100644 index 000000000..df6af7a2b --- /dev/null +++ b/_test/tests/inc/indexer_histogram.test.php @@ -0,0 +1,19 @@ +<?php +/** + * Tests the histogram function of the indexer. + * + * @author Michael Hamann <michael@content-space.de> + */ +class indexer_histogram_test extends DokuWikiTest { + function test_minlength() { + $indexer = idx_get_indexer(); + $indexer->addMetaKeys('histo1', 'testkey', array('foo', 'bar', 'foobar')); + $indexer->addMetaKeys('histo2', 'testkey', array('bar', 'testing')); + $indexer->addMetaKeys('histo3', 'testkey', array('foo', 'foobar')); + $histogram4 = $indexer->histogram(1, 0, 4, 'testkey'); + $this->assertEquals(array('foobar' => 2, 'testing' => 1), $histogram4); + $histogram2 = $indexer->histogram(1, 0, 2, 'testkey'); + $this->assertEquals(array('foobar' => 2, 'testing' => 1, 'foo' => 2, 'bar' => 2), $histogram2); + } + +} diff --git a/_test/tests/inc/input.test.php b/_test/tests/inc/input.test.php index 761b7ddbc..59b5ea4b9 100644 --- a/_test/tests/inc/input.test.php +++ b/_test/tests/inc/input.test.php @@ -12,7 +12,8 @@ class input_test extends DokuWikiTest { 'zero' => '0', 'one' => '1', 'empty' => '', - 'emptya' => array() + 'emptya' => array(), + 'do' => array('save' => 'Speichern'), ); public function test_str() { @@ -213,4 +214,20 @@ class input_test extends DokuWikiTest { $this->assertEquals('bla',$test); } + public function test_extract(){ + $_REQUEST = $this->data; + $_POST = $this->data; + $_GET = $this->data; + $INPUT = new Input(); + + $this->assertEquals('save', $INPUT->extract('do')->str('do')); + $this->assertEquals('', $INPUT->extract('emptya')->str('emptya')); + $this->assertEquals('foo', $INPUT->extract('string')->str('string')); + $this->assertEquals('foo', $INPUT->extract('array')->str('array')); + + $this->assertEquals('save', $INPUT->post->extract('do')->str('do')); + $this->assertEquals('', $INPUT->post->extract('emptya')->str('emptya')); + $this->assertEquals('foo', $INPUT->post->extract('string')->str('string')); + $this->assertEquals('foo', $INPUT->post->extract('array')->str('array')); + } } diff --git a/_test/tests/inc/parserutils_set_metadata_during_rendering.test.php b/_test/tests/inc/parserutils_set_metadata_during_rendering.test.php index 0683848f1..f08785ca2 100644 --- a/_test/tests/inc/parserutils_set_metadata_during_rendering.test.php +++ b/_test/tests/inc/parserutils_set_metadata_during_rendering.test.php @@ -50,7 +50,8 @@ class parserutils_set_metadata_during_rendering_test extends DokuWikiTest { function helper_set_metadata($event, $meta) { if ($this->active) { p_set_metadata($this->id, $meta, false, true); - $key = array_pop(array_keys($meta)); + $keys = array_keys($meta); + $key = array_pop($keys); $this->assertTrue(is_string($meta[$key])); // ensure we really have a key // ensure that the metadata property hasn't been set previously $this->assertNotEquals($meta[$key], p_get_metadata($this->id, $key)); diff --git a/_test/tests/inc/subscription_set.test.php b/_test/tests/inc/subscription_set.test.php new file mode 100644 index 000000000..5c0a6c816 --- /dev/null +++ b/_test/tests/inc/subscription_set.test.php @@ -0,0 +1,20 @@ +<?php +/** + * Tests the subscription set function + */ +class subscription_set_test extends DokuWikiTest { + /** + * Tests, if overwriting subscriptions works even when subscriptions for the same + * user exist for two nested namespaces, this is a test for the bug described in FS#2580 + */ + function test_overwrite() { + subscription_set('admin', ':', 'digest', '123456789'); + subscription_set('admin', ':wiki:', 'digest', '123456789'); + subscription_set('admin', ':', 'digest', '1234', true); + subscription_set('admin', ':wiki:', 'digest', '1234', true); + $subscriptions = subscription_find(':wiki:', array('user' => 'admin')); + $this->assertCount(1, $subscriptions[':'], 'More than one subscription saved for the root namespace even though the old one should have been overwritten.'); + $this->assertCount(1, $subscriptions[':wiki:'], 'More than one subscription saved for the wiki namespace even though the old one should have been overwritten.'); + $this->assertCount(2, $subscriptions, 'Didn\'t find the expected two subscriptions'); + } +} diff --git a/_test/tests/inc/tar.test.php b/_test/tests/inc/tar.test.php new file mode 100644 index 000000000..e8805a75d --- /dev/null +++ b/_test/tests/inc/tar.test.php @@ -0,0 +1,319 @@ +<?php + +class Tar_TestCase extends DokuWikiTest { + + /** + * simple test that checks that the given filenames and contents can be grepped from + * the uncompressed tar stream + * + * No check for format correctness + */ + public function test_createdynamic() { + $tar = new Tar(); + + $dir = dirname(__FILE__).'/tar'; + + $tar->create(); + $tar->AddFile("$dir/testdata1.txt"); + $tar->AddFile("$dir/foobar/testdata2.txt", 'noway/testdata2.txt'); + $tar->addData('another/testdata3.txt', 'testcontent3'); + + $data = $tar->getArchive(); + + $this->assertTrue(strpos($data, 'testcontent1') !== false, 'Content in TAR'); + $this->assertTrue(strpos($data, 'testcontent2') !== false, 'Content in TAR'); + $this->assertTrue(strpos($data, 'testcontent3') !== false, 'Content in TAR'); + + $this->assertTrue(strpos($data, "$dir/testdata1.txt") !== false, 'Path in TAR'); + $this->assertTrue(strpos($data, 'noway/testdata2.txt') !== false, 'Path in TAR'); + $this->assertTrue(strpos($data, 'another/testdata3.txt') !== false, 'Path in TAR'); + + $this->assertTrue(strpos($data, "$dir/foobar/testdata2.txt") === false, 'Path not in TAR'); + $this->assertTrue(strpos($data, "foobar") === false, 'Path not in TAR'); + } + + /** + * simple test that checks that the given filenames and contents can be grepped from the + * uncompressed tar file + * + * No check for format correctness + */ + public function test_createfile() { + $tar = new Tar(); + + $dir = dirname(__FILE__).'/tar'; + $tmp = tempnam(sys_get_temp_dir(), 'dwtartest'); + + $tar->create($tmp, Tar::COMPRESS_NONE); + $tar->AddFile("$dir/testdata1.txt"); + $tar->AddFile("$dir/foobar/testdata2.txt", 'noway/testdata2.txt'); + $tar->addData('another/testdata3.txt', 'testcontent3'); + $tar->close(); + + $this->assertTrue(filesize($tmp) > 30); //arbitrary non-zero number + $data = file_get_contents($tmp); + + $this->assertTrue(strpos($data, 'testcontent1') !== false, 'Content in TAR'); + $this->assertTrue(strpos($data, 'testcontent2') !== false, 'Content in TAR'); + $this->assertTrue(strpos($data, 'testcontent3') !== false, 'Content in TAR'); + + $this->assertTrue(strpos($data, "$dir/testdata1.txt") !== false, 'Path in TAR'); + $this->assertTrue(strpos($data, 'noway/testdata2.txt') !== false, 'Path in TAR'); + $this->assertTrue(strpos($data, 'another/testdata3.txt') !== false, 'Path in TAR'); + + $this->assertTrue(strpos($data, "$dir/foobar/testdata2.txt") === false, 'Path not in TAR'); + $this->assertTrue(strpos($data, "foobar") === false, 'Path not in TAR'); + + @unlink($tmp); + } + + /** + * List the contents of the prebuilt TAR files + */ + public function test_tarcontent() { + $dir = dirname(__FILE__).'/tar'; + + foreach(array('tar', 'tgz', 'tbz') as $ext) { + $tar = new Tar(); + $file = "$dir/test.$ext"; + + $tar->open($file); + $content = $tar->contents(); + + $this->assertCount(4, $content, "Contents of $file"); + $this->assertEquals('tar/testdata1.txt', $content[1]['filename'], "Contents of $file"); + $this->assertEquals(13, $content[1]['size'], "Contents of $file"); + + $this->assertEquals('tar/foobar/testdata2.txt', $content[3]['filename'], "Contents of $file"); + $this->assertEquals(13, $content[1]['size'], "Contents of $file"); + } + } + + /** + * Extract the prebuilt tar files + */ + public function test_tarextract() { + $dir = dirname(__FILE__).'/tar'; + $out = sys_get_temp_dir().'/dwtartest'.md5(time()); + + foreach(array('tar', 'tgz', 'tbz') as $ext) { + $tar = new Tar(); + $file = "$dir/test.$ext"; + + $tar->open($file); + $tar->extract($out); + + clearstatcache(); + + $this->assertFileExists($out.'/tar/testdata1.txt', "Extracted $file"); + $this->assertEquals(13, filesize($out.'/tar/testdata1.txt'), "Extracted $file"); + + $this->assertFileExists($out.'/tar/foobar/testdata2.txt', "Extracted $file"); + $this->assertEquals(13, filesize($out.'/tar/foobar/testdata2.txt'), "Extracted $file"); + + TestUtils::rdelete($out); + } + } + + /** + * Extract the prebuilt tar files with component stripping + */ + public function test_compstripextract() { + $dir = dirname(__FILE__).'/tar'; + $out = sys_get_temp_dir().'/dwtartest'.md5(time()); + + foreach(array('tar', 'tgz', 'tbz') as $ext) { + $tar = new Tar(); + $file = "$dir/test.$ext"; + + $tar->open($file); + $tar->extract($out, 1); + + clearstatcache(); + + $this->assertFileExists($out.'/testdata1.txt', "Extracted $file"); + $this->assertEquals(13, filesize($out.'/testdata1.txt'), "Extracted $file"); + + $this->assertFileExists($out.'/foobar/testdata2.txt', "Extracted $file"); + $this->assertEquals(13, filesize($out.'/foobar/testdata2.txt'), "Extracted $file"); + + TestUtils::rdelete($out); + } + } + + /** + * Extract the prebuilt tar files with prefix stripping + */ + public function test_prefixstripextract() { + $dir = dirname(__FILE__).'/tar'; + $out = sys_get_temp_dir().'/dwtartest'.md5(time()); + + foreach(array('tar', 'tgz', 'tbz') as $ext) { + $tar = new Tar(); + $file = "$dir/test.$ext"; + + $tar->open($file); + $tar->extract($out, 'tar/foobar/'); + + clearstatcache(); + + $this->assertFileExists($out.'/tar/testdata1.txt', "Extracted $file"); + $this->assertEquals(13, filesize($out.'/tar/testdata1.txt'), "Extracted $file"); + + $this->assertFileExists($out.'/testdata2.txt', "Extracted $file"); + $this->assertEquals(13, filesize($out.'/testdata2.txt'), "Extracted $file"); + + TestUtils::rdelete($out); + } + } + + /** + * Extract the prebuilt tar files with include regex + */ + public function test_includeextract() { + $dir = dirname(__FILE__).'/tar'; + $out = sys_get_temp_dir().'/dwtartest'.md5(time()); + + foreach(array('tar', 'tgz', 'tbz') as $ext) { + $tar = new Tar(); + $file = "$dir/test.$ext"; + + $tar->open($file); + $tar->extract($out, '', '', '/\/foobar\//'); + + clearstatcache(); + + $this->assertFileNotExists($out.'/tar/testdata1.txt', "Extracted $file"); + + $this->assertFileExists($out.'/tar/foobar/testdata2.txt', "Extracted $file"); + $this->assertEquals(13, filesize($out.'/tar/foobar/testdata2.txt'), "Extracted $file"); + + TestUtils::rdelete($out); + } + } + + /** + * Extract the prebuilt tar files with exclude regex + */ + public function test_excludeextract() { + $dir = dirname(__FILE__).'/tar'; + $out = sys_get_temp_dir().'/dwtartest'.md5(time()); + + foreach(array('tar', 'tgz', 'tbz') as $ext) { + $tar = new Tar(); + $file = "$dir/test.$ext"; + + $tar->open($file); + $tar->extract($out, '', '/\/foobar\//'); + + clearstatcache(); + + $this->assertFileExists($out.'/tar/testdata1.txt', "Extracted $file"); + $this->assertEquals(13, filesize($out.'/tar/testdata1.txt'), "Extracted $file"); + + $this->assertFileNotExists($out.'/tar/foobar/testdata2.txt', "Extracted $file"); + + TestUtils::rdelete($out); + } + } + + /** + * Check the extension to compression guesser + */ + public function test_filetype() { + $tar = new Tar(); + $this->assertEquals(Tar::COMPRESS_NONE, $tar->filetype('foo')); + $this->assertEquals(Tar::COMPRESS_GZIP, $tar->filetype('foo.tgz')); + $this->assertEquals(Tar::COMPRESS_GZIP, $tar->filetype('foo.tGZ')); + $this->assertEquals(Tar::COMPRESS_GZIP, $tar->filetype('foo.tar.GZ')); + $this->assertEquals(Tar::COMPRESS_GZIP, $tar->filetype('foo.tar.gz')); + $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tbz')); + $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tBZ')); + $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tar.BZ2')); + $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tar.bz2')); + } + + public function test_longpathextract() { + $dir = dirname(__FILE__).'/tar'; + $out = sys_get_temp_dir().'/dwtartest'.md5(time()); + + foreach(array('ustar', 'gnu') as $format) { + $tar = new Tar(); + $tar->open("$dir/longpath-$format.tgz"); + $tar->extract($out); + + $this->assertFileExists($out.'/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/test.txt'); + + TestUtils::rdelete($out); + } + } + + public function test_createlongpathustar() { + $tar = new Tar(); + $tmp = tempnam(sys_get_temp_dir(), 'dwtartest'); + + $path = ''; + for($i=0; $i<11; $i++) $path .= '1234567890/'; + $path = rtrim($path,'/'); + + $tar->create($tmp, Tar::COMPRESS_NONE); + $tar->addData("$path/test.txt", 'testcontent1'); + $tar->close(); + + $this->assertTrue(filesize($tmp) > 30); //arbitrary non-zero number + $data = file_get_contents($tmp); + + // We should find the path and filename separated, no longlink entry + $this->assertTrue(strpos($data, 'testcontent1') !== false, 'content in TAR'); + $this->assertTrue(strpos($data, 'test.txt') !== false, 'filename in TAR'); + $this->assertTrue(strpos($data, $path) !== false, 'path in TAR'); + $this->assertFalse(strpos($data, "$path/test.txt") !== false, 'full filename in TAR'); + $this->assertFalse(strpos($data, '@LongLink') !== false, '@LongLink in TAR'); + + @unlink($tmp); + } + + public function test_createlongpathgnu() { + $tar = new Tar(); + $tmp = tempnam(sys_get_temp_dir(), 'dwtartest'); + + $path = ''; + for($i=0; $i<20; $i++) $path .= '1234567890/'; + $path = rtrim($path,'/'); + + $tar->create($tmp, Tar::COMPRESS_NONE); + $tar->addData("$path/test.txt", 'testcontent1'); + $tar->close(); + + $this->assertTrue(filesize($tmp) > 30); //arbitrary non-zero number + $data = file_get_contents($tmp); + + // We should find the complete path/filename and a longlink entry + $this->assertTrue(strpos($data, 'testcontent1') !== false, 'content in TAR'); + $this->assertTrue(strpos($data, 'test.txt') !== false, 'filename in TAR'); + $this->assertTrue(strpos($data, $path) !== false, 'path in TAR'); + $this->assertTrue(strpos($data, "$path/test.txt") !== false, 'full filename in TAR'); + $this->assertTrue(strpos($data, '@LongLink') !== false, '@LongLink in TAR'); + + @unlink($tmp); + } + + /** + * Extract a tarbomomb + */ + public function test_tarbomb() { + $dir = dirname(__FILE__).'/tar'; + $out = sys_get_temp_dir().'/dwtartest'.md5(time()); + + $tar = new Tar(); + + $tar->open("$dir/tarbomb.tgz"); + $tar->extract($out); + + clearstatcache(); + + $this->assertFileExists($out.'/AAAAAAAAAAAAAAAAA/BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB.txt'); + + TestUtils::rdelete($out); + } +}
\ No newline at end of file diff --git a/_test/tests/inc/tar/foobar/testdata2.txt b/_test/tests/inc/tar/foobar/testdata2.txt new file mode 100644 index 000000000..a7db15771 --- /dev/null +++ b/_test/tests/inc/tar/foobar/testdata2.txt @@ -0,0 +1 @@ +testcontent2 diff --git a/_test/tests/inc/tar/longpath-gnu.tgz b/_test/tests/inc/tar/longpath-gnu.tgz Binary files differnew file mode 100644 index 000000000..6c937c8fe --- /dev/null +++ b/_test/tests/inc/tar/longpath-gnu.tgz diff --git a/_test/tests/inc/tar/longpath-ustar.tgz b/_test/tests/inc/tar/longpath-ustar.tgz Binary files differnew file mode 100644 index 000000000..59efbff66 --- /dev/null +++ b/_test/tests/inc/tar/longpath-ustar.tgz diff --git a/_test/tests/inc/tar/tarbomb.tgz b/_test/tests/inc/tar/tarbomb.tgz Binary files differnew file mode 100644 index 000000000..8418d4073 --- /dev/null +++ b/_test/tests/inc/tar/tarbomb.tgz diff --git a/_test/tests/inc/tar/test.tar b/_test/tests/inc/tar/test.tar Binary files differnew file mode 100644 index 000000000..931866b0b --- /dev/null +++ b/_test/tests/inc/tar/test.tar diff --git a/_test/tests/inc/tar/test.tbz b/_test/tests/inc/tar/test.tbz Binary files differnew file mode 100644 index 000000000..5a7374019 --- /dev/null +++ b/_test/tests/inc/tar/test.tbz diff --git a/_test/tests/inc/tar/test.tgz b/_test/tests/inc/tar/test.tgz Binary files differnew file mode 100644 index 000000000..b00319649 --- /dev/null +++ b/_test/tests/inc/tar/test.tgz diff --git a/_test/tests/inc/tar/testdata1.txt b/_test/tests/inc/tar/testdata1.txt new file mode 100644 index 000000000..ac65bb32e --- /dev/null +++ b/_test/tests/inc/tar/testdata1.txt @@ -0,0 +1 @@ +testcontent1 diff --git a/_test/tests/inc/template_sidebar.test.php b/_test/tests/inc/template_include_page.test.php index 56153894a..47d4d46f1 100644 --- a/_test/tests/inc/template_sidebar.test.php +++ b/_test/tests/inc/template_include_page.test.php @@ -1,12 +1,12 @@ <?php -class template_sidebar_test extends DokuWikiTest { +class template_include_page_test extends DokuWikiTest { function testNoSidebar() { global $ID; $ID = 'foo:bar:baz:test'; - $sidebar = tpl_sidebar(false); - $this->assertEquals('',$sidebar); + $sidebar = tpl_include_page('sidebar', false, true); + $this->assertEquals('', $sidebar); } function testExistingSidebars() { @@ -15,25 +15,25 @@ class template_sidebar_test extends DokuWikiTest { saveWikiText('sidebar', 'topsidebar-test', ''); $ID = 'foo:bar:baz:test'; - $sidebar = tpl_sidebar(false); + $sidebar = tpl_include_page('sidebar', false, true); $this->assertTrue(strpos($sidebar, 'topsidebar-test') > 0); $ID = 'foo'; - $sidebar = tpl_sidebar(false); + $sidebar = tpl_include_page('sidebar', false, true); $this->assertTrue(strpos($sidebar, 'topsidebar-test') > 0); saveWikiText('foo:bar:sidebar', 'bottomsidebar-test', ''); $ID = 'foo:bar:baz:test'; - $sidebar = tpl_sidebar(false); + $sidebar = tpl_include_page('sidebar', false, true); $this->assertTrue(strpos($sidebar, 'bottomsidebar-test') > 0); $ID = 'foo:bar:test'; - $sidebar = tpl_sidebar(false); + $sidebar = tpl_include_page('sidebar', false, true); $this->assertTrue(strpos($sidebar, 'bottomsidebar-test') > 0); $ID = 'foo'; - $sidebar = tpl_sidebar(false); + $sidebar = tpl_include_page('sidebar', false, true); $this->assertTrue(strpos($sidebar, 'topsidebar-test') > 0); } diff --git a/_test/tests/inc/utf8_basename.test.php b/_test/tests/inc/utf8_basename.test.php new file mode 100644 index 000000000..1544e9915 --- /dev/null +++ b/_test/tests/inc/utf8_basename.test.php @@ -0,0 +1,91 @@ +<?php + +class utf8_basename_test extends DokuWikiTest { + + function test1(){ + $data = array( + array('/this/foo/bar.test.png', '', 'bar.test.png'), + array('\\this\\foo\\bar.test.png', '', 'bar.test.png'), + array('/this\\foo/bar.test.png', '', 'bar.test.png'), + array('/this/foo\\bar.test.png', '', 'bar.test.png'), + + array('/this/ДокуВики/bar.test.png', '', 'bar.test.png'), + array('\\this\\ДокуВики\\bar.test.png', '', 'bar.test.png'), + array('/this\\ДокуВики/bar.test.png', '', 'bar.test.png'), + array('/this/ДокуВики\\bar.test.png', '', 'bar.test.png'), + + array('/this/foo/ДокуВики.test.png', '', 'ДокуВики.test.png'), + array('\\this\\foo\\ДокуВики.test.png', '', 'ДокуВики.test.png'), + array('/this\\foo/ДокуВики.test.png', '', 'ДокуВики.test.png'), + array('/this/foo\\ДокуВики.test.png', '', 'ДокуВики.test.png'), + + array('/this/foo/bar.test.png', '.png', 'bar.test'), + array('\\this\\foo\\bar.test.png', '.png', 'bar.test'), + array('/this\\foo/bar.test.png', '.png', 'bar.test'), + array('/this/foo\\bar.test.png', '.png', 'bar.test'), + + array('/this/ДокуВики/bar.test.png', '.png', 'bar.test'), + array('\\this\\ДокуВики\\bar.test.png', '.png', 'bar.test'), + array('/this\\ДокуВики/bar.test.png', '.png', 'bar.test'), + array('/this/ДокуВики\\bar.test.png', '.png', 'bar.test'), + + array('/this/foo/ДокуВики.test.png', '.png', 'ДокуВики.test'), + array('\\this\\foo\\ДокуВики.test.png', '.png', 'ДокуВики.test'), + array('/this\\foo/ДокуВики.test.png', '.png', 'ДокуВики.test'), + array('/this/foo\\ДокуВики.test.png', '.png', 'ДокуВики.test'), + + array('/this/foo/bar.test.png', '.foo', 'bar.test.png'), + array('\\this\\foo\\bar.test.png', '.foo', 'bar.test.png'), + array('/this\\foo/bar.test.png', '.foo', 'bar.test.png'), + array('/this/foo\\bar.test.png', '.foo', 'bar.test.png'), + + array('/this/ДокуВики/bar.test.png', '.foo', 'bar.test.png'), + array('\\this\\ДокуВики\\bar.test.png', '.foo', 'bar.test.png'), + array('/this\\ДокуВики/bar.test.png', '.foo', 'bar.test.png'), + array('/this/ДокуВики\\bar.test.png', '.foo', 'bar.test.png'), + + array('/this/foo/ДокуВики.test.png', '.foo', 'ДокуВики.test.png'), + array('\\this\\foo\\ДокуВики.test.png', '.foo', 'ДокуВики.test.png'), + array('/this\\foo/ДокуВики.test.png', '.foo', 'ДокуВики.test.png'), + array('/this/foo\\ДокуВики.test.png', '.foo', 'ДокуВики.test.png'), + + + array('/this/foo/ДокуВики.test.Вик', '.foo', 'ДокуВики.test.Вик'), + array('\\this\\foo\\ДокуВики.test.Вик', '.foo', 'ДокуВики.test.Вик'), + array('/this\\foo/ДокуВики.test.Вик', '.foo', 'ДокуВики.test.Вик'), + array('/this/foo\\ДокуВики.test.Вик', '.foo', 'ДокуВики.test.Вик'), + + array('/this/foo/ДокуВики.test.Вик', '.Вик', 'ДокуВики.test'), + array('\\this\\foo\\ДокуВики.test.Вик', '.Вик', 'ДокуВики.test'), + array('/this\\foo/ДокуВики.test.Вик', '.Вик', 'ДокуВики.test'), + array('/this/foo\\ДокуВики.test.Вик', '.Вик', 'ДокуВики.test'), + + array('bar.test.png', '', 'bar.test.png'), + array('bar.test.png', '.png', 'bar.test'), + + array('/bar.test.png', '', 'bar.test.png'), + array('/bar.test.png', '.png', 'bar.test'), + array('\\bar.test.png', '', 'bar.test.png'), + array('\\bar.test.png', '.png', 'bar.test'), + array('\\/bar.test.png', '', 'bar.test.png'), + array('\\/bar.test.png', '.png', 'bar.test'), + array('/\\bar.test.png', '', 'bar.test.png'), + array('/\\bar.test.png', '.png', 'bar.test'), + + // PHP's basename does this too: + array('foo/', '', 'foo'), + array('foo\\', '', 'foo'), + array('foo\\/', '', 'foo'), + array('foo/\\', '', 'foo'), + array('foo.png/', '.png', 'foo'), + array('foo.png\\', '.png', 'foo'), + array('foo.png\\/', '.png', 'foo'), + array('foo.png/\\', '.png', 'foo'), + ); + + foreach($data as $test){ + $this->assertEquals($test[2], utf8_basename($test[0], $test[1]), "input: ('".$test[0]."', '".$test[1]."')"); + } + } + +}
\ No newline at end of file |