summaryrefslogtreecommitdiff
path: root/_test
diff options
context:
space:
mode:
Diffstat (limited to '_test')
-rw-r--r--_test/core/DokuWikiTest.php2
-rw-r--r--_test/phpunit.xml4
-rw-r--r--_test/tests/inc/auth_aclcheck.test.php10
-rw-r--r--_test/tests/inc/auth_aclcheck_caseinsensitive.test.php128
-rw-r--r--_test/tests/inc/auth_admincheck.test.php5
-rw-r--r--_test/tests/inc/auth_nameencode.test.php2
-rw-r--r--_test/tests/inc/auth_password.test.php6
-rw-r--r--_test/tests/inc/httpclient_http_proxy.test.php20
-rw-r--r--_test/tests/inc/httpclient_https.test.php1
-rw-r--r--_test/tests/inc/httpclient_https_proxy.test.php15
-rw-r--r--_test/tests/inc/indexer_pid.test.php18
-rw-r--r--_test/tests/inc/indexer_rename.test.php83
-rw-r--r--_test/tests/inc/mailer.test.php20
-rw-r--r--_test/tests/inc/parser/parser.inc.php3
-rw-r--r--_test/tests/inc/parser/parser_footnote.test.php4
-rw-r--r--_test/tests/inc/parser/parser_quotes.test.php4
-rw-r--r--_test/tests/inc/remote.test.php5
-rw-r--r--_test/tests/inc/search/search.test.php19
-rw-r--r--_test/tests/inc/subscription.test.php246
-rw-r--r--_test/tests/inc/subscription_set.test.php20
-rw-r--r--_test/tests/inc/tar.test.php319
-rw-r--r--_test/tests/inc/tar/foobar/testdata2.txt1
-rw-r--r--_test/tests/inc/tar/longpath-gnu.tgzbin0 -> 413 bytes
-rw-r--r--_test/tests/inc/tar/longpath-ustar.tgzbin0 -> 311 bytes
-rw-r--r--_test/tests/inc/tar/tarbomb.tgzbin0 -> 183 bytes
-rw-r--r--_test/tests/inc/tar/test.tarbin0 -> 10240 bytes
-rw-r--r--_test/tests/inc/tar/test.tbzbin0 -> 217 bytes
-rw-r--r--_test/tests/inc/tar/test.tgzbin0 -> 220 bytes
-rw-r--r--_test/tests/inc/tar/testdata1.txt1
-rw-r--r--_test/tests/inc/tarlib.test.php0
30 files changed, 896 insertions, 40 deletions
diff --git a/_test/core/DokuWikiTest.php b/_test/core/DokuWikiTest.php
index b9e151456..91eb5293b 100644
--- a/_test/core/DokuWikiTest.php
+++ b/_test/core/DokuWikiTest.php
@@ -30,6 +30,8 @@ abstract class DokuWikiTest extends PHPUnit_Framework_TestCase {
// remove any leftovers from the last run
if(is_dir(DOKU_TMP_DATA)){
+ // clear indexer data and cache
+ idx_get_indexer()->clear();
TestUtils::rdelete(DOKU_TMP_DATA);
}
diff --git a/_test/phpunit.xml b/_test/phpunit.xml
index 13676f207..fc7dd8be0 100644
--- a/_test/phpunit.xml
+++ b/_test/phpunit.xml
@@ -10,6 +10,9 @@
<testsuite name="Plugin Tests">
<directory suffix=".test.php">../lib/plugins/*/_test</directory>
</testsuite>
+ <testsuite name="Template Tests">
+ <directory suffix=".test.php">../lib/tpl/*/_test</directory>
+ </testsuite>
</testsuites>
<filter>
@@ -19,6 +22,7 @@
<directory suffix=".php">../_cs/</directory>
<directory suffix=".php">../_test/</directory>
<directory suffix=".php">../lib/plugins/*/_test/</directory>
+ <directory suffix=".php">../lib/tpl/*/_test/</directory>
</exclude>
</whitelist>
</filter>
diff --git a/_test/tests/inc/auth_aclcheck.test.php b/_test/tests/inc/auth_aclcheck.test.php
index 5dc0d7f60..b128b7871 100644
--- a/_test/tests/inc/auth_aclcheck.test.php
+++ b/_test/tests/inc/auth_aclcheck.test.php
@@ -2,22 +2,18 @@
class auth_acl_test extends DokuWikiTest {
- var $oldConf;
var $oldAuthAcl;
- function setup() {
- global $conf;
+ function setUp() {
+ parent::setUp();
global $AUTH_ACL;
global $auth;
- $this->oldConf = $conf;
$this->oldAuthAcl = $AUTH_ACL;
$auth = new DokuWiki_Auth_Plugin();
}
- function teardown() {
- global $conf;
+ function tearDown() {
global $AUTH_ACL;
- $conf = $this->oldConf;
$AUTH_ACL = $this->oldAuthAcl;
}
diff --git a/_test/tests/inc/auth_aclcheck_caseinsensitive.test.php b/_test/tests/inc/auth_aclcheck_caseinsensitive.test.php
new file mode 100644
index 000000000..2f4821c2d
--- /dev/null
+++ b/_test/tests/inc/auth_aclcheck_caseinsensitive.test.php
@@ -0,0 +1,128 @@
+<?php
+
+class auth_acl_caseinsensitive_auth extends auth_basic {
+ function isCaseSensitive() {
+ return false;
+ }
+}
+
+class auth_acl_caseinsensitive_test extends DokuWikiTest {
+ protected $oldAuth;
+ protected $oldAuthAcl;
+
+ function setUp() {
+ parent::setUp();
+ global $auth;
+ global $AUTH_ACL;
+
+ $this->oldAuth = $auth;
+ $this->oldAuthAcl = $AUTH_ACL;
+
+ $auth = new auth_acl_caseinsensitive_auth();
+ }
+
+ function tearDown() {
+ global $conf;
+ global $AUTH_ACL;
+ global $auth;
+
+ $auth = $this->oldAuth;
+ $AUTH_ACL = $this->oldAuthAcl;
+ }
+
+ function test_multiadmin_restricted_ropage() {
+ global $conf;
+ global $AUTH_ACL;
+
+ $conf['superuser'] = 'John,doe,@Admin1,@admin2';
+ $conf['useacl'] = 1;
+
+ $AUTH_ACL = array(
+ '* @ALL 0',
+ '* @Group1 8',
+ '* @group2 8',
+ 'namespace:page @Group1 1',
+ 'namespace:page @group2 1',
+ );
+
+ // anonymous user
+ $this->assertEquals(auth_aclcheck('page', '', array()), AUTH_NONE);
+ $this->assertEquals(auth_aclcheck('namespace:page', '', array()), AUTH_NONE);
+ $this->assertEquals(auth_aclcheck('namespace:*', '', array()), AUTH_NONE);
+
+ // user with no matching group
+ $this->assertEquals(auth_aclcheck('page', 'jill', array('foo')), AUTH_NONE);
+ $this->assertEquals(auth_aclcheck('namespace:page', 'jill', array('foo')), AUTH_NONE);
+ $this->assertEquals(auth_aclcheck('namespace:*', 'jill', array('foo')), AUTH_NONE);
+
+ // user with matching group 1
+ $this->assertEquals(auth_aclcheck('page', 'jill', array('foo', 'group1')), AUTH_UPLOAD);
+ $this->assertEquals(auth_aclcheck('namespace:page', 'jill', array('foo', 'group1')), AUTH_READ);
+ $this->assertEquals(auth_aclcheck('namespace:*', 'jill', array('foo', 'group1')), AUTH_UPLOAD);
+
+ // user with matching group 2
+ $this->assertEquals(auth_aclcheck('page', 'jill', array('foo', 'Group2')), AUTH_UPLOAD);
+ $this->assertEquals(auth_aclcheck('namespace:page', 'jill', array('foo', 'Group2')), AUTH_READ);
+ $this->assertEquals(auth_aclcheck('namespace:*', 'jill', array('foo', 'Group2')), AUTH_UPLOAD);
+
+ // super user John
+ $this->assertEquals(auth_aclcheck('page', 'john', array('foo')), AUTH_ADMIN);
+ $this->assertEquals(auth_aclcheck('namespace:page', 'john', array('foo')), AUTH_ADMIN);
+ $this->assertEquals(auth_aclcheck('namespace:*', 'john', array('foo')), AUTH_ADMIN);
+
+ // super user doe
+ $this->assertEquals(auth_aclcheck('page', 'Doe', array('foo')), AUTH_ADMIN);
+ $this->assertEquals(auth_aclcheck('namespace:page', 'Doe', array('foo')), AUTH_ADMIN);
+ $this->assertEquals(auth_aclcheck('namespace:*', 'Doe', array('foo')), AUTH_ADMIN);
+
+ // user with matching admin group 1
+ $this->assertEquals(auth_aclcheck('page', 'jill', array('foo', 'admin1')), AUTH_ADMIN);
+ $this->assertEquals(auth_aclcheck('namespace:page', 'jill', array('foo', 'admin1')), AUTH_ADMIN);
+ $this->assertEquals(auth_aclcheck('namespace:*', 'jill', array('foo', 'admin1')), AUTH_ADMIN);
+
+ // user with matching admin group 2
+ $this->assertEquals(auth_aclcheck('page', 'jill', array('foo', 'Admin2')), AUTH_ADMIN);
+ $this->assertEquals(auth_aclcheck('namespace:page', 'jill', array('foo', 'Admin2')), AUTH_ADMIN);
+ $this->assertEquals(auth_aclcheck('namespace:*', 'jill', array('foo', 'Admin2')), AUTH_ADMIN);
+ }
+
+ /*
+ * Test aclcheck on @ALL group
+ *
+ * The default permission for @ALL group is AUTH_NONE. So we use an
+ * ACL entry which grants @ALL group an AUTH_READ permission to see
+ * whether ACL matching is properly done or not.
+ */
+ function test_restricted_allread() {
+ global $conf;
+ global $AUTH_ACL;
+
+ $conf['superuser'] = 'john';
+ $conf['useacl'] = 1;
+
+ $AUTH_ACL = array(
+ '* @ALL 1',
+ '* @group1 8',
+ );
+
+ // anonymous user
+ $this->assertEquals(auth_aclcheck('page', '', array()), AUTH_READ);
+ $this->assertEquals(auth_aclcheck('namespace:page', '', array()), AUTH_READ);
+ $this->assertEquals(auth_aclcheck('namespace:*', '', array()), AUTH_READ);
+
+ // user with no matching group
+ $this->assertEquals(auth_aclcheck('page', 'jill', array('foo')), AUTH_READ);
+ $this->assertEquals(auth_aclcheck('namespace:page', 'jill', array('foo')), AUTH_READ);
+ $this->assertEquals(auth_aclcheck('namespace:*', 'jill', array('foo')), AUTH_READ);
+
+ // user with matching group
+ $this->assertEquals(auth_aclcheck('page', 'jill', array('foo', 'Group1')), AUTH_UPLOAD);
+ $this->assertEquals(auth_aclcheck('namespace:page', 'jill', array('foo', 'Group1')), AUTH_UPLOAD);
+ $this->assertEquals(auth_aclcheck('namespace:*', 'jill', array('foo', 'Group1')), AUTH_UPLOAD);
+
+ // super user
+ $this->assertEquals(auth_aclcheck('page', 'John', array('foo')), AUTH_ADMIN);
+ $this->assertEquals(auth_aclcheck('namespace:page', 'John', array('foo')), AUTH_ADMIN);
+ $this->assertEquals(auth_aclcheck('namespace:*', 'John', array('foo')), AUTH_ADMIN);
+ }
+}
diff --git a/_test/tests/inc/auth_admincheck.test.php b/_test/tests/inc/auth_admincheck.test.php
index 2fb5902d7..087be3810 100644
--- a/_test/tests/inc/auth_admincheck.test.php
+++ b/_test/tests/inc/auth_admincheck.test.php
@@ -10,7 +10,8 @@ class auth_admin_test extends DokuWikiTest {
private $oldauth;
- function setup() {
+ function setUp() {
+ parent::setUp();
global $auth;
$this->oldauth = $auth;
}
@@ -27,9 +28,7 @@ class auth_admin_test extends DokuWikiTest {
function teardown() {
global $auth;
- global $conf;
global $AUTH_ACL;
- unset($conf);
unset($AUTH_ACL);
$auth = $this->oldauth;
}
diff --git a/_test/tests/inc/auth_nameencode.test.php b/_test/tests/inc/auth_nameencode.test.php
index 21db304e0..da9f31f90 100644
--- a/_test/tests/inc/auth_nameencode.test.php
+++ b/_test/tests/inc/auth_nameencode.test.php
@@ -2,7 +2,7 @@
class auth_nameencode_test extends DokuWikiTest {
- function teardown() {
+ function tearDown() {
global $cache_authname;
$cache_authname = array();
}
diff --git a/_test/tests/inc/auth_password.test.php b/_test/tests/inc/auth_password.test.php
index 426353291..27e03be60 100644
--- a/_test/tests/inc/auth_password.test.php
+++ b/_test/tests/inc/auth_password.test.php
@@ -16,6 +16,7 @@ class auth_password_test extends PHPUnit_Framework_TestCase {
'kmd5' => 'a579299436d7969791189acadd86fcb716',
'djangomd5' => 'md5$abcde$d0fdddeda8cd92725d2b54148ac09158',
'djangosha1' => 'sha1$abcde$c8e65a7f0acc9158843048a53dcc5a6bc4d17678',
+ 'sha512' => '$6$abcdefgh12345678$J9.zOcgx0lotwZdcz0uulA3IVQMinZvFZVjA5vapRLVAAqtay23XD4xeeUxQ3B4JvDWYFBIxVWW1tOYlHX13k1'
);
@@ -61,6 +62,11 @@ class auth_password_test extends PHPUnit_Framework_TestCase {
$this->assertTrue(auth_verifyPassword('test12345','$H$9IQRaTwmfeRo7ud9Fh4E2PdI0S3r.L0'));
}
+ function test_veryPassword_mediawiki(){
+ $this->assertTrue(auth_verifyPassword('password', ':B:838c83e1:e4ab7024509eef084cdabd03d8b2972c'));
+ }
+
+
/**
* pmd5 checking should throw an exception when a hash with a too high
* iteration count is passed
diff --git a/_test/tests/inc/httpclient_http_proxy.test.php b/_test/tests/inc/httpclient_http_proxy.test.php
new file mode 100644
index 000000000..faa7a4280
--- /dev/null
+++ b/_test/tests/inc/httpclient_http_proxy.test.php
@@ -0,0 +1,20 @@
+<?php
+
+class httpclient_http_proxy_test extends DokuWikiTest {
+ protected $url = 'http://www.dokuwiki.org/README';
+
+ /**
+ * @group internet
+ */
+ function test_simpleget(){
+ $http = new HTTPClient();
+ // proxy provided by Andrwe Lord Weber <dokuwiki@andrwe.org>
+ $http->proxy_host = 'proxy.andrwe.org';
+ $http->proxy_port = 8080;
+
+ $data = $http->get($this->url);
+ $this->assertFalse($data === false, 'HTTP response');
+ $this->assertTrue(strpos($data,'DokuWiki') !== false, 'response content');
+ }
+
+} \ No newline at end of file
diff --git a/_test/tests/inc/httpclient_https.test.php b/_test/tests/inc/httpclient_https.test.php
index 26a0f86db..955d467ec 100644
--- a/_test/tests/inc/httpclient_https.test.php
+++ b/_test/tests/inc/httpclient_https.test.php
@@ -1,4 +1,5 @@
<?php
+require_once dirname(__FILE__).'/httpclient_http.test.php';
class httpclient_https_test extends httpclient_http_test {
protected $server = 'https://httpbin.org/';
diff --git a/_test/tests/inc/httpclient_https_proxy.test.php b/_test/tests/inc/httpclient_https_proxy.test.php
new file mode 100644
index 000000000..aca3b3be2
--- /dev/null
+++ b/_test/tests/inc/httpclient_https_proxy.test.php
@@ -0,0 +1,15 @@
+<?php
+require_once dirname(__FILE__).'/httpclient_http_proxy.test.php';
+
+class httpclient_https_proxy_test extends httpclient_http_proxy_test {
+ protected $url = 'https://www.dokuwiki.org/README';
+
+ public function setUp(){
+ // skip tests when this PHP has no SSL support
+ $transports = stream_get_transports();
+ if(!in_array('ssl',$transports)){
+ $this->markTestSkipped('No SSL support available.');
+ }
+ parent::setUp();
+ }
+} \ No newline at end of file
diff --git a/_test/tests/inc/indexer_pid.test.php b/_test/tests/inc/indexer_pid.test.php
new file mode 100644
index 000000000..8c58b1abd
--- /dev/null
+++ b/_test/tests/inc/indexer_pid.test.php
@@ -0,0 +1,18 @@
+<?php
+/**
+ * Tests the pid functions of the indexer.
+ *
+ * @author Michael Hamann <michael@content-space.de>
+ */
+class indexer_pid_test extends DokuWikiTest {
+ function test_pid() {
+ $indexer = idx_get_indexer();
+ $syntaxPID = $indexer->getPID('wiki:syntax');
+ $this->assertEquals('wiki:syntax', $indexer->getPageFromPID($syntaxPID), 'getPageFromPID(getPID(\'wiki:syntax\')) != \'wiki:syntax\'');
+ $dokuwikiPID = $indexer->getPID('wiki:dokuwiki');
+ $this->assertEquals('wiki:syntax', $indexer->getPageFromPID($syntaxPID), 'getPageFromPID(getPID(\'wiki:syntax\')) != \'wiki:syntax\' after getting the PID for wiki:dokuwiki');
+ $this->assertEquals($syntaxPID, $indexer->getPID('wiki:syntax'), 'getPID(\'wiki:syntax\') didn\'t returned different PIDs when called twice');
+ $this->assertNotEquals($syntaxPID, $dokuwikiPID, 'Same PID returned for different pages');
+ $this->assertTrue(is_numeric($syntaxPID) && is_numeric($dokuwikiPID), 'PIDs are not numeric');
+ }
+}
diff --git a/_test/tests/inc/indexer_rename.test.php b/_test/tests/inc/indexer_rename.test.php
new file mode 100644
index 000000000..d8c456f8e
--- /dev/null
+++ b/_test/tests/inc/indexer_rename.test.php
@@ -0,0 +1,83 @@
+<?php
+/**
+ * Test cases for the Doku_Indexer::renamePage and Doku_Indexer::renameMetaValue methods
+ */
+class indexer_rename_test extends DokuWikiTest {
+ /** @var Doku_Indexer $indexer */
+ private $indexer;
+
+ private $old_id = 'old_testid';
+
+ function setUp() {
+ parent::setUp();
+ $this->indexer = idx_get_indexer();
+ $this->indexer->clear();
+
+ saveWikiText($this->old_id, 'Old test content', 'Created old test page for indexer rename test');
+ idx_addPage($this->old_id);
+ }
+
+ function test_rename_to_new_page() {
+ $newid = 'new_id_1';
+
+ $oldpid = $this->indexer->getPID($this->old_id);
+
+ $this->assertTrue($this->indexer->renamePage($this->old_id, $newid), 'Renaming the page to a new id failed');
+ io_rename(wikiFN($this->old_id), wikiFN($newid));
+
+ $this->assertNotEquals($this->indexer->getPID($this->old_id), $oldpid, 'PID for the old page unchanged after rename.');
+ $this->assertEquals($this->indexer->getPID($newid), $oldpid, 'New page has not the old pid.');
+ $query = array('old');
+ $this->assertEquals(array('old' => array($newid => 1)), $this->indexer->lookup($query), '"Old" doesn\'t find the new page');
+ }
+
+ function test_rename_to_existing_page() {
+ $newid = 'existing_page';
+ saveWikiText($newid, 'Existing content', 'Created page for move_to_existing_page');
+ idx_addPage($newid);
+
+ $oldpid = $this->indexer->getPID($this->old_id);
+ $existingpid = $this->indexer->getPID($newid);
+
+ $this->assertTrue($this->indexer->renamePage($this->old_id, $newid), 'Renaming the page to an existing id failed');
+
+ $this->assertNotEquals($this->indexer->getPID($this->old_id), $oldpid, 'PID for old page unchanged after rename.');
+ $this->assertNotEquals($this->indexer->getPID($this->old_id), $existingpid, 'PID for old page is now PID of the existing page.');
+ $this->assertEquals($this->indexer->getPID($newid), $oldpid, 'New page has not the old pid.');
+ $query = array('existing');
+ $this->assertEquals(array('existing' => array()), $this->indexer->lookup($query), 'Existing page hasn\'t been deleted from the index.');
+ $query = array('old');
+ $this->assertEquals(array('old' => array($newid => 1)), $this->indexer->lookup($query), '"Old" doesn\'t find the new page');
+ }
+
+ function test_meta_rename_to_new_value() {
+ $this->indexer->addMetaKeys($this->old_id, array('mkey' => 'old_value'));
+
+ $this->assertTrue($this->indexer->renameMetaValue('mkey', 'old_value', 'new_value'), 'Meta value rename to new value failed.');
+ $query = 'old_value';
+ $this->assertEquals(array(), $this->indexer->lookupKey('mkey', $query), 'Page can still be found under old value.');
+ $query = 'new_value';
+ $this->assertEquals(array($this->old_id), $this->indexer->lookupKey('mkey', $query), 'Page can\'t be found under new value.');
+ }
+
+ function test_meta_rename_to_existing_value() {
+ $this->indexer->addMetaKeys($this->old_id, array('mkey' => array('old_value', 'new_value')));
+
+ saveWikiText('newvalue', 'Test page', '');
+ idx_addPage('newvalue');
+ $this->indexer->addMetaKeys('newvalue', array('mkey' => array('new_value')));
+
+ saveWikiText('oldvalue', 'Test page', '');
+ idx_addPage('oldvalue');
+ $this->indexer->addMetaKeys('oldvalue', array('mkey' => array('old_value')));
+
+ $this->assertTrue($this->indexer->renameMetaValue('mkey', 'old_value', 'new_value'), 'Meta value rename to existing value failed');
+ $query = 'old_value';
+ $this->assertEquals(array(), $this->indexer->lookupKey('mkey', $query), 'Page can still be found under old value.');
+ $query = 'new_value';
+ $result = $this->indexer->lookupKey('mkey', $query);
+ $this->assertContains($this->old_id, $result, 'Page with both values can\'t be found anymore');
+ $this->assertContains('newvalue', $result, 'Page with new value can\'t be found anymore');
+ $this->assertContains('oldvalue', $result, 'Page with only the old value can\'t be found anymore');
+ }
+}
diff --git a/_test/tests/inc/mailer.test.php b/_test/tests/inc/mailer.test.php
index b2c74a257..053e216b8 100644
--- a/_test/tests/inc/mailer.test.php
+++ b/_test/tests/inc/mailer.test.php
@@ -7,6 +7,14 @@ class TestMailer extends Mailer {
public function prop($name){
return $this->$name;
}
+
+ public function &propRef($name) {
+ return $this->$name;
+ }
+
+ public function prepareHeaders() {
+ return parent::prepareHeaders();
+ }
}
class mailer_test extends DokuWikiTest {
@@ -90,5 +98,17 @@ class mailer_test extends DokuWikiTest {
}
}
+ /**
+ * @see https://forum.dokuwiki.org/post/35822
+ */
+ function test_emptyBCCorCC() {
+ $mail = new TestMailer();
+ $headers = &$mail->propRef('headers');
+ $headers['Bcc'] = '';
+ $headers['Cc'] = '';
+ $header = $mail->prepareHeaders();
+ $this->assertEquals(0, preg_match('/(^|\n)Bcc: (\n|$)/', $header), 'Bcc found in headers.');
+ $this->assertEquals(0, preg_match('/(^|\n)Cc: (\n|$)/', $header), 'Bcc found in headers.');
+ }
}
//Setup VIM: ex: et ts=4 :
diff --git a/_test/tests/inc/parser/parser.inc.php b/_test/tests/inc/parser/parser.inc.php
index e9efef0d3..61f15678b 100644
--- a/_test/tests/inc/parser/parser.inc.php
+++ b/_test/tests/inc/parser/parser.inc.php
@@ -8,7 +8,8 @@ abstract class TestOfDoku_Parser extends PHPUnit_Framework_TestCase {
var $P;
var $H;
- function setup() {
+ function setUp() {
+ parent::setUp();
$this->P = new Doku_Parser();
$this->H = new Doku_Handler();
$this->P->Handler = & $this->H;
diff --git a/_test/tests/inc/parser/parser_footnote.test.php b/_test/tests/inc/parser/parser_footnote.test.php
index f3b5ddf56..b47a575de 100644
--- a/_test/tests/inc/parser/parser_footnote.test.php
+++ b/_test/tests/inc/parser/parser_footnote.test.php
@@ -3,8 +3,8 @@ require_once 'parser.inc.php';
class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
- function setup() {
- parent::setup();
+ function setUp() {
+ parent::setUp();
$this->P->addMode('footnote',new Doku_Parser_Mode_Footnote());
}
diff --git a/_test/tests/inc/parser/parser_quotes.test.php b/_test/tests/inc/parser/parser_quotes.test.php
index b2dae1039..b82328212 100644
--- a/_test/tests/inc/parser/parser_quotes.test.php
+++ b/_test/tests/inc/parser/parser_quotes.test.php
@@ -3,8 +3,8 @@ require_once 'parser.inc.php';
class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
- function setup() {
- parent::setup();
+ function setUp() {
+ parent::setUp();
global $conf;
$conf['typography'] = 2;
}
diff --git a/_test/tests/inc/remote.test.php b/_test/tests/inc/remote.test.php
index c3d941a2c..d0d4eb7ce 100644
--- a/_test/tests/inc/remote.test.php
+++ b/_test/tests/inc/remote.test.php
@@ -112,12 +112,12 @@ class remote_plugin_testplugin extends DokuWiki_Remote_Plugin {
class remote_test extends DokuWikiTest {
- var $originalConf;
var $userinfo;
var $remote;
function setUp() {
+ parent::setUp();
global $plugin_controller;
global $conf;
global $USERINFO;
@@ -131,7 +131,6 @@ class remote_test extends DokuWikiTest {
$plugin_controller = $pluginManager;
- $this->originalConf = $conf;
$conf['remote'] = 1;
$conf['remoteuser'] = '!!not set!!';
$conf['useacl'] = 0;
@@ -143,9 +142,7 @@ class remote_test extends DokuWikiTest {
}
function tearDown() {
- global $conf;
global $USERINFO;
- $conf = $this->originalConf;
$USERINFO = $this->userinfo;
}
diff --git a/_test/tests/inc/search/search.test.php b/_test/tests/inc/search/search.test.php
index 33cc80e74..9c854a661 100644
--- a/_test/tests/inc/search/search.test.php
+++ b/_test/tests/inc/search/search.test.php
@@ -1,6 +1,7 @@
<?php
class search_test extends DokuWikiTest {
+
function strip_index_data($entry) {
$n_entry = array();
foreach(array('id', 'type', 'level', 'open') as $k) {
@@ -9,6 +10,24 @@ class search_test extends DokuWikiTest {
return $n_entry;
}
+ function test_search_allpages(){
+ $data = array();
+
+ //depth is 0 hence we should recurse endlesly
+ search($data, dirname(__FILE__) . '/data', 'search_allpages', array('depth' => 0), 'ns1');
+ $this->assertEquals(3, count($data));
+
+ //depth is 1 and we start too deep to expect results
+ $data = array();
+ search($data, dirname(__FILE__) . '/data', 'search_allpages', array('depth' => 1), 'ns1/ns3');
+ $this->assertEquals(0, count($data));
+
+ //depth is 1 so I should get only pages from ns1
+ $data = array();
+ search($data, dirname(__FILE__) . '/data', 'search_allpages', array('depth' => 1), 'ns1');
+ $this->assertEquals(2, count($data));
+ }
+
function test_search_index(){
$data = array();
search($data, dirname(__FILE__) . '/data', 'search_index',
diff --git a/_test/tests/inc/subscription.test.php b/_test/tests/inc/subscription.test.php
new file mode 100644
index 000000000..333400576
--- /dev/null
+++ b/_test/tests/inc/subscription.test.php
@@ -0,0 +1,246 @@
+<?php
+
+class subscription_test extends DokuWikiTest {
+
+ function test_regexp() {
+ // data to test against
+ $data = array(
+ "casper every\n",
+ "Andreas digest 1344689733",
+ "Cold%20Fusion every",
+ "zioth list 1344691369\n",
+ "nlights digest",
+ "rikblok\tdigest \t 1344716803",
+ );
+
+ // user, style, data, expected number of results
+ $tests = array(
+ array('Cold Fusion', null, null, 1),
+ array('casper', null, null, 1),
+ array('nope', null, null, 0),
+ array('lights', null, null, 0),
+ array(array('Cold Fusion', 'casper', 'nope'), null, null, 2),
+ array(null, 'list', null, 1),
+ array(null, 'every', null, 2),
+ array(null, 'digest', null, 3),
+ array(null, array('list', 'every'), null, 3),
+ array('casper', 'digest', null, 0),
+ array('casper', array('digest', 'every'), null, 1),
+ array('zioth', 'list', '1344691369', 1),
+ array('zioth', null, '1344691369', 1),
+ array('zioth', 'digest', '1344691369', 0),
+ );
+
+ $sub = new MockupSubscription();
+
+ $row = 0;
+ foreach($tests as $test) {
+ $re = $sub->buildregex($test[0], $test[1], $test[2]);
+ $this->assertFalse(empty($re), "test line $row");
+ $result = preg_grep($re, $data);
+ $this->assertEquals($test[3], count($result), "test line $row. $re got\n".print_r($result, true));
+
+ $row++;
+ }
+ }
+
+ function test_addremove() {
+ $sub = new MockupSubscription();
+
+ // no subscriptions
+ $this->assertArrayNotHasKey(
+ 'wiki:dokuwiki',
+ $sub->subscribers('wiki:dokuwiki', null, array('every', 'list', 'digest'))
+ );
+
+ // add page subscription
+ $sub->add('wiki:dokuwiki', 'testuser', 'every');
+
+ // one subscription
+ $this->assertArrayHasKey(
+ 'wiki:dokuwiki',
+ $sub->subscribers('wiki:dokuwiki', null, array('every', 'list', 'digest'))
+ );
+
+ // remove page subscription
+ $sub->remove('wiki:dokuwiki', 'testuser');
+
+ // no subscription
+ $this->assertArrayNotHasKey(
+ 'wiki:dokuwiki',
+ $sub->subscribers('wiki:dokuwiki', null, array('every', 'list', 'digest'))
+ );
+
+ // add namespace subscription
+ $sub->add('wiki:', 'testuser', 'every');
+
+ // one subscription
+ $this->assertArrayHasKey(
+ 'wiki:',
+ $sub->subscribers('wiki:dokuwiki', null, array('every', 'list', 'digest'))
+ );
+
+ // remove (non existing) page subscription
+ $sub->remove('wiki:dokuwiki', 'testuser');
+
+ // still one subscription
+ $this->assertArrayHasKey(
+ 'wiki:',
+ $sub->subscribers('wiki:dokuwiki', null, array('every', 'list', 'digest'))
+ );
+
+ // change namespace subscription
+ $sub->add('wiki:', 'testuser', 'digest', '1234567');
+
+ // still one subscription
+ $this->assertArrayHasKey(
+ 'wiki:',
+ $sub->subscribers('wiki:dokuwiki', null, array('every', 'list', 'digest'))
+ );
+
+ // check contents
+ $this->assertEquals(
+ array('wiki:' => array('testuser' => array('digest', '1234567'))),
+ $sub->subscribers('wiki:dokuwiki', null, array('every', 'list', 'digest'))
+ );
+
+ // change subscription data
+ $sub->add('wiki:', 'testuser', 'digest', '7654321');
+
+ // still one subscription
+ $this->assertArrayHasKey(
+ 'wiki:',
+ $sub->subscribers('wiki:dokuwiki', null, array('every', 'list', 'digest'))
+ );
+
+ // check contents
+ $this->assertEquals(
+ array('wiki:' => array('testuser' => array('digest', '7654321'))),
+ $sub->subscribers('wiki:dokuwiki', null, array('every', 'list', 'digest'))
+ );
+ }
+
+ function test_bulkdigest() {
+ $sub = new MockupSubscription();
+
+ // let's start with nothing
+ $this->assertEquals(0, $sub->send_bulk('sub1:test'));
+
+ // create a subscription
+ $sub->add('sub1:', 'testuser', 'digest', '978328800'); // last mod 2001-01-01
+
+ // now create change
+ $_SERVER['REMOTE_USER'] = 'someguy';
+ saveWikiText('sub1:test', 'foo bar', 'a subscription change', false);
+
+ // should trigger a mail
+ $this->assertEquals(1, $sub->send_bulk('sub1:test'));
+ $this->assertEquals(array('arthur@example.com'), $sub->mails);
+
+ $sub->reset();
+
+ // now create more changes
+ $_SERVER['REMOTE_USER'] = 'someguy';
+ saveWikiText('sub1:sub2:test', 'foo bar', 'a subscription change', false);
+ saveWikiText('sub1:another_test', 'foo bar', 'a subscription change', false);
+
+ // should not trigger a mail, because the subscription time has not been reached, yet
+ $this->assertEquals(0, $sub->send_bulk('sub1:test'));
+ $this->assertEquals(array(), $sub->mails);
+
+ // reset the subscription time
+ $sub->add('sub1:', 'testuser', 'digest', '978328800'); // last mod 2001-01-01
+
+ // we now should get mails for three changes
+ $this->assertEquals(3, $sub->send_bulk('sub1:test'));
+ $this->assertEquals(array('arthur@example.com', 'arthur@example.com', 'arthur@example.com'), $sub->mails);
+ }
+
+ function test_bulklist() {
+ $sub = new MockupSubscription();
+
+ // let's start with nothing
+ $this->assertEquals(0, $sub->send_bulk('sub1:test'));
+
+ // create a subscription
+ $sub->add('sub1:', 'testuser', 'list', '978328800'); // last mod 2001-01-01
+
+ // now create change
+ $_SERVER['REMOTE_USER'] = 'someguy';
+ saveWikiText('sub1:test', 'foo bar', 'a subscription change', false);
+
+ // should trigger a mail
+ $this->assertEquals(1, $sub->send_bulk('sub1:test'));
+ $this->assertEquals(array('arthur@example.com'), $sub->mails);
+
+ $sub->reset();
+
+ // now create more changes
+ $_SERVER['REMOTE_USER'] = 'someguy';
+ saveWikiText('sub1:sub2:test', 'foo bar', 'a subscription change', false);
+ saveWikiText('sub1:another_test', 'foo bar', 'a subscription change', false);
+
+ // should not trigger a mail, because the subscription time has not been reached, yet
+ $this->assertEquals(0, $sub->send_bulk('sub1:test'));
+ $this->assertEquals(array(), $sub->mails);
+
+ // reset the subscription time
+ $sub->add('sub1:', 'testuser', 'list', '978328800'); // last mod 2001-01-01
+
+ // we now should get a single mail for all three changes
+ $this->assertEquals(1, $sub->send_bulk('sub1:test'));
+ $this->assertEquals(array('arthur@example.com'), $sub->mails);
+ }
+
+ /**
+ * 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() {
+ $sub = new MockupSubscription();
+
+ $sub->add(':', 'admin', 'digest', '123456789');
+ $sub->add(':wiki:', 'admin', 'digest', '123456789');
+ $sub->add(':', 'admin', 'digest', '1234');
+ $sub->add(':wiki:', 'admin', 'digest', '1234');
+
+ $subscriptions = $sub->subscribers(':wiki:', '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');
+ }
+}
+
+/**
+ * makes protected methods visible for testing
+ */
+class MockupSubscription extends Subscription {
+ public $mails; // we keep sent mails here
+
+ public function __construct() {
+ $this->reset();
+ }
+
+ /**
+ * resets the mail array
+ */
+ public function reset() {
+ $this->mails = array();
+ }
+
+ public function isenabled() {
+ return true;
+ }
+
+ public function buildregex($user = null, $style = null, $data = null) {
+ return parent::buildregex($user, $style, $data);
+ }
+
+ protected function send($subscriber_mail, $subject, $id, $template, $trep, $hrep = null) {
+ $this->mails[] = $subscriber_mail;
+ return true;
+ }
+}
+
+//Setup VIM: ex: et ts=4 :
diff --git a/_test/tests/inc/subscription_set.test.php b/_test/tests/inc/subscription_set.test.php
deleted file mode 100644
index 5c0a6c816..000000000
--- a/_test/tests/inc/subscription_set.test.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?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
new file mode 100644
index 000000000..6c937c8fe
--- /dev/null
+++ b/_test/tests/inc/tar/longpath-gnu.tgz
Binary files differ
diff --git a/_test/tests/inc/tar/longpath-ustar.tgz b/_test/tests/inc/tar/longpath-ustar.tgz
new file mode 100644
index 000000000..59efbff66
--- /dev/null
+++ b/_test/tests/inc/tar/longpath-ustar.tgz
Binary files differ
diff --git a/_test/tests/inc/tar/tarbomb.tgz b/_test/tests/inc/tar/tarbomb.tgz
new file mode 100644
index 000000000..8418d4073
--- /dev/null
+++ b/_test/tests/inc/tar/tarbomb.tgz
Binary files differ
diff --git a/_test/tests/inc/tar/test.tar b/_test/tests/inc/tar/test.tar
new file mode 100644
index 000000000..931866b0b
--- /dev/null
+++ b/_test/tests/inc/tar/test.tar
Binary files differ
diff --git a/_test/tests/inc/tar/test.tbz b/_test/tests/inc/tar/test.tbz
new file mode 100644
index 000000000..5a7374019
--- /dev/null
+++ b/_test/tests/inc/tar/test.tbz
Binary files differ
diff --git a/_test/tests/inc/tar/test.tgz b/_test/tests/inc/tar/test.tgz
new file mode 100644
index 000000000..b00319649
--- /dev/null
+++ b/_test/tests/inc/tar/test.tgz
Binary files differ
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/tarlib.test.php b/_test/tests/inc/tarlib.test.php
deleted file mode 100644
index e69de29bb..000000000
--- a/_test/tests/inc/tarlib.test.php
+++ /dev/null