summaryrefslogtreecommitdiff
path: root/_test/tests/inc
diff options
context:
space:
mode:
Diffstat (limited to '_test/tests/inc')
-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
8 files changed, 197 insertions, 10 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/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){