summaryrefslogtreecommitdiff
path: root/_test/tests
diff options
context:
space:
mode:
authorGuy Brand <gb@unistra.fr>2013-03-06 14:08:08 +0100
committerGuy Brand <gb@unistra.fr>2013-03-06 14:08:08 +0100
commit23678e344b4ddcad14254c106ecb93af174fdaa0 (patch)
treea5c787e4d87313a7fb6f18cb4c78bf210d92d60c /_test/tests
parent847cef0a6bfd2ff9dc54e1fc140f5ba0ece0017a (diff)
parent5721a1547938df76003c6d91ea003dc1c70abd94 (diff)
downloadrpg-23678e344b4ddcad14254c106ecb93af174fdaa0.tar.gz
rpg-23678e344b4ddcad14254c106ecb93af174fdaa0.tar.bz2
Merge branch 'master' into stable
Diffstat (limited to '_test/tests')
-rw-r--r--_test/tests/inc/PageUtilsIsHiddenPage.test.php95
-rw-r--r--_test/tests/inc/auth_aclcheck.test.php12
-rw-r--r--_test/tests/inc/auth_aclcheck_caseinsensitive.test.php128
-rw-r--r--_test/tests/inc/auth_admincheck.test.php9
-rw-r--r--_test/tests/inc/auth_browseruid.test.php30
-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/common_pageinfo.test.php299
-rw-r--r--_test/tests/inc/httpclient_http.test.php13
-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/media_get_from_url.test.php80
-rw-r--r--_test/tests/inc/media_ispublic.test.php18
-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/parserutils_set_metadata_during_rendering.test.php3
-rw-r--r--_test/tests/inc/remote.test.php7
-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
34 files changed, 1431 insertions, 45 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/auth_aclcheck.test.php b/_test/tests/inc/auth_aclcheck.test.php
index 991f82da7..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 auth_basic();
+ $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..21b2cfdb0
--- /dev/null
+++ b/_test/tests/inc/auth_aclcheck_caseinsensitive.test.php
@@ -0,0 +1,128 @@
+<?php
+
+class auth_acl_caseinsensitive_auth extends DokuWiki_Auth_Plugin {
+ 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 d88399cbe..087be3810 100644
--- a/_test/tests/inc/auth_admincheck.test.php
+++ b/_test/tests/inc/auth_admincheck.test.php
@@ -1,6 +1,6 @@
<?php
-class auth_admin_test_AuthInSensitive extends auth_basic {
+class auth_admin_test_AuthInSensitive extends DokuWiki_Auth_Plugin {
function isCaseSensitive(){
return false;
}
@@ -10,14 +10,15 @@ class auth_admin_test extends DokuWikiTest {
private $oldauth;
- function setup() {
+ function setUp() {
+ parent::setUp();
global $auth;
$this->oldauth = $auth;
}
function setSensitive() {
global $auth;
- $auth = new auth_basic();
+ $auth = new DokuWiki_Auth_Plugin();
}
function setInSensitive() {
@@ -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_browseruid.test.php b/_test/tests/inc/auth_browseruid.test.php
new file mode 100644
index 000000000..d33552582
--- /dev/null
+++ b/_test/tests/inc/auth_browseruid.test.php
@@ -0,0 +1,30 @@
+<?php
+
+class auth_browseruid_test extends DokuWikiTest {
+
+
+ /**
+ * regression test to ensure correct browser id on IE9.
+ *
+ * IE9 send different HTTP_ACCEPT_LANGUAGE header on ajax request.
+ */
+ function testIE9JsVsDefault() {
+
+ // javascript request
+ $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)';
+ $_SERVER['HTTP_ACCEPT_ENCODING'] = 'gzip, deflate';
+ $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'de';
+ unset($_SERVER['HTTP_ACCEPT_CHARSET']);
+ $javascriptId = auth_browseruid();
+
+ // default request
+ $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)';
+ $_SERVER['HTTP_ACCEPT_ENCODING'] = 'gzip, deflate';
+ $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'de-DE';
+ $normalId = auth_browseruid();
+
+ $this->assertEquals($normalId, $javascriptId);
+
+ }
+
+} \ No newline at end of file
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/common_pageinfo.test.php b/_test/tests/inc/common_pageinfo.test.php
new file mode 100644
index 000000000..c54fbce26
--- /dev/null
+++ b/_test/tests/inc/common_pageinfo.test.php
@@ -0,0 +1,299 @@
+<?php
+/**
+ * Unit Test for inc/common.php - pageinfo()
+ *
+ * @author Christopher Smith <chris@jalakai.co.uk>
+ */
+class common_pageinfo_test extends DokuWikiTest {
+
+ function setup(){
+ parent::setup();
+
+ global $USERINFO;
+ $USERINFO = array(
+ 'pass' => '179ad45c6ce2cb97cf1029e212046e81',
+ 'name' => 'Arthur Dent',
+ 'mail' => 'arthur@example.com',
+ 'grps' => array ('admin','user'),
+ );
+ $_SERVER['REMOTE_USER'] = 'testuser';
+ $_SERVER['REMOTE_ADDR'] = '1.2.3.4';
+ }
+
+ function _get_expected_pageinfo() {
+ global $USERINFO;
+ $info = array (
+ 'isadmin' => true,
+ 'ismanager' => true,
+ 'userinfo' => $USERINFO,
+ 'perm' => 255,
+ 'namespace' => false,
+ 'ismobile' => false,
+ 'client' => 'testuser',
+ );
+ $info['rev'] = null;
+ $info['subscribed'] = false;
+ $info['locked'] = false;
+ $info['exists'] = false;
+ $info['writable'] = true;
+ $info['editable'] = true;
+ $info['lastmod'] = false;
+ $info['meta'] = array();
+ $info['ip'] = null;
+ $info['user'] = null;
+ $info['sum'] = null;
+ $info['editor'] = null;
+
+ return $info;
+ }
+
+ /**
+ * check info keys and values for a non-existent page & admin user
+ */
+ function test_basic_nonexistentpage(){
+ global $ID,$conf;
+ $ID = 'wiki:start';
+
+ $info = $this->_get_expected_pageinfo();
+ $info['id'] = 'wiki:start';
+ $info['namespace'] = 'wiki';
+ $info['filepath'] = $conf['datadir'].'/wiki/start.txt';
+
+ $this->assertEquals($info, pageinfo());
+ }
+
+ /**
+ * check info keys and values for a existing page & admin user
+ */
+ function test_basic_existingpage(){
+ global $ID,$conf;
+ $ID = 'wiki:syntax';
+ $filename = $conf['datadir'].'/wiki/syntax.txt';
+ $rev = filemtime($filename);
+
+ $info = $this->_get_expected_pageinfo();
+ $info['id'] = 'wiki:syntax';
+ $info['namespace'] = 'wiki';
+ $info['filepath'] = $filename;
+ $info['exists'] = true;
+ $info['lastmod'] = $rev;
+ $info['meta'] = p_get_metadata($ID);
+
+ $this->assertEquals($info, pageinfo());
+ }
+
+ /**
+ * check info keys and values for anonymous user
+ */
+ function test_anonymoususer(){
+ global $ID,$conf,$REV;
+
+ unset($_SERVER['REMOTE_USER']);
+ global $USERINFO; $USERINFO = array();
+
+ $ID = 'wiki:syntax';
+ $filename = $conf['datadir'].'/wiki/syntax.txt';
+ $rev = filemtime($filename);
+
+ $info = $this->_get_expected_pageinfo();
+ $info['id'] = 'wiki:syntax';
+ $info['namespace'] = 'wiki';
+ $info['filepath'] = $filename;
+ $info['exists'] = true;
+ $info['lastmod'] = $rev;
+ $info['meta'] = p_get_metadata($ID);
+ $info['rev'] = '';
+
+ $info = array_merge($info, array(
+ 'isadmin' => false,
+ 'ismanager' => false,
+ 'perm' => 8,
+ 'client' => '1.2.3.4',
+ ));
+ unset($info['userinfo']);
+ $this->assertEquals($info, pageinfo());
+ }
+
+ /**
+ * check info keys and values with $REV
+ * (also see $RANGE tests)
+ */
+ function test_rev(){
+ global $ID,$conf,$REV;
+
+ $ID = 'wiki:syntax';
+ $filename = $conf['datadir'].'/wiki/syntax.txt';
+ $rev = filemtime($filename);
+ $REV = $rev - 100;
+
+ $info = $this->_get_expected_pageinfo();
+ $info['id'] = 'wiki:syntax';
+ $info['namespace'] = 'wiki';
+ $info['meta'] = p_get_metadata($ID);
+ $info['rev'] = $REV;
+ $info['filepath'] = str_replace('pages','attic',substr($filename,0,-3).$REV.'.txt.gz');
+
+ $this->assertEquals($info, pageinfo());
+ $this->assertEquals($rev-100, $REV);
+ }
+
+ /**
+ * check info keys and values with $RANGE
+ */
+ function test_range(){
+ global $ID,$conf,$REV,$RANGE;
+
+ $ID = 'wiki:syntax';
+ $filename = $conf['datadir'].'/wiki/syntax.txt';
+ $rev = filemtime($filename);
+ $range = '1000-2000';
+
+ $info = $this->_get_expected_pageinfo();
+ $info['id'] = 'wiki:syntax';
+ $info['namespace'] = 'wiki';
+ $info['exists'] = true;
+ $info['lastmod'] = $rev;
+ $info['meta'] = p_get_metadata($ID);
+ $info['filepath'] = $filename;
+
+ // check $RANGE without $REV
+ // expected result $RANGE unchanged
+ $RANGE = $range;
+
+ $this->assertEquals($info, pageinfo());
+ $this->assertFalse(isset($REV));
+ $this->assertEquals($range,$RANGE);
+
+ // check $RANGE with $REV = current
+ // expected result: $RANGE unchanged, $REV cleared
+ $REV = $rev;
+ $info['rev'] = '';
+
+ $this->assertEquals($info, pageinfo());
+ $this->assertEquals('',$REV);
+ $this->assertEquals($range,$RANGE);
+
+ // check with a real $REV
+ // expected result: $REV and $RANGE are cleared
+ $REV = $rev - 100;
+
+ $this->assertEquals($info, pageinfo());
+ $this->assertEquals('',$REV);
+ $this->assertEquals('',$RANGE);
+ }
+
+ /**
+ * test editor entry and external edit
+ */
+ function test_editor_and_externaledits(){
+ global $ID,$conf;
+ $ID = 'wiki:syntax';
+ $filename = $conf['datadir'].'/wiki/syntax.txt';
+ $rev = filemtime($filename);
+
+ $info = $this->_get_expected_pageinfo();
+ $info['id'] = 'wiki:syntax';
+ $info['namespace'] = 'wiki';
+ $info['filepath'] = $filename;
+ $info['exists'] = true;
+ $info['lastmod'] = $rev;
+ $info['meta'] = p_get_metadata($ID); // need $INFO set correctly for addLogEntry()
+
+ global $INFO;
+ $INFO = $info;
+
+ // add an editor for the current version of $ID
+ addLogEntry($rev, $ID);
+
+ $info['meta'] = p_get_metadata($ID);
+ $info['editor'] = $_SERVER['REMOTE_USER'];
+ $info['user'] = $_SERVER['REMOTE_USER'];
+ $info['ip'] = $_SERVER['REMOTE_ADDR'];
+ $info['sum'] = '';
+
+ // with an editor ...
+ $this->assertEquals($info, pageinfo());
+
+ // clear the meta['last_change'] value, pageinfo should restore it
+ p_set_metadata($ID,array('last_change' => false));
+
+ $this->assertEquals($info, pageinfo());
+ $this->assertEquals($info['meta']['last_change'], p_get_metadata($ID,'last_change'));
+
+ // fake an external edit, pageinfo should clear the last change from meta data
+ // and not return any editor data
+ $now = time()+10;
+ touch($filename,$now);
+
+ $info['lastmod'] = $now;
+ $info['meta']['last_change'] = false;
+ $info['ip'] = null;
+ $info['user'] = null;
+ $info['sum'] = null;
+ $info['editor'] = null;
+
+ $this->assertEquals($info, pageinfo());
+ $this->assertEquals($info['meta'], p_get_metadata($ID)); // check metadata has been updated correctly
+ }
+
+ /**
+ * check draft
+ */
+ function test_draft(){
+ global $ID,$conf;
+ $ID = 'wiki:syntax';
+ $filename = $conf['datadir'].'/wiki/syntax.txt';
+ $rev = filemtime($filename);
+
+ $info = $this->_get_expected_pageinfo();
+ $info['id'] = 'wiki:syntax';
+ $info['namespace'] = 'wiki';
+ $info['filepath'] = $filename;
+ $info['exists'] = true;
+ $info['lastmod'] = $rev;
+ $info['meta'] = p_get_metadata($ID);
+
+ // setup a draft, make it more recent than the current page
+ // - pageinfo should recognise it and keep it
+ $draft = getCacheName($info['client'].$ID,'.draft');
+ touch($draft,$rev + 10);
+
+ $info['draft'] = $draft;
+
+ $this->assertEquals($info, pageinfo());
+ $this->assertFileExists($draft);
+
+ // make the draft older than the current page
+ // - pageinfo should remove it and not return the 'draft' key
+ touch($draft,$rev - 10);
+ unset($info['draft']);
+
+ $this->assertEquals($info, pageinfo());
+ $this->assertFalse(file_exists($draft));
+ }
+
+ /**
+ * check ismobile
+ */
+ function test_ismobile(){
+ global $ID,$conf;
+ $ID = 'wiki:start';
+
+ $info = $this->_get_expected_pageinfo();
+ $info['id'] = 'wiki:start';
+ $info['namespace'] = 'wiki';
+ $info['filepath'] = $conf['datadir'].'/wiki/start.txt';
+
+ // overkill, ripped from clientismobile() as we aren't testing detection - but forcing it
+ $_SERVER['HTTP_X_WAP_PROFILE'] = 'a fake url';
+ $_SERVER['HTTP_ACCEPT'] .= ';wap';
+ $_SERVER['HTTP_USER_AGENT'] = 'blackberry,symbian,hand,mobi,phone';
+
+ $info['ismobile'] = clientismobile();
+
+ $this->assertTrue(clientismobile()); // ensure THIS test fails if clientismobile() returns false
+ $this->assertEquals($info, pageinfo()); // it would be a test failure not a pageinfo failure.
+ }
+}
+
+//Setup VIM: ex: et ts=4 :
diff --git a/_test/tests/inc/httpclient_http.test.php b/_test/tests/inc/httpclient_http.test.php
index 9959a1f06..252eb6b65 100644
--- a/_test/tests/inc/httpclient_http.test.php
+++ b/_test/tests/inc/httpclient_http.test.php
@@ -134,6 +134,19 @@ class httpclient_http_test extends DokuWikiTest {
/**
* @group internet
*/
+ function test_maxbodyok(){
+ $http = new HTTPClient();
+ $http->max_bodysize = 500*1024;
+ $data = $http->get($this->server.'/stream/5');
+ $this->assertTrue($data !== false, 'HTTP response');
+ $http->max_bodysize_abort = false;
+ $data = $http->get($this->server.'/stream/5');
+ $this->assertTrue($data !== false, 'HTTP response');
+ }
+
+ /**
+ * @group internet
+ */
function test_basicauth(){
$http = new HTTPClient();
$http->user = 'user';
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/media_get_from_url.test.php b/_test/tests/inc/media_get_from_url.test.php
new file mode 100644
index 000000000..3903b8a05
--- /dev/null
+++ b/_test/tests/inc/media_get_from_url.test.php
@@ -0,0 +1,80 @@
+<?php
+
+class media_get_from_url_test extends DokuWikiTest {
+
+ /**
+ * @group internet
+ */
+ public function test_cache(){
+ global $conf;
+ $conf['fetchsize'] = 500*1024; //500kb
+
+
+ $local = media_get_from_URL('http://www.google.com/images/srpr/logo3w.png','png',-1);
+ $this->assertTrue($local !== false);
+ $this->assertFileExists($local);
+
+ // remember time stamp
+ $time = filemtime($local);
+ clearstatcache(false, $local);
+ sleep(1);
+
+ // fetch again and make sure we got a cache file
+ $local = media_get_from_URL('http://www.google.com/images/srpr/logo3w.png','png',-1);
+ clearstatcache(false, $local);
+ $this->assertTrue($local !== false);
+ $this->assertFileExists($local);
+ $this->assertEquals($time, filemtime($local));
+
+ unlink($local);
+ }
+
+ /**
+ * @group internet
+ */
+ public function test_nocache(){
+ global $conf;
+ $conf['fetchsize'] = 500*1024; //500kb
+
+ $local = media_get_from_URL('http://www.google.com/images/srpr/logo3w.png','png',0);
+ $this->assertFalse($local);
+ }
+
+ /**
+ * @group internet
+ * @group slow
+ */
+ public function test_recache(){
+ global $conf;
+ $conf['fetchsize'] = 500*1024; //500kb
+
+
+ $local = media_get_from_URL('http://www.google.com/images/srpr/logo3w.png','png',5);
+ $this->assertTrue($local !== false);
+ $this->assertFileExists($local);
+
+ // remember time stamp
+ $time = filemtime($local);
+ clearstatcache(false, $local);
+ sleep(1);
+
+ // fetch again and make sure we got a cache file
+ $local = media_get_from_URL('http://www.google.com/images/srpr/logo3w.png','png',5);
+ clearstatcache(false, $local);
+ $this->assertTrue($local !== false);
+ $this->assertFileExists($local);
+ $this->assertEquals($time, filemtime($local));
+
+ clearstatcache(false, $local);
+ sleep(6);
+
+ // fetch again and make sure we got a new file
+ $local = media_get_from_URL('http://www.google.com/images/srpr/logo3w.png','png',5);
+ clearstatcache(false, $local);
+ $this->assertTrue($local !== false);
+ $this->assertFileExists($local);
+ $this->assertNotEquals($time, filemtime($local));
+
+ unlink($local);
+ }
+} \ No newline at end of file
diff --git a/_test/tests/inc/media_ispublic.test.php b/_test/tests/inc/media_ispublic.test.php
new file mode 100644
index 000000000..307c64654
--- /dev/null
+++ b/_test/tests/inc/media_ispublic.test.php
@@ -0,0 +1,18 @@
+<?php
+
+class media_ispublic_test extends DokuWikiTest {
+
+
+ public function test_external(){
+ $this->assertTrue(media_ispublic('http://www.example.com/foo.png'));
+ $this->assertTrue(media_ispublic('https://www.example.com/foo.png'));
+ $this->assertTrue(media_ispublic('hTTp://www.example.com/foo.png'));
+ $this->assertTrue(media_ispublic('hTTps://www.example.com/foo.png'));
+ }
+
+ public function test_internal(){
+ $this->assertTrue(media_ispublic('wiki:logo.png'));
+ $this->assertFalse(media_ispublic('private:logo.png'));
+ }
+
+} \ No newline at end of file
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/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/remote.test.php b/_test/tests/inc/remote.test.php
index 49152d8db..d0d4eb7ce 100644
--- a/_test/tests/inc/remote.test.php
+++ b/_test/tests/inc/remote.test.php
@@ -1,6 +1,6 @@
<?php
-class MockAuth extends auth_basic {
+class MockAuth extends DokuWiki_Auth_Plugin {
function isCaseSensitive() { return true; }
}
@@ -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..33d4e9d8d 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 2 so I should get only pages from ns1
+ $data = array();
+ search($data, dirname(__FILE__) . '/data', 'search_allpages', array('depth' => 2), '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