diff options
author | Andreas Gohr <andi@splitbrain.org> | 2012-11-30 12:30:40 +0100 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2012-11-30 12:30:40 +0100 |
commit | d14415e37072dbe16077efd700aee5bd33707b54 (patch) | |
tree | 062c3c190039ac9490f56598b0ee116de18c2480 /_test/tests/inc/PageUtilsIsHiddenPage.test.php | |
parent | 2ed38036a53a489d2fcadc46ce601f8c876fca31 (diff) | |
parent | 38479cbba628ee76a92ff5f3c974cfa8e6ce9e61 (diff) | |
download | rpg-d14415e37072dbe16077efd700aee5bd33707b54.tar.gz rpg-d14415e37072dbe16077efd700aee5bd33707b54.tar.bz2 |
Merge branch 'master' into subscription
* master: (175 commits)
some coding style improvements
added .idea project folder to gitignore
use correct setUp method and parent calls.
Correct German plugin manager translation (download != install)
correct return in sendDigest()
Fix case-insensitive match in ACL checking
GeSHi update to 1.0.8.11
ignore empty header on mail sending
remove empty BCC/CC mail headers
Galician language update
some welcome page changes
Combine subsequent calls to strtr into a single transformation
changed semicolon to colon in link to welcome page to make it less confusing
fixed wrong sidebar showing in namespaces when sidebar is disabled
Typo fix for TL;DR
removed a bunch of outdated and irrelevant networking acronyms
added another place to look for logo to make it more consistent (FS#2656)
French language update
Czech language update
compat js findPosX/y more closely mimic historical function
...
Conflicts:
inc/auth.php
inc/common.php
inc/subscription.php
lib/exe/indexer.php
Diffstat (limited to '_test/tests/inc/PageUtilsIsHiddenPage.test.php')
-rw-r--r-- | _test/tests/inc/PageUtilsIsHiddenPage.test.php | 95 |
1 files changed, 95 insertions, 0 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 : |