summaryrefslogtreecommitdiff
path: root/_test/tests
diff options
context:
space:
mode:
Diffstat (limited to '_test/tests')
-rw-r--r--_test/tests/inc/auth_password.test.php9
-rw-r--r--_test/tests/inc/form_form.test.php4
-rw-r--r--_test/tests/inc/io_deletefromfile.test.php15
-rw-r--r--_test/tests/inc/io_readfile.test.php7
-rw-r--r--_test/tests/inc/io_readfile/large.txt.bz2bin0 -> 47 bytes
-rw-r--r--_test/tests/inc/io_readfile/long.txt.bz2bin0 -> 53 bytes
-rw-r--r--_test/tests/inc/io_replaceinfile.test.php108
-rw-r--r--_test/tests/inc/io_savefile.test.php49
-rw-r--r--_test/tests/inc/ixr_library_date.test.php13
-rw-r--r--_test/tests/inc/parser/lexer.test.php4
-rw-r--r--_test/tests/inc/parser/renderer_resolveinterwiki.test.php22
-rw-r--r--_test/tests/inc/remote.test.php8
-rw-r--r--_test/tests/inc/tar.test.php454
-rw-r--r--_test/tests/inc/tar/block.txt1
-rw-r--r--_test/tests/inc/tar/foobar/testdata2.txt1
-rw-r--r--_test/tests/inc/tar/longpath-gnu.tgzbin413 -> 0 bytes
-rw-r--r--_test/tests/inc/tar/longpath-ustar.tgzbin311 -> 0 bytes
-rw-r--r--_test/tests/inc/tar/tarbomb.tgzbin183 -> 0 bytes
-rw-r--r--_test/tests/inc/tar/test.tarbin10240 -> 0 bytes
-rw-r--r--_test/tests/inc/tar/test.tbzbin217 -> 0 bytes
-rw-r--r--_test/tests/inc/tar/test.tgzbin220 -> 0 bytes
-rw-r--r--_test/tests/inc/tar/testdata1.txt1
-rw-r--r--_test/tests/inc/tar/zero.txt0
-rw-r--r--_test/tests/inc/template_include_page.test.php77
24 files changed, 272 insertions, 501 deletions
diff --git a/_test/tests/inc/auth_password.test.php b/_test/tests/inc/auth_password.test.php
index 07b9f5bb2..5067e2ca1 100644
--- a/_test/tests/inc/auth_password.test.php
+++ b/_test/tests/inc/auth_password.test.php
@@ -16,9 +16,16 @@ class auth_password_test extends DokuWikiTest {
'kmd5' => 'a579299436d7969791189acadd86fcb716',
'djangomd5' => 'md5$abcde$d0fdddeda8cd92725d2b54148ac09158',
'djangosha1' => 'sha1$abcde$c8e65a7f0acc9158843048a53dcc5a6bc4d17678',
- 'sha512' => '$6$abcdefgh12345678$J9.zOcgx0lotwZdcz0uulA3IVQMinZvFZVjA5vapRLVAAqtay23XD4xeeUxQ3B4JvDWYFBIxVWW1tOYlHX13k1'
+
);
+ function __construct() {
+ if(defined('CRYPT_SHA512') && CRYPT_SHA512 == 1) {
+ // Check SHA512 only if available in this PHP
+ $this->passes['sha512'] = '$6$abcdefgh12345678$J9.zOcgx0lotwZdcz0uulA3IVQMinZvFZVjA5vapRLVAAqtay23XD4xeeUxQ3B4JvDWYFBIxVWW1tOYlHX13k1';
+ }
+ }
+
function test_cryptPassword(){
foreach($this->passes as $method => $hash){
diff --git a/_test/tests/inc/form_form.test.php b/_test/tests/inc/form_form.test.php
index 02242a807..7f168b895 100644
--- a/_test/tests/inc/form_form.test.php
+++ b/_test/tests/inc/form_form.test.php
@@ -30,9 +30,9 @@ class form_test extends DokuWikiTest {
$realoutput .= '<input type="checkbox" id="check__id" name="r" value="1" /> ';
$realoutput .= '<span>Check</span></label>';
$realoutput .= "\n";
- $realoutput .= '<input name="do[save]" type="submit" value="Save" class="button" accesskey="s" title="Save [S]" />';
+ $realoutput .= '<button name="do[save]" type="submit" accesskey="s" title="Save [S]">Save</button>';
$realoutput .= "\n";
- $realoutput .= '<input name="do[cancel]" type="submit" value="Cancel" class="button" />';
+ $realoutput .= '<button name="do[cancel]" type="submit">Cancel</button>';
$realoutput .= "\n";
$realoutput .= "</fieldset>\n</div></form>\n";
return $realoutput;
diff --git a/_test/tests/inc/io_deletefromfile.test.php b/_test/tests/inc/io_deletefromfile.test.php
new file mode 100644
index 000000000..e86150aac
--- /dev/null
+++ b/_test/tests/inc/io_deletefromfile.test.php
@@ -0,0 +1,15 @@
+<?php
+
+class io_deletefromfile_test extends DokuWikiTest {
+
+ function test_delete(){
+ $file = TMP_DIR.'/test.txt';
+ $contents = "The\012Delete\012Delete01\012Delete02\012Delete\012DeleteX\012Test\012";
+ io_saveFile($file, $contents);
+ $this->assertTrue(io_deleteFromFile($file, "Delete\012"));
+ $this->assertEquals("The\012Delete01\012Delete02\012DeleteX\012Test\012", io_readFile($file));
+ $this->assertTrue(io_deleteFromFile($file, "#Delete\\d+\012#", true));
+ $this->assertEquals("The\012DeleteX\012Test\012", io_readFile($file));
+ }
+
+}
diff --git a/_test/tests/inc/io_readfile.test.php b/_test/tests/inc/io_readfile.test.php
index e3e90cd8d..700c1902b 100644
--- a/_test/tests/inc/io_readfile.test.php
+++ b/_test/tests/inc/io_readfile.test.php
@@ -48,6 +48,11 @@ class io_readfile_test extends DokuWikiTest {
$this->assertEquals("The\015\012Test\015\012", io_readFile(__DIR__.'/io_readfile/test.txt.bz2', false));
$this->assertEquals(false, io_readFile(__DIR__.'/io_readfile/nope.txt.bz2'));
$this->assertEquals(false, io_readFile(__DIR__.'/io_readfile/corrupt.txt.bz2'));
+ // internal bzfile function
+ $this->assertEquals(array("The\015\012","Test\015\012"), bzfile(__DIR__.'/io_readfile/test.txt.bz2', true));
+ $this->assertEquals(array_fill(0, 120, str_repeat('a', 80)."\012"), bzfile(__DIR__.'/io_readfile/large.txt.bz2', true));
+ $line = str_repeat('a', 8888)."\012";
+ $this->assertEquals(array($line,"\012",$line,"!"), bzfile(__DIR__.'/io_readfile/long.txt.bz2', true));
}
-} \ No newline at end of file
+}
diff --git a/_test/tests/inc/io_readfile/large.txt.bz2 b/_test/tests/inc/io_readfile/large.txt.bz2
new file mode 100644
index 000000000..3135435f8
--- /dev/null
+++ b/_test/tests/inc/io_readfile/large.txt.bz2
Binary files differ
diff --git a/_test/tests/inc/io_readfile/long.txt.bz2 b/_test/tests/inc/io_readfile/long.txt.bz2
new file mode 100644
index 000000000..fb40759e6
--- /dev/null
+++ b/_test/tests/inc/io_readfile/long.txt.bz2
Binary files differ
diff --git a/_test/tests/inc/io_replaceinfile.test.php b/_test/tests/inc/io_replaceinfile.test.php
new file mode 100644
index 000000000..452ed7401
--- /dev/null
+++ b/_test/tests/inc/io_replaceinfile.test.php
@@ -0,0 +1,108 @@
+<?php
+
+class io_replaceinfile_test extends DokuWikiTest {
+
+ protected $contents = "The\012Delete\012Delete\012Delete01\012Delete02\012Delete\012DeleteX\012Test\012";
+
+ /*
+ * dependency for tests needing zlib extension to pass
+ */
+ public function test_ext_zlib() {
+ if (!extension_loaded('zlib')) {
+ $this->markTestSkipped('skipping all zlib tests. Need zlib extension');
+ }
+ }
+
+ /*
+ * dependency for tests needing zlib extension to pass
+ */
+ public function test_ext_bz2() {
+ if (!extension_loaded('bz2')) {
+ $this->markTestSkipped('skipping all bzip2 tests. Need bz2 extension');
+ }
+ }
+
+ function _write($file){
+
+ io_saveFile($file, $this->contents);
+ // Replace one, no regex
+ $this->assertTrue(io_replaceInFile($file, "Delete\012", "Delete00\012", false, 1));
+ $this->assertEquals("The\012Delete00\012Delete\012Delete01\012Delete02\012Delete\012DeleteX\012Test\012", io_readFile($file));
+ // Replace all, no regex
+ $this->assertTrue(io_replaceInFile($file, "Delete\012", "DeleteX\012", false, -1));
+ $this->assertEquals("The\012Delete00\012DeleteX\012Delete01\012Delete02\012DeleteX\012DeleteX\012Test\012", io_readFile($file));
+ // Replace two, regex and backreference
+ $this->assertTrue(io_replaceInFile($file, "#Delete(\\d+)\012#", "\\1\012", true, 2));
+ $this->assertEquals("The\01200\012DeleteX\01201\012Delete02\012DeleteX\012DeleteX\012Test\012", io_readFile($file));
+ // Delete and insert, no regex
+ $this->assertTrue(io_replaceInFile($file, "DeleteX\012", "Replace\012", false, 0));
+ $this->assertEquals("The\01200\01201\012Delete02\012Test\012Replace\012", io_readFile($file));
+ }
+
+ function test_replace(){
+ $this->_write(TMP_DIR.'/test.txt');
+ }
+
+
+ /**
+ * @depends test_ext_zlib
+ */
+ function test_gzwrite(){
+ $this->_write(TMP_DIR.'/test.txt.gz');
+ }
+
+ /**
+ * @depends test_ext_bz2
+ */
+ function test_bzwrite(){
+ $this->_write(TMP_DIR.'/test.txt.bz2');
+ }
+
+ /**
+ * Test for a non-regex replacement where $newline contains a backreference like construct - it shouldn't affect the replacement
+ */
+ function test_edgecase1()
+ {
+ $file = TMP_DIR . '/test.txt';
+
+ io_saveFile($file, $this->contents);
+ $this->assertTrue(io_replaceInFile($file, "Delete\012", "Delete\\00\012", false, -1));
+ $this->assertEquals("The\012Delete\\00\012Delete\\00\012Delete01\012Delete02\012Delete\\00\012DeleteX\012Test\012", io_readFile($file), "Edge case: backreference like construct in replacement line");
+ }
+ /**
+ * Test with replace all where replacement line == search line - must not timeout
+ *
+ * @small
+ */
+ function test_edgecase2() {
+ $file = TMP_DIR.'/test.txt';
+
+ io_saveFile($file, $this->contents);
+ $this->assertTrue(io_replaceInFile($file, "Delete\012", "Delete\012", false, -1));
+ $this->assertEquals("The\012Delete\012Delete\012Delete01\012Delete02\012Delete\012DeleteX\012Test\012", io_readFile($file), "Edge case: new line the same as old line");
+ }
+
+ /**
+ * Test where $oldline exactly matches one line and also matches part of other lines - only the exact match should be replaced
+ */
+ function test_edgecase3()
+ {
+ $file = TMP_DIR . '/test.txt';
+ $contents = "The\012Delete\01201Delete\01202Delete\012Test\012";
+
+ io_saveFile($file, $contents);
+ $this->assertTrue(io_replaceInFile($file, "Delete\012", "Replace\012", false, -1));
+ $this->assertEquals("The\012Replace\01201Delete\01202Delete\012Test\012", io_readFile($file), "Edge case: old line is a match for parts of other lines");
+ }
+
+ /**
+ * Test passing an invalid parameter.
+ *
+ * @expectedException PHPUnit_Framework_Error_Warning
+ */
+ function test_badparam()
+ {
+ /* The empty $oldline parameter should be caught before the file doesn't exist test. */
+ $this->assertFalse(io_replaceInFile(TMP_DIR.'/not_existing_file.txt', '', '', false, 0));
+ }
+}
diff --git a/_test/tests/inc/io_savefile.test.php b/_test/tests/inc/io_savefile.test.php
new file mode 100644
index 000000000..4a4d4671d
--- /dev/null
+++ b/_test/tests/inc/io_savefile.test.php
@@ -0,0 +1,49 @@
+<?php
+
+class io_savefile_test extends DokuWikiTest {
+
+ /*
+ * dependency for tests needing zlib extension to pass
+ */
+ public function test_ext_zlib() {
+ if (!extension_loaded('zlib')) {
+ $this->markTestSkipped('skipping all zlib tests. Need zlib extension');
+ }
+ }
+
+ /*
+ * dependency for tests needing zlib extension to pass
+ */
+ public function test_ext_bz2() {
+ if (!extension_loaded('bz2')) {
+ $this->markTestSkipped('skipping all bzip2 tests. Need bz2 extension');
+ }
+ }
+
+ function _write($file){
+ $contents = "The\012Write\012Test\012";
+ $this->assertTrue(io_saveFile($file, $contents));
+ $this->assertEquals($contents, io_readFile($file));
+ $this->assertTrue(io_saveFile($file, $contents, true));
+ $this->assertEquals($contents.$contents, io_readFile($file));
+ }
+
+ function test_write(){
+ $this->_write(TMP_DIR.'/test.txt');
+ }
+
+ /**
+ * @depends test_ext_zlib
+ */
+ function test_gzwrite(){
+ $this->_write(TMP_DIR.'/test.txt.gz');
+ }
+
+ /**
+ * @depends test_ext_bz2
+ */
+ function test_bzwrite(){
+ $this->_write(TMP_DIR.'/test.txt.bz2');
+ }
+
+}
diff --git a/_test/tests/inc/ixr_library_date.test.php b/_test/tests/inc/ixr_library_date.test.php
index f38486925..0c81e6741 100644
--- a/_test/tests/inc/ixr_library_date.test.php
+++ b/_test/tests/inc/ixr_library_date.test.php
@@ -2,6 +2,9 @@
require_once DOKU_INC.'inc/IXR_Library.php';
+/**
+ * Class ixr_library_date_test
+ */
class ixr_library_date_test extends DokuWikiTest {
@@ -16,18 +19,24 @@ class ixr_library_date_test extends DokuWikiTest {
array('2010-08-17T09:23:14Z', 1282036994),
array('20100817T09:23:14Z', 1282036994),
+ // with timezone
+ array('2010-08-17 09:23:14+0000', 1282036994),
+ array('2010-08-17 09:23:14+00:00', 1282036994),
+ array('2010-08-17 12:23:14+03:00', 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
+ array(1282036980, 1282036980),
+// 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->assertEquals($dt->getTimeStamp(),$test[1]);
+ $this->assertEquals($test[1], $dt->getTimeStamp());
}
}
diff --git a/_test/tests/inc/parser/lexer.test.php b/_test/tests/inc/parser/lexer.test.php
index d0965a13e..c50665928 100644
--- a/_test/tests/inc/parser/lexer.test.php
+++ b/_test/tests/inc/parser/lexer.test.php
@@ -146,7 +146,7 @@ class TestOfLexerStateStack extends DokuWikiTest {
}
class TestParser {
- function TestParser() {
+ function __construct() {
}
function accept() {
}
@@ -364,7 +364,7 @@ class TestOfLexerHandlers extends DokuWikiTest {
class TestParserByteIndex {
- function TestParserByteIndex() {}
+ function __construct() {}
function ignore() {}
diff --git a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php
index dd1ed1d3f..772001b99 100644
--- a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php
+++ b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php
@@ -14,21 +14,23 @@ class Test_resolveInterwiki extends DokuWikiTest {
$Renderer->interwiki['withslash'] = '/test';
$Renderer->interwiki['onlytext'] = ':onlytext{NAME}'; //with {URL} double urlencoded
$Renderer->interwiki['withquery'] = ':anyns:{NAME}?do=edit';
+ //this was the only link with host/port/path/query. Keep it here for regression
+ $Renderer->interwiki['coral'] = 'http://{HOST}.{PORT}.nyud.net:8090{PATH}?{QUERY}';
$tests = array(
// shortcut, reference and expected
- array('wp', 'foo @+%/#txt', 'http://en.wikipedia.org/wiki/foo @+%/#txt'),
- array('amazon', 'foo @+%/#txt', 'http://www.amazon.com/exec/obidos/ASIN/foo%20%40%2B%25%2F/splitbrain-20/#txt'),
- array('doku', 'foo @+%/#txt', 'http://www.dokuwiki.org/foo%20%40%2B%25%2F#txt'),
- array('coral', 'http://example.com:83/path/naar/?query=foo%20%40%2B%25%2F', 'http://example.com.83.nyud.net:8090/path/naar/?query=foo%20%40%2B%25%2F'),
+ array('wp', 'foo [\\]^`{|}~@+#%?/#txt', 'https://en.wikipedia.org/wiki/foo %5B%5C%5D%5E%60%7B%7C%7D~@+%23%25?/#txt'),
+ array('amazon', 'foo [\\]^`{|}~@+#%?/#txt', 'https://www.amazon.com/exec/obidos/ASIN/foo%20%5B%5C%5D%5E%60%7B%7C%7D~%40%2B%23%25%3F%2F/splitbrain-20/#txt'),
+ array('doku', 'foo [\\]^`{|}~@+#%?/#txt', 'https://www.dokuwiki.org/foo%20%5B%5C%5D%5E%60%7B%7C%7D~%40%2B%23%25%3F%2F#txt'),
+ array('coral', 'http://example.com:83/path/naar/?query=foo%20%40%2B%25%3F%2F', 'http://example.com.83.nyud.net:8090/path/naar/?query=foo%20%40%2B%25%3F%2F'),
array('scheme', 'ftp://foo @+%/#txt', 'ftp://example.com#txt'),
//relative url
- array('withslash', 'foo @+%/#txt', '/testfoo%20%40%2B%25%2F#txt'),
- array('skype', 'foo @+%/#txt', 'skype:foo @+%/#txt'),
+ array('withslash', 'foo [\\]^`{|}~@+#%?/#txt', '/testfoo%20%5B%5C%5D%5E%60%7B%7C%7D~%40%2B%23%25%3F%2F#txt'),
+ array('skype', 'foo [\\]^`{|}~@+#%?/#txt', 'skype:foo %5B%5C%5D%5E%60%7B%7C%7D~@+%23%25?/#txt'),
//dokuwiki id's
- array('onlytext', 'foo @+%#txt', DOKU_BASE.'doku.php?id=onlytextfoo#txt'),
- array('user', 'foo @+%#txt', DOKU_BASE.'doku.php?id=user:foo#txt'),
- array('withquery', 'foo @+%#txt', DOKU_BASE.'doku.php?id=anyns:foo&amp;do=edit#txt')
+ array('onlytext', 'foo [\\]^`{|}~@+#%/#txt', DOKU_BASE.'doku.php?id=onlytextfoo#txt'),
+ array('user', 'foo [\\]^`{|}~@+#%/#txt', DOKU_BASE.'doku.php?id=user:foo#txt'),
+ array('withquery', 'foo [\\]^`{|}~@+#%/#txt', DOKU_BASE.'doku.php?id=anyns:foo&amp;do=edit#txt')
);
foreach($tests as $test) {
@@ -45,7 +47,7 @@ class Test_resolveInterwiki extends DokuWikiTest {
$shortcut = 'nonexisting';
$reference = 'foo @+%/';
$url = $Renderer->_resolveInterWiki($shortcut, $reference);
- $expected = 'http://www.google.com/search?q=foo%20%40%2B%25%2F&amp;btnI=lucky';
+ $expected = 'https://www.google.com/search?q=foo%20%40%2B%25%2F&amp;btnI=lucky';
$this->assertEquals($expected, $url);
}
diff --git a/_test/tests/inc/remote.test.php b/_test/tests/inc/remote.test.php
index d0d4eb7ce..037b1dc0b 100644
--- a/_test/tests/inc/remote.test.php
+++ b/_test/tests/inc/remote.test.php
@@ -160,10 +160,16 @@ class remote_test extends DokuWikiTest {
$this->assertTrue($this->remote->hasAccess());
}
+ /**
+ * @expectedException RemoteAccessDeniedException
+ */
function test_hasAccessFail() {
global $conf;
$conf['remote'] = 0;
- $this->assertFalse($this->remote->hasAccess());
+ // the hasAccess() should throw a Exception to keep the same semantics with xmlrpc.php.
+ // because the user(xmlrpc) check remote before .--> (!$conf['remote']) die('XML-RPC server not enabled.');
+ // so it must be a Exception when get here.
+ $this->remote->hasAccess();
}
function test_hasAccessFailAcl() {
diff --git a/_test/tests/inc/tar.test.php b/_test/tests/inc/tar.test.php
deleted file mode 100644
index 15453b16d..000000000
--- a/_test/tests/inc/tar.test.php
+++ /dev/null
@@ -1,454 +0,0 @@
-<?php
-
-class Tar_TestCase extends DokuWikiTest {
- /**
- * file extensions that several tests use
- */
- protected $extensions = array('tar');
-
- public function setUp() {
- parent::setUp();
- if (extension_loaded('zlib')) {
- $this->extensions[] = 'tgz';
- }
- if (extension_loaded('bz2')) {
- $this->extensions[] = 'tbz';
- }
- }
-
- /*
- * dependency for tests needing zlib extension to pass
- */
- public function test_ext_zlib() {
- if (!extension_loaded('zlib')) {
- $this->markTestSkipped('skipping all zlib tests. Need zlib extension');
- }
- }
-
- /*
- * dependency for tests needing zlib extension to pass
- */
- public function test_ext_bz2() {
- if (!extension_loaded('bz2')) {
- $this->markTestSkipped('skipping all bzip2 tests. Need bz2 extension');
- }
- }
-
- /**
- * 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';
- $tdir = ltrim($dir,'/');
-
- $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');
-
- // fullpath might be too long to be stored as full path FS#2802
- $this->assertTrue(strpos($data, "$tdir") !== false, 'Path in TAR');
- $this->assertTrue(strpos($data, "testdata1.txt") !== false, 'File in TAR');
-
- $this->assertTrue(strpos($data, 'noway/testdata2.txt') !== false, 'Path in TAR');
- $this->assertTrue(strpos($data, 'another/testdata3.txt') !== false, 'Path in TAR');
-
- // fullpath might be too long to be stored as full path FS#2802
- $this->assertTrue(strpos($data, "$tdir/foobar") === false, 'Path not in TAR');
- $this->assertTrue(strpos($data, "foobar.txt") === false, 'File 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';
- $tdir = ltrim($dir,'/');
- $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');
-
- // fullpath might be too long to be stored as full path FS#2802
- $this->assertTrue(strpos($data, "$tdir") !== false, "Path in TAR '$tdir'");
- $this->assertTrue(strpos($data, "testdata1.txt") !== false, 'File in TAR');
-
- $this->assertTrue(strpos($data, 'noway/testdata2.txt') !== false, 'Path in TAR');
- $this->assertTrue(strpos($data, 'another/testdata3.txt') !== false, 'Path in TAR');
-
- // fullpath might be too long to be stored as full path FS#2802
- $this->assertTrue(strpos($data, "$tdir/foobar") === false, 'Path not in TAR');
- $this->assertTrue(strpos($data, "foobar.txt") === false, 'File 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($this->extensions 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($this->extensions 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($this->extensions 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($this->extensions 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($this->extensions 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($this->extensions 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'));
- }
-
- /**
- * @depends test_ext_zlib
- */
- 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);
- }
- }
-
- // FS#1442
- public function test_createlongfile() {
- $tar = new Tar();
- $tmp = tempnam(sys_get_temp_dir(), 'dwtartest');
-
- $path = '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.txt';
-
- $tar->create($tmp, Tar::COMPRESS_NONE);
- $tar->addData($path, 'testcontent1');
- $tar->close();
-
- $this->assertTrue(filesize($tmp) > 30); //arbitrary non-zero number
- $data = file_get_contents($tmp);
-
- // We should find the complete path and a longlink entry
- $this->assertTrue(strpos($data, 'testcontent1') !== false, 'content in TAR');
- $this->assertTrue(strpos($data, $path) !== false, 'path in TAR');
- $this->assertTrue(strpos($data, '@LongLink') !== false, '@LongLink in TAR');
-
- @unlink($tmp);
- }
-
- 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
- * @depends test_ext_zlib
- */
- 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);
- }
-
- /**
- * A single zero file should be just a header block + the footer
- */
- public function test_zerofile(){
- $dir = dirname(__FILE__).'/tar';
- $tar = new Tar();
- $tar->create();
- $tar->addFile("$dir/zero.txt", 'zero.txt');
- $file = $tar->getArchive(Tar::COMPRESS_NONE);
-
- $this->assertEquals(512*3, strlen($file)); // 1 header block + 2 footer blocks
- }
-
- public function test_zerodata(){
- $tar = new Tar();
- $tar->create();
- $tar->addData('zero.txt','');
- $file = $tar->getArchive(Tar::COMPRESS_NONE);
-
- $this->assertEquals(512*3, strlen($file)); // 1 header block + 2 footer blocks
- }
-
- /**
- * A file of exactly one block should be just a header block + data block + the footer
- */
- public function test_blockfile(){
- $dir = dirname(__FILE__).'/tar';
- $tar = new Tar();
- $tar->create();
- $tar->addFile("$dir/block.txt", 'block.txt');
- $file = $tar->getArchive(Tar::COMPRESS_NONE);
-
- $this->assertEquals(512*4, strlen($file)); // 1 header block + data block + 2 footer blocks
- }
-
- public function test_blockdata(){
- $tar = new Tar();
- $tar->create();
- $tar->addData('block.txt', str_pad('', 512, 'x'));
- $file = $tar->getArchive(Tar::COMPRESS_NONE);
-
- $this->assertEquals(512*4, strlen($file)); // 1 header block + data block + 2 footer blocks
- }
-
-
- public function test_cleanPath(){
- $tar = new Tar();
- $tests = array (
- '/foo/bar' => 'foo/bar',
- '/foo/bar/' => 'foo/bar',
- 'foo//bar' => 'foo/bar',
- 'foo/0/bar' => 'foo/0/bar',
- 'foo/../bar' => 'bar',
- 'foo/bang/bang/../../bar' => 'foo/bar',
- 'foo/../../bar' => 'bar',
- 'foo/.././../bar' => 'bar',
- );
-
- foreach($tests as $in => $out){
- $this->assertEquals($out, $tar->cleanPath($in), "Input: $in");
- }
- }
-}
diff --git a/_test/tests/inc/tar/block.txt b/_test/tests/inc/tar/block.txt
deleted file mode 100644
index 9b2f53080..000000000
--- a/_test/tests/inc/tar/block.txt
+++ /dev/null
@@ -1 +0,0 @@
-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \ No newline at end of file
diff --git a/_test/tests/inc/tar/foobar/testdata2.txt b/_test/tests/inc/tar/foobar/testdata2.txt
deleted file mode 100644
index a7db15771..000000000
--- a/_test/tests/inc/tar/foobar/testdata2.txt
+++ /dev/null
@@ -1 +0,0 @@
-testcontent2
diff --git a/_test/tests/inc/tar/longpath-gnu.tgz b/_test/tests/inc/tar/longpath-gnu.tgz
deleted file mode 100644
index 6c937c8fe..000000000
--- a/_test/tests/inc/tar/longpath-gnu.tgz
+++ /dev/null
Binary files differ
diff --git a/_test/tests/inc/tar/longpath-ustar.tgz b/_test/tests/inc/tar/longpath-ustar.tgz
deleted file mode 100644
index 59efbff66..000000000
--- a/_test/tests/inc/tar/longpath-ustar.tgz
+++ /dev/null
Binary files differ
diff --git a/_test/tests/inc/tar/tarbomb.tgz b/_test/tests/inc/tar/tarbomb.tgz
deleted file mode 100644
index 8418d4073..000000000
--- a/_test/tests/inc/tar/tarbomb.tgz
+++ /dev/null
Binary files differ
diff --git a/_test/tests/inc/tar/test.tar b/_test/tests/inc/tar/test.tar
deleted file mode 100644
index 931866b0b..000000000
--- a/_test/tests/inc/tar/test.tar
+++ /dev/null
Binary files differ
diff --git a/_test/tests/inc/tar/test.tbz b/_test/tests/inc/tar/test.tbz
deleted file mode 100644
index 5a7374019..000000000
--- a/_test/tests/inc/tar/test.tbz
+++ /dev/null
Binary files differ
diff --git a/_test/tests/inc/tar/test.tgz b/_test/tests/inc/tar/test.tgz
deleted file mode 100644
index b00319649..000000000
--- a/_test/tests/inc/tar/test.tgz
+++ /dev/null
Binary files differ
diff --git a/_test/tests/inc/tar/testdata1.txt b/_test/tests/inc/tar/testdata1.txt
deleted file mode 100644
index ac65bb32e..000000000
--- a/_test/tests/inc/tar/testdata1.txt
+++ /dev/null
@@ -1 +0,0 @@
-testcontent1
diff --git a/_test/tests/inc/tar/zero.txt b/_test/tests/inc/tar/zero.txt
deleted file mode 100644
index e69de29bb..000000000
--- a/_test/tests/inc/tar/zero.txt
+++ /dev/null
diff --git a/_test/tests/inc/template_include_page.test.php b/_test/tests/inc/template_include_page.test.php
index 47d4d46f1..7dd13ba23 100644
--- a/_test/tests/inc/template_include_page.test.php
+++ b/_test/tests/inc/template_include_page.test.php
@@ -1,40 +1,67 @@
<?php
-class template_include_page_test extends DokuWikiTest {
- function testNoSidebar() {
- global $ID;
+class template_pagetitle_test extends DokuWikiTest {
- $ID = 'foo:bar:baz:test';
- $sidebar = tpl_include_page('sidebar', false, true);
- $this->assertEquals('', $sidebar);
+ function test_localID() {
+ global $ID,$ACT;
+
+
+ $id = 'foo:bar';
+
+ $ACT = 'show';
+ $this->assertEquals('foo:bar', tpl_pagetitle($id, true));
}
- function testExistingSidebars() {
- global $ID;
+ function test_globalID() {
+ global $ID,$ACT;
+
- saveWikiText('sidebar', 'topsidebar-test', '');
+ $ID = 'foo:bar';
- $ID = 'foo:bar:baz:test';
- $sidebar = tpl_include_page('sidebar', false, true);
- $this->assertTrue(strpos($sidebar, 'topsidebar-test') > 0);
+ $ACT = 'show';
+ $this->assertEquals('foo:bar', tpl_pagetitle(null, true));
+ }
+
+ function test_adminTitle() {
+ global $ID,$ACT;
- $ID = 'foo';
- $sidebar = tpl_include_page('sidebar', false, true);
- $this->assertTrue(strpos($sidebar, 'topsidebar-test') > 0);
+ $ID = 'foo:bar';
+
+ $ACT = 'admin';
+ $this->assertEquals('Admin', tpl_pagetitle(null, true));
+ }
- saveWikiText('foo:bar:sidebar', 'bottomsidebar-test', '');
+ function test_adminPluginTitle() {
+ global $ID,$ACT,$INPUT,$conf;
- $ID = 'foo:bar:baz:test';
- $sidebar = tpl_include_page('sidebar', false, true);
- $this->assertTrue(strpos($sidebar, 'bottomsidebar-test') > 0);
+ if (!plugin_load('admin','revert')) {
+ $this->markTestSkipped('Revert plugin not found, unable to test admin plugin titles');
+ return;
+ }
- $ID = 'foo:bar:test';
- $sidebar = tpl_include_page('sidebar', false, true);
- $this->assertTrue(strpos($sidebar, 'bottomsidebar-test') > 0);
+ $ID = 'foo:bar';
+ $ACT = 'admin';
+ $conf['lang'] = 'en';
+ $INPUT->set('page','revert');
- $ID = 'foo';
- $sidebar = tpl_include_page('sidebar', false, true);
- $this->assertTrue(strpos($sidebar, 'topsidebar-test') > 0);
+ $this->assertEquals('Revert Manager', tpl_pagetitle(null, true));
}
+ function test_nonPageFunctionTitle() {
+ global $ID,$ACT;
+
+ $ID = 'foo:bar';
+
+ $ACT = 'index';
+ $this->assertEquals('Sitemap', tpl_pagetitle(null, true));
+ }
+
+ function test_pageFunctionTitle() {
+ global $ID,$ACT;
+
+ $ID = 'foo:bar';
+
+ $ACT = 'revisions';
+ $this->assertEquals('foo:bar - Old revisions', tpl_pagetitle(null, true));
+ }
}