From e8b5a4f91c8a6e230a6cfe13c43dc9ddce31e253 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 28 Jul 2012 12:02:06 +0200 Subject: fix E_STRICT errors FS#2427 This commit fixes all E_STRICT messages shown when running the test suite. There might be more problems not covered by tests, yet. For compatibility reasons with plugins, E_STRICT errors are still supressed. --- _test/tests/inc/parserutils_set_metadata_during_rendering.test.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to '_test/tests') 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)); -- cgit v1.2.3 From 0a78cb463952660f3bb257dd3dd030db725cd4f4 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Fri, 7 Sep 2012 21:06:57 +0200 Subject: Fix the test if a subscription already exists FS#2580 This fixes the test for existing subscriptions by not only testing if the subscription for the deepest namespace level is for the current page but by simply testing all levels. Test case is included, it fails without this change. --- _test/tests/inc/subscription_set.test.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 _test/tests/inc/subscription_set.test.php (limited to '_test/tests') diff --git a/_test/tests/inc/subscription_set.test.php b/_test/tests/inc/subscription_set.test.php new file mode 100644 index 000000000..5c0a6c816 --- /dev/null +++ b/_test/tests/inc/subscription_set.test.php @@ -0,0 +1,20 @@ + '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'); + } +} -- cgit v1.2.3 From 680b17407a599dced5eb57e9a6467ee36d4f68b8 Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Sat, 6 Oct 2012 14:06:30 +0100 Subject: fixed sidebar test and renamed it to reflect recent changes --- _test/tests/inc/template_include_page.test.php | 40 ++++++++++++++++++++++++++ _test/tests/inc/template_sidebar.test.php | 40 -------------------------- 2 files changed, 40 insertions(+), 40 deletions(-) create mode 100644 _test/tests/inc/template_include_page.test.php delete mode 100644 _test/tests/inc/template_sidebar.test.php (limited to '_test/tests') diff --git a/_test/tests/inc/template_include_page.test.php b/_test/tests/inc/template_include_page.test.php new file mode 100644 index 000000000..47d4d46f1 --- /dev/null +++ b/_test/tests/inc/template_include_page.test.php @@ -0,0 +1,40 @@ +assertEquals('', $sidebar); + } + + function testExistingSidebars() { + global $ID; + + saveWikiText('sidebar', 'topsidebar-test', ''); + + $ID = 'foo:bar:baz:test'; + $sidebar = tpl_include_page('sidebar', false, true); + $this->assertTrue(strpos($sidebar, 'topsidebar-test') > 0); + + $ID = 'foo'; + $sidebar = tpl_include_page('sidebar', false, true); + $this->assertTrue(strpos($sidebar, 'topsidebar-test') > 0); + + saveWikiText('foo:bar:sidebar', 'bottomsidebar-test', ''); + + $ID = 'foo:bar:baz:test'; + $sidebar = tpl_include_page('sidebar', false, true); + $this->assertTrue(strpos($sidebar, 'bottomsidebar-test') > 0); + + $ID = 'foo:bar:test'; + $sidebar = tpl_include_page('sidebar', false, true); + $this->assertTrue(strpos($sidebar, 'bottomsidebar-test') > 0); + + $ID = 'foo'; + $sidebar = tpl_include_page('sidebar', false, true); + $this->assertTrue(strpos($sidebar, 'topsidebar-test') > 0); + } + +} diff --git a/_test/tests/inc/template_sidebar.test.php b/_test/tests/inc/template_sidebar.test.php deleted file mode 100644 index 56153894a..000000000 --- a/_test/tests/inc/template_sidebar.test.php +++ /dev/null @@ -1,40 +0,0 @@ -assertEquals('',$sidebar); - } - - function testExistingSidebars() { - global $ID; - - saveWikiText('sidebar', 'topsidebar-test', ''); - - $ID = 'foo:bar:baz:test'; - $sidebar = tpl_sidebar(false); - $this->assertTrue(strpos($sidebar, 'topsidebar-test') > 0); - - $ID = 'foo'; - $sidebar = tpl_sidebar(false); - $this->assertTrue(strpos($sidebar, 'topsidebar-test') > 0); - - saveWikiText('foo:bar:sidebar', 'bottomsidebar-test', ''); - - $ID = 'foo:bar:baz:test'; - $sidebar = tpl_sidebar(false); - $this->assertTrue(strpos($sidebar, 'bottomsidebar-test') > 0); - - $ID = 'foo:bar:test'; - $sidebar = tpl_sidebar(false); - $this->assertTrue(strpos($sidebar, 'bottomsidebar-test') > 0); - - $ID = 'foo'; - $sidebar = tpl_sidebar(false); - $this->assertTrue(strpos($sidebar, 'topsidebar-test') > 0); - } - -} -- cgit v1.2.3 From d12bd962d0cacbaad479be04cc953c607212756f Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Wed, 31 Oct 2012 16:33:22 +0100 Subject: added test for isHiddenPage() --- _test/tests/inc/pageutils_isHiddenPage.test.php | 37 +++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 _test/tests/inc/pageutils_isHiddenPage.test.php (limited to '_test/tests') diff --git a/_test/tests/inc/pageutils_isHiddenPage.test.php b/_test/tests/inc/pageutils_isHiddenPage.test.php new file mode 100644 index 000000000..8f2fcebea --- /dev/null +++ b/_test/tests/inc/pageutils_isHiddenPage.test.php @@ -0,0 +1,37 @@ +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')); + } + +} +//Setup VIM: ex: et ts=4 : -- cgit v1.2.3 From 8449cc9d82848df24eb88a73dd81d7e048933287 Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Wed, 31 Oct 2012 16:51:54 +0100 Subject: added event PAGEUTILS_ID_HIDEPAGE --- _test/tests/inc/PageUtilsIsHiddenPage.test.php | 49 +++++++++++++++++++++++++ _test/tests/inc/pageutils_isHiddenPage.test.php | 37 ------------------- 2 files changed, 49 insertions(+), 37 deletions(-) create mode 100644 _test/tests/inc/PageUtilsIsHiddenPage.test.php delete mode 100644 _test/tests/inc/pageutils_isHiddenPage.test.php (limited to '_test/tests') diff --git a/_test/tests/inc/PageUtilsIsHiddenPage.test.php b/_test/tests/inc/PageUtilsIsHiddenPage.test.php new file mode 100644 index 000000000..153d0e8f6 --- /dev/null +++ b/_test/tests/inc/PageUtilsIsHiddenPage.test.php @@ -0,0 +1,49 @@ +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 testEventHandler() { + global $EVENT_HANDLER; + $this->prepare(); + $EVENT_HANDLER->register_hook('PAGEUTILS_ID_HIDEPAGE', 'BEFORE', $this, 'alwaysHide'); + + $this->assertFalse(isHiddenPage('test')); + } + + function alwaysHide(Doku_Event &$event, $params) { + $event->data['hide'] = true; + } + +} +//Setup VIM: ex: et ts=4 : diff --git a/_test/tests/inc/pageutils_isHiddenPage.test.php b/_test/tests/inc/pageutils_isHiddenPage.test.php deleted file mode 100644 index 8f2fcebea..000000000 --- a/_test/tests/inc/pageutils_isHiddenPage.test.php +++ /dev/null @@ -1,37 +0,0 @@ -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')); - } - -} -//Setup VIM: ex: et ts=4 : -- cgit v1.2.3 From d922c55256c59ee6ee332a4db8740a01e559dcee Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 3 Nov 2012 09:36:29 +0100 Subject: fix use of constructor in TarLib --- _test/tests/inc/tarlib.test.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 _test/tests/inc/tarlib.test.php (limited to '_test/tests') diff --git a/_test/tests/inc/tarlib.test.php b/_test/tests/inc/tarlib.test.php new file mode 100644 index 000000000..e69de29bb -- cgit v1.2.3 From bee9f377bc547c99fe99b4e38199cb92cf668554 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 3 Nov 2012 17:54:02 +0100 Subject: Completely rewritten Tar library This new class is only losely based on our previous library. The whole API was changed to make it more flexible and memory saving. Some fisrt unit tests are included --- _test/tests/inc/tar.test.php | 134 +++++++++++++++++++++++++++++++ _test/tests/inc/tar/foobar/testdata2.txt | 1 + _test/tests/inc/tar/test.tar | Bin 0 -> 10240 bytes _test/tests/inc/tar/test.tbz | Bin 0 -> 217 bytes _test/tests/inc/tar/test.tgz | Bin 0 -> 220 bytes _test/tests/inc/tar/testdata1.txt | 1 + _test/tests/inc/tarlib.test.php | 0 7 files changed, 136 insertions(+) create mode 100644 _test/tests/inc/tar.test.php create mode 100644 _test/tests/inc/tar/foobar/testdata2.txt create mode 100644 _test/tests/inc/tar/test.tar create mode 100644 _test/tests/inc/tar/test.tbz create mode 100644 _test/tests/inc/tar/test.tgz create mode 100644 _test/tests/inc/tar/testdata1.txt delete mode 100644 _test/tests/inc/tarlib.test.php (limited to '_test/tests') diff --git a/_test/tests/inc/tar.test.php b/_test/tests/inc/tar.test.php new file mode 100644 index 000000000..706516d9e --- /dev/null +++ b/_test/tests/inc/tar.test.php @@ -0,0 +1,134 @@ +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); + } + + } + + /** + * 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')); + } +} \ 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/test.tar b/_test/tests/inc/tar/test.tar new file mode 100644 index 000000000..931866b0b Binary files /dev/null and b/_test/tests/inc/tar/test.tar differ diff --git a/_test/tests/inc/tar/test.tbz b/_test/tests/inc/tar/test.tbz new file mode 100644 index 000000000..5a7374019 Binary files /dev/null and b/_test/tests/inc/tar/test.tbz differ diff --git a/_test/tests/inc/tar/test.tgz b/_test/tests/inc/tar/test.tgz new file mode 100644 index 000000000..b00319649 Binary files /dev/null and b/_test/tests/inc/tar/test.tgz 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 -- cgit v1.2.3 From 7252880f21c842017c334eb15c6a7a174f950798 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 3 Nov 2012 18:30:52 +0100 Subject: added test cases for Tar::extract parameters --- _test/tests/inc/tar.test.php | 103 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) (limited to '_test/tests') diff --git a/_test/tests/inc/tar.test.php b/_test/tests/inc/tar.test.php index 706516d9e..4de9e668d 100644 --- a/_test/tests/inc/tar.test.php +++ b/_test/tests/inc/tar.test.php @@ -113,9 +113,112 @@ class Tar_TestCase extends DokuWikiTest { 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 */ -- cgit v1.2.3 From 421a2704022cbc8fa07ab673c2d503199f460b8e Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 4 Nov 2012 10:36:58 +0100 Subject: Tar: Added extraction support for long file names Supports POSIX ustar prefixes and GNU longlink entries --- _test/tests/inc/tar.test.php | 17 ++++++++++++++++- _test/tests/inc/tar/longpath-gnu.tgz | Bin 0 -> 413 bytes _test/tests/inc/tar/longpath-ustar.tgz | Bin 0 -> 311 bytes 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 _test/tests/inc/tar/longpath-gnu.tgz create mode 100644 _test/tests/inc/tar/longpath-ustar.tgz (limited to '_test/tests') diff --git a/_test/tests/inc/tar.test.php b/_test/tests/inc/tar.test.php index 4de9e668d..9abd27612 100644 --- a/_test/tests/inc/tar.test.php +++ b/_test/tests/inc/tar.test.php @@ -218,7 +218,6 @@ class Tar_TestCase extends DokuWikiTest { } } - /** * Check the extension to compression guesser */ @@ -234,4 +233,20 @@ class Tar_TestCase extends DokuWikiTest { $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); + } + } + } \ No newline at end of file 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 Binary files /dev/null and b/_test/tests/inc/tar/longpath-gnu.tgz 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 Binary files /dev/null and b/_test/tests/inc/tar/longpath-ustar.tgz differ -- cgit v1.2.3 From 90a1db709d3590e849a5a4966fbdf8fb58ae75cd Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 4 Nov 2012 11:31:20 +0100 Subject: Tar: support for creating archives with long filenames The library now creates either a POSIX ustar prefix or a GNU longlink entry for files which have a name longer than 100 bytes --- _test/tests/inc/tar.test.php | 97 +++++++++++++++++++++++++++++++++----------- 1 file changed, 73 insertions(+), 24 deletions(-) (limited to '_test/tests') diff --git a/_test/tests/inc/tar.test.php b/_test/tests/inc/tar.test.php index 9abd27612..47851fd4c 100644 --- a/_test/tests/inc/tar.test.php +++ b/_test/tests/inc/tar.test.php @@ -8,7 +8,7 @@ class Tar_TestCase extends DokuWikiTest { * * No check for format correctness */ - public function test_createdynamic(){ + public function test_createdynamic() { $tar = new Tar(); $dir = dirname(__FILE__).'/tar'; @@ -38,7 +38,7 @@ class Tar_TestCase extends DokuWikiTest { * * No check for format correctness */ - public function test_createfile(){ + public function test_createfile() { $tar = new Tar(); $dir = dirname(__FILE__).'/tar'; @@ -70,10 +70,10 @@ class Tar_TestCase extends DokuWikiTest { /** * List the contents of the prebuilt TAR files */ - public function test_tarcontent(){ + public function test_tarcontent() { $dir = dirname(__FILE__).'/tar'; - foreach(array('tar','tgz','tbz') as $ext){ + foreach(array('tar', 'tgz', 'tbz') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -92,11 +92,11 @@ class Tar_TestCase extends DokuWikiTest { /** * Extract the prebuilt tar files */ - public function test_tarextract(){ + public function test_tarextract() { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext){ + foreach(array('tar', 'tgz', 'tbz') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -118,16 +118,16 @@ class Tar_TestCase extends DokuWikiTest { /** * Extract the prebuilt tar files with component stripping */ - public function test_compstripextract(){ + public function test_compstripextract() { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext){ + foreach(array('tar', 'tgz', 'tbz') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; $tar->open($file); - $tar->extract($out,1); + $tar->extract($out, 1); clearstatcache(); @@ -144,16 +144,16 @@ class Tar_TestCase extends DokuWikiTest { /** * Extract the prebuilt tar files with prefix stripping */ - public function test_prefixstripextract(){ + public function test_prefixstripextract() { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext){ + foreach(array('tar', 'tgz', 'tbz') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; $tar->open($file); - $tar->extract($out,'tar/foobar/'); + $tar->extract($out, 'tar/foobar/'); clearstatcache(); @@ -170,22 +170,21 @@ class Tar_TestCase extends DokuWikiTest { /** * Extract the prebuilt tar files with include regex */ - public function test_includeextract(){ + public function test_includeextract() { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext){ + foreach(array('tar', 'tgz', 'tbz') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; $tar->open($file); - $tar->extract($out,'','','/\/foobar\//'); + $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"); @@ -196,16 +195,16 @@ class Tar_TestCase extends DokuWikiTest { /** * Extract the prebuilt tar files with exclude regex */ - public function test_excludeextract(){ + public function test_excludeextract() { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext){ + foreach(array('tar', 'tgz', 'tbz') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; $tar->open($file); - $tar->extract($out,'','/\/foobar\//'); + $tar->extract($out, '', '/\/foobar\//'); clearstatcache(); @@ -221,8 +220,8 @@ class Tar_TestCase extends DokuWikiTest { /** * Check the extension to compression guesser */ - public function test_filetype(){ - $tar = new Tar(); + 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')); @@ -234,12 +233,12 @@ class Tar_TestCase extends DokuWikiTest { $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tar.bz2')); } - public function test_longpathextract(){ + 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(); + foreach(array('ustar', 'gnu') as $format) { + $tar = new Tar(); $tar->open("$dir/longpath-$format.tgz"); $tar->extract($out); @@ -249,4 +248,54 @@ class Tar_TestCase extends DokuWikiTest { } } + 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); + } + } \ No newline at end of file -- cgit v1.2.3 From 2949ece61602372cf55fba6be4522fa8899fb70d Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 4 Nov 2012 12:21:47 +0100 Subject: unit test for tar bombs --- _test/tests/inc/tar.test.php | 18 ++++++++++++++++++ _test/tests/inc/tar/tarbomb.tgz | Bin 0 -> 183 bytes 2 files changed, 18 insertions(+) create mode 100644 _test/tests/inc/tar/tarbomb.tgz (limited to '_test/tests') diff --git a/_test/tests/inc/tar.test.php b/_test/tests/inc/tar.test.php index 47851fd4c..e8805a75d 100644 --- a/_test/tests/inc/tar.test.php +++ b/_test/tests/inc/tar.test.php @@ -298,4 +298,22 @@ class Tar_TestCase extends DokuWikiTest { @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/tarbomb.tgz b/_test/tests/inc/tar/tarbomb.tgz new file mode 100644 index 000000000..8418d4073 Binary files /dev/null and b/_test/tests/inc/tar/tarbomb.tgz differ -- cgit v1.2.3 From fb55b51ef82bc3066173e7547500d9e79c410e34 Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Mon, 5 Nov 2012 10:57:42 +0100 Subject: changed PAGEUTILS_ID_HIDEPAGE to has BEFORE/AFTER --- _test/tests/inc/PageUtilsIsHiddenPage.test.php | 52 ++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 3 deletions(-) (limited to '_test/tests') diff --git a/_test/tests/inc/PageUtilsIsHiddenPage.test.php b/_test/tests/inc/PageUtilsIsHiddenPage.test.php index 153d0e8f6..a7077862e 100644 --- a/_test/tests/inc/PageUtilsIsHiddenPage.test.php +++ b/_test/tests/inc/PageUtilsIsHiddenPage.test.php @@ -33,16 +33,62 @@ class PageUtilsIsHiddenPageTest extends DokuWikiTest { $this->assertFalse(isHiddenPage('another')); } - function testEventHandler() { + function testEventHandlerBefore() { global $EVENT_HANDLER; $this->prepare(); $EVENT_HANDLER->register_hook('PAGEUTILS_ID_HIDEPAGE', 'BEFORE', $this, 'alwaysHide'); - $this->assertFalse(isHiddenPage('test')); + $this->assertTrue(isHiddenPage('another')); } function alwaysHide(Doku_Event &$event, $params) { - $event->data['hide'] = true; + $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; } } -- cgit v1.2.3 From 1f61f312a78e212aaa4a4bc3f60961036ec07fd7 Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Fri, 23 Nov 2012 18:48:09 +0100 Subject: remove empty BCC/CC mail headers Empty BCC/CC headers may cause errors on IIS. --- _test/tests/inc/mailer.test.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to '_test/tests') diff --git a/_test/tests/inc/mailer.test.php b/_test/tests/inc/mailer.test.php index b2c74a257..91c4a999d 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,14 @@ class mailer_test extends DokuWikiTest { } } + 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 : -- cgit v1.2.3 From 91effd8de07e4afc59b6763ac72b268f58cfc941 Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Fri, 23 Nov 2012 19:55:44 +0100 Subject: ignore empty header on mail sending --- _test/tests/inc/mailer.test.php | 3 +++ 1 file changed, 3 insertions(+) (limited to '_test/tests') diff --git a/_test/tests/inc/mailer.test.php b/_test/tests/inc/mailer.test.php index 91c4a999d..053e216b8 100644 --- a/_test/tests/inc/mailer.test.php +++ b/_test/tests/inc/mailer.test.php @@ -98,6 +98,9 @@ class mailer_test extends DokuWikiTest { } } + /** + * @see https://forum.dokuwiki.org/post/35822 + */ function test_emptyBCCorCC() { $mail = new TestMailer(); $headers = &$mail->propRef('headers'); -- cgit v1.2.3 From eb3ce0d55290dd4a60193e680aa50b46571350bd Mon Sep 17 00:00:00 2001 From: Kazutaka Miyasaka Date: Sun, 25 Nov 2012 21:02:32 +0900 Subject: Fix case-insensitive match in ACL checking ACL checking of DokuWiki is currently always case-sensitive regardless of auth backend setting ($auth->isCaseSensitive). This commit enables case-insensitive match in the same way of auth_isMember(). --- .../inc/auth_aclcheck_caseinsensitive.test.php | 131 +++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 _test/tests/inc/auth_aclcheck_caseinsensitive.test.php (limited to '_test/tests') 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..9f1fb6aa0 --- /dev/null +++ b/_test/tests/inc/auth_aclcheck_caseinsensitive.test.php @@ -0,0 +1,131 @@ +oldConf = $conf; + $this->oldAuth = $auth; + $this->oldAuthAcl = $AUTH_ACL; + + $auth = new auth_acl_caseinsensitive_auth(); + } + + function teardown() { + global $conf; + global $AUTH_ACL; + global $auth; + + $conf = $this->oldConf; + $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); + } +} -- cgit v1.2.3 From ff576d9309a9a8c229caea79f2f8509cc986eee4 Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Thu, 29 Nov 2012 14:59:46 +0100 Subject: use correct setUp method and parent calls. --- _test/tests/inc/auth_aclcheck.test.php | 10 +++------- _test/tests/inc/auth_aclcheck_caseinsensitive.test.php | 9 +++------ _test/tests/inc/auth_admincheck.test.php | 5 ++--- _test/tests/inc/auth_nameencode.test.php | 2 +- _test/tests/inc/parser/parser.inc.php | 3 ++- _test/tests/inc/parser/parser_footnote.test.php | 4 ++-- _test/tests/inc/parser/parser_quotes.test.php | 4 ++-- _test/tests/inc/remote.test.php | 5 +---- 8 files changed, 16 insertions(+), 26 deletions(-) (limited to '_test/tests') diff --git a/_test/tests/inc/auth_aclcheck.test.php b/_test/tests/inc/auth_aclcheck.test.php index 991f82da7..8e5a04ff5 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(); } - 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 index 9f1fb6aa0..2f4821c2d 100644 --- a/_test/tests/inc/auth_aclcheck_caseinsensitive.test.php +++ b/_test/tests/inc/auth_aclcheck_caseinsensitive.test.php @@ -7,28 +7,25 @@ class auth_acl_caseinsensitive_auth extends auth_basic { } class auth_acl_caseinsensitive_test extends DokuWikiTest { - protected $oldConf; protected $oldAuth; protected $oldAuthAcl; - function setup() { - global $conf; + function setUp() { + parent::setUp(); global $auth; global $AUTH_ACL; - $this->oldConf = $conf; $this->oldAuth = $auth; $this->oldAuthAcl = $AUTH_ACL; $auth = new auth_acl_caseinsensitive_auth(); } - function teardown() { + function tearDown() { global $conf; global $AUTH_ACL; global $auth; - $conf = $this->oldConf; $auth = $this->oldAuth; $AUTH_ACL = $this->oldAuthAcl; } diff --git a/_test/tests/inc/auth_admincheck.test.php b/_test/tests/inc/auth_admincheck.test.php index d88399cbe..17424a08e 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/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 49152d8db..611e1ab0f 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; } -- cgit v1.2.3