summaryrefslogtreecommitdiff
path: root/_test
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2013-01-25 11:09:54 +0100
committerAndreas Gohr <andi@splitbrain.org>2013-01-25 11:09:54 +0100
commit33e75ca2f63b10ae1c7c7e9891ae857ce80d1811 (patch)
tree481e679c75e8eb5a58bd3f71a48f26ec87d86db4 /_test
parent3295f40a380553bb3f7f3018cee2e4462e0be417 (diff)
parenta24fc53e2623640cf5e2d00de741c1b67c9bb294 (diff)
downloadrpg-33e75ca2f63b10ae1c7c7e9891ae857ce80d1811.tar.gz
rpg-33e75ca2f63b10ae1c7c7e9891ae857ce80d1811.tar.bz2
Merge branch 'confmanager' into future
* confmanager: added failing test for array type started to add some unit tests to config manager Revert "config manager: let PHP parse the config file" added 'array' type for config manager config manager: let PHP parse the config file config manager: removed dead/commented code 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 added event PAGEUTILS_ID_HIDEPAGE added test for isHiddenPage() add index file similar to fileicons to show active smileys fix E_STRICT errors FS#2427
Diffstat (limited to '_test')
-rw-r--r--_test/tests/inc/PageUtilsIsHiddenPage.test.php95
-rw-r--r--_test/tests/inc/parserutils_set_metadata_during_rendering.test.php3
2 files changed, 97 insertions, 1 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/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));