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') 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 0483f97f57369aa0b4ba028a881a78fda540d2a9 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 28 Jul 2012 15:41:53 +0200 Subject: added multiby html_highlight tests FS#2440 --- _test/tests/inc/html_hilight.test.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to '_test') diff --git a/_test/tests/inc/html_hilight.test.php b/_test/tests/inc/html_hilight.test.php index bb0cdd424..fc4eced67 100644 --- a/_test/tests/inc/html_hilight.test.php +++ b/_test/tests/inc/html_hilight.test.php @@ -97,4 +97,36 @@ class html_hilight_test extends DokuWikiTest { html_hilight($html,'x/') ); } + + function testMB() { + $html = 'foo ДокуВики bar'; + $this->assertRegExp( + '/foo ДокуВики<\/span> bar/', + html_hilight($html,'ДокуВики') + ); + } + + function testMBright() { + $html = 'foo ДокуВики bar'; + $this->assertRegExp( + '/foo Доку<\/span>Вики bar/', + html_hilight($html,'Доку*') + ); + } + + function testMBleft() { + $html = 'foo ДокуВики bar'; + $this->assertRegExp( + '/foo ДокуВики<\/span> bar/', + html_hilight($html,'*Вики') + ); + } + + function testMBboth() { + $html = 'foo ДокуВики bar'; + $this->assertRegExp( + '/foo ДокуВи<\/span>ки bar/', + html_hilight($html,'*куВи*') + ); + } } -- cgit v1.2.3 From 420addb2e4aefb77d089e776672d40c18f86b2ac Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 29 Jul 2012 10:45:53 +0200 Subject: fix utf8_basename for file names without any directory --- _test/tests/inc/utf8_basename.test.php | 3 +++ 1 file changed, 3 insertions(+) (limited to '_test') diff --git a/_test/tests/inc/utf8_basename.test.php b/_test/tests/inc/utf8_basename.test.php index 1cb5b5606..62d006088 100644 --- a/_test/tests/inc/utf8_basename.test.php +++ b/_test/tests/inc/utf8_basename.test.php @@ -59,6 +59,9 @@ class utf8_basename_test extends DokuWikiTest { array('\\this\\foo\\ДокуВики.test.Вик', '.Вик', 'ДокуВики.test'), array('/this\\foo/ДокуВики.test.Вик', '.Вик', 'ДокуВики.test'), array('/this/foo\\ДокуВики.test.Вик', '.Вик', 'ДокуВики.test'), + + array('bar.test.png', '', 'bar.test.png'), + array('bar.test.png', '.png', 'bar.test'), ); foreach($data as $test){ -- cgit v1.2.3 From a8c343f2838765f8034ee6b91263b1b417f3a7ec Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Sun, 29 Jul 2012 12:09:31 +0200 Subject: Fix utf8_basename for files in the root directory --- _test/tests/inc/utf8_basename.test.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to '_test') diff --git a/_test/tests/inc/utf8_basename.test.php b/_test/tests/inc/utf8_basename.test.php index 62d006088..475b7ada8 100644 --- a/_test/tests/inc/utf8_basename.test.php +++ b/_test/tests/inc/utf8_basename.test.php @@ -62,6 +62,10 @@ class utf8_basename_test extends DokuWikiTest { array('bar.test.png', '', 'bar.test.png'), array('bar.test.png', '.png', 'bar.test'), + + array('/bar.test.png', '', 'bar.test.png'), + array('\\bar.test.png', '', 'bar.test.png'), + array('/bar.test.png', '.png', 'bar.test'), ); foreach($data as $test){ -- cgit v1.2.3 From fa446926c63aef4f4f394967b84d20e2da0dad6d Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 29 Jul 2012 12:09:42 +0200 Subject: more utf8_basename fixes --- _test/tests/inc/utf8_basename.test.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to '_test') diff --git a/_test/tests/inc/utf8_basename.test.php b/_test/tests/inc/utf8_basename.test.php index 475b7ada8..1544e9915 100644 --- a/_test/tests/inc/utf8_basename.test.php +++ b/_test/tests/inc/utf8_basename.test.php @@ -64,8 +64,23 @@ class utf8_basename_test extends DokuWikiTest { array('bar.test.png', '.png', 'bar.test'), array('/bar.test.png', '', 'bar.test.png'), - array('\\bar.test.png', '', 'bar.test.png'), array('/bar.test.png', '.png', 'bar.test'), + array('\\bar.test.png', '', 'bar.test.png'), + array('\\bar.test.png', '.png', 'bar.test'), + array('\\/bar.test.png', '', 'bar.test.png'), + array('\\/bar.test.png', '.png', 'bar.test'), + array('/\\bar.test.png', '', 'bar.test.png'), + array('/\\bar.test.png', '.png', 'bar.test'), + + // PHP's basename does this too: + array('foo/', '', 'foo'), + array('foo\\', '', 'foo'), + array('foo\\/', '', 'foo'), + array('foo/\\', '', 'foo'), + array('foo.png/', '.png', 'foo'), + array('foo.png\\', '.png', 'foo'), + array('foo.png\\/', '.png', 'foo'), + array('foo.png/\\', '.png', 'foo'), ); foreach($data as $test){ -- cgit v1.2.3 From 80a47290a7a01f2a320d09d387eea690ce1f62b4 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Mon, 6 Aug 2012 20:34:51 +0200 Subject: do not recompress already minified js FS#2574 --- _test/tests/lib/exe/js_js_compress.test.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to '_test') diff --git a/_test/tests/lib/exe/js_js_compress.test.php b/_test/tests/lib/exe/js_js_compress.test.php index 49f93cc54..b1ae2a84f 100644 --- a/_test/tests/lib/exe/js_js_compress.test.php +++ b/_test/tests/lib/exe/js_js_compress.test.php @@ -118,6 +118,32 @@ class js_js_compress_test extends DokuWikiTest { $this->assertEquals("var foo='this is a multiline string';",js_compress($text)); } + function test_nocompress(){ + $text = <<assertEquals($out, js_compress($text)); + } /** * Test the files provided with the original JsStrip -- cgit v1.2.3 From d9e9c1bb60342ce88be150cc05de21dabfe130b2 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Thu, 9 Aug 2012 23:28:11 +0200 Subject: extract method for Input class makes it easier to access our do parameters --- _test/tests/inc/input.test.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to '_test') diff --git a/_test/tests/inc/input.test.php b/_test/tests/inc/input.test.php index 761b7ddbc..59b5ea4b9 100644 --- a/_test/tests/inc/input.test.php +++ b/_test/tests/inc/input.test.php @@ -12,7 +12,8 @@ class input_test extends DokuWikiTest { 'zero' => '0', 'one' => '1', 'empty' => '', - 'emptya' => array() + 'emptya' => array(), + 'do' => array('save' => 'Speichern'), ); public function test_str() { @@ -213,4 +214,20 @@ class input_test extends DokuWikiTest { $this->assertEquals('bla',$test); } + public function test_extract(){ + $_REQUEST = $this->data; + $_POST = $this->data; + $_GET = $this->data; + $INPUT = new Input(); + + $this->assertEquals('save', $INPUT->extract('do')->str('do')); + $this->assertEquals('', $INPUT->extract('emptya')->str('emptya')); + $this->assertEquals('foo', $INPUT->extract('string')->str('string')); + $this->assertEquals('foo', $INPUT->extract('array')->str('array')); + + $this->assertEquals('save', $INPUT->post->extract('do')->str('do')); + $this->assertEquals('', $INPUT->post->extract('emptya')->str('emptya')); + $this->assertEquals('foo', $INPUT->post->extract('string')->str('string')); + $this->assertEquals('foo', $INPUT->post->extract('array')->str('array')); + } } -- cgit v1.2.3 From 0edda900aa7730d677390edffa0bdd7cab736e1d Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 26 Aug 2012 16:02:48 +0200 Subject: replace deprecated split calls FS#2583 --- _test/core/phpQuery-onefile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '_test') diff --git a/_test/core/phpQuery-onefile.php b/_test/core/phpQuery-onefile.php index 4c1dfa3da..402cf8e49 100644 --- a/_test/core/phpQuery-onefile.php +++ b/_test/core/phpQuery-onefile.php @@ -4206,7 +4206,7 @@ class phpQueryObject .($node->getAttribute('id') ? '#'.$node->getAttribute('id'):'') .($node->getAttribute('class') - ? '.'.join('.', split(' ', $node->getAttribute('class'))):'') + ? '.'.join('.', explode(' ', $node->getAttribute('class'))):'') .($node->getAttribute('name') ? '[name="'.$node->getAttribute('name').'"]':'') .($node->getAttribute('value') && strpos($node->getAttribute('value'), '<'.'?php') === false -- 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') 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 0c313f7823f6b43dd546221b81e0e22613a04d23 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Tue, 2 Oct 2012 00:23:22 +0200 Subject: Always load the parser in the test environment This fixes the problem that $PARSER_MODES was sometimes unset by PHPUnit between test functions that called p_get_parsermodes() as PHPUnit tried to restore the global environment. I couldn't reproduce this when I executed all tests but just when I executed a single plugin test. --- _test/bootstrap.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to '_test') diff --git a/_test/bootstrap.php b/_test/bootstrap.php index 58ad6a0d7..310b3627a 100644 --- a/_test/bootstrap.php +++ b/_test/bootstrap.php @@ -110,3 +110,7 @@ $dh->close(); // load dw require_once(DOKU_INC.'inc/init.php'); +// load the parser so $PARSER_MODES is defined before the tests start +// otherwise PHPUnit unsets $PARSER_MODES in some cases which breaks p_get_parsermodes() +require_once(DOKU_INC.'inc/parser/parser.php'); + -- 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') 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') 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') 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') 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 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') 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