summaryrefslogtreecommitdiff
path: root/_test
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2012-11-08 23:15:08 +0100
committerAndreas Gohr <andi@splitbrain.org>2012-11-08 23:15:08 +0100
commit04924b7a9d090c0814cfff3e6706263e4d5a46e8 (patch)
treed83fc6b5683fbc9c639bfd1832f96dca2f3c8646 /_test
parent1ea7a6bada66fc9b7a45f61b4892e4ea23196d89 (diff)
parenta731ed1d6736ca405b3559adfd9500affcc59412 (diff)
downloadrpg-04924b7a9d090c0814cfff3e6706263e4d5a46e8.tar.gz
rpg-04924b7a9d090c0814cfff3e6706263e4d5a46e8.tar.bz2
Merge branch 'master' into proxyconnect
* master: (169 commits) added PCRE UTF-8 checks to do=check FS#2636 avoid multiple paralell update checks fix regression bug in HTTPClient FS#2621 changed PAGEUTILS_ID_HIDEPAGE to has BEFORE/AFTER TarLib code cleanup TarLib: fixed appending in non-dynamic mode fixed third method of adding files in TarLib fix lone zero block in TarLib created archives fix use of constructor in TarLib Slovak language update Korean language update Latvian language update added event PAGEUTILS_ID_HIDEPAGE added test for isHiddenPage() removed redundant variables in tpl_include_page() (because of 3ff8773b) added cut off points for mobile devices as parameters to style.ini Corrected typo: ruke -> rule Persian language update Spanish language update russian language update ...
Diffstat (limited to '_test')
-rw-r--r--_test/bootstrap.php4
-rw-r--r--_test/core/phpQuery-onefile.php2
-rw-r--r--_test/tests/inc/PageUtilsIsHiddenPage.test.php95
-rw-r--r--_test/tests/inc/html_hilight.test.php32
-rw-r--r--_test/tests/inc/input.test.php19
-rw-r--r--_test/tests/inc/parserutils_set_metadata_during_rendering.test.php3
-rw-r--r--_test/tests/inc/subscription_set.test.php20
-rw-r--r--_test/tests/inc/tarlib.test.php0
-rw-r--r--_test/tests/inc/template_include_page.test.php (renamed from _test/tests/inc/template_sidebar.test.php)16
-rw-r--r--_test/tests/inc/utf8_basename.test.php22
-rw-r--r--_test/tests/lib/exe/js_js_compress.test.php26
11 files changed, 228 insertions, 11 deletions
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');
+
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
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/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.*>ДокуВики<\/span> bar/',
+ html_hilight($html,'ДокуВики')
+ );
+ }
+
+ function testMBright() {
+ $html = 'foo ДокуВики bar';
+ $this->assertRegExp(
+ '/foo <span.*>Доку<\/span>Вики bar/',
+ html_hilight($html,'Доку*')
+ );
+ }
+
+ function testMBleft() {
+ $html = 'foo ДокуВики bar';
+ $this->assertRegExp(
+ '/foo Доку<span.*>Вики<\/span> bar/',
+ html_hilight($html,'*Вики')
+ );
+ }
+
+ function testMBboth() {
+ $html = 'foo ДокуВики bar';
+ $this->assertRegExp(
+ '/foo До<span.*>куВи<\/span>ки bar/',
+ html_hilight($html,'*куВи*')
+ );
+ }
}
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'));
+ }
}
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/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 @@
+<?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/tarlib.test.php b/_test/tests/inc/tarlib.test.php
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/_test/tests/inc/tarlib.test.php
diff --git a/_test/tests/inc/template_sidebar.test.php b/_test/tests/inc/template_include_page.test.php
index 56153894a..47d4d46f1 100644
--- a/_test/tests/inc/template_sidebar.test.php
+++ b/_test/tests/inc/template_include_page.test.php
@@ -1,12 +1,12 @@
<?php
-class template_sidebar_test extends DokuWikiTest {
+class template_include_page_test extends DokuWikiTest {
function testNoSidebar() {
global $ID;
$ID = 'foo:bar:baz:test';
- $sidebar = tpl_sidebar(false);
- $this->assertEquals('',$sidebar);
+ $sidebar = tpl_include_page('sidebar', false, true);
+ $this->assertEquals('', $sidebar);
}
function testExistingSidebars() {
@@ -15,25 +15,25 @@ class template_sidebar_test extends DokuWikiTest {
saveWikiText('sidebar', 'topsidebar-test', '');
$ID = 'foo:bar:baz:test';
- $sidebar = tpl_sidebar(false);
+ $sidebar = tpl_include_page('sidebar', false, true);
$this->assertTrue(strpos($sidebar, 'topsidebar-test') > 0);
$ID = 'foo';
- $sidebar = tpl_sidebar(false);
+ $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_sidebar(false);
+ $sidebar = tpl_include_page('sidebar', false, true);
$this->assertTrue(strpos($sidebar, 'bottomsidebar-test') > 0);
$ID = 'foo:bar:test';
- $sidebar = tpl_sidebar(false);
+ $sidebar = tpl_include_page('sidebar', false, true);
$this->assertTrue(strpos($sidebar, 'bottomsidebar-test') > 0);
$ID = 'foo';
- $sidebar = tpl_sidebar(false);
+ $sidebar = tpl_include_page('sidebar', false, true);
$this->assertTrue(strpos($sidebar, 'topsidebar-test') > 0);
}
diff --git a/_test/tests/inc/utf8_basename.test.php b/_test/tests/inc/utf8_basename.test.php
index 1cb5b5606..1544e9915 100644
--- a/_test/tests/inc/utf8_basename.test.php
+++ b/_test/tests/inc/utf8_basename.test.php
@@ -59,6 +59,28 @@ 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'),
+
+ 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){
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 = <<<EOF
+var meh = 'test' ;
+
+/* BEGIN NOCOMPRESS */
+
+
+var foo = 'test' ;
+
+var bar = 'test' ;
+
+
+/* END NOCOMPRESS */
+
+var moh = 'test' ;
+EOF;
+ $out = <<<EOF
+var meh='test';
+var foo = 'test' ;
+
+var bar = 'test' ;
+var moh='test';
+EOF;
+
+ $this->assertEquals($out, js_compress($text));
+ }
/**
* Test the files provided with the original JsStrip