summaryrefslogtreecommitdiff
path: root/_test
diff options
context:
space:
mode:
authorDominik Eckelmann <eckelmann@cosmocode.de>2012-11-05 10:57:42 +0100
committerDominik Eckelmann <eckelmann@cosmocode.de>2012-11-05 10:57:42 +0100
commitfb55b51ef82bc3066173e7547500d9e79c410e34 (patch)
tree9b0b32a6cb91eb82ce757d53aaa846566b51db4d /_test
parent8449cc9d82848df24eb88a73dd81d7e048933287 (diff)
downloadrpg-fb55b51ef82bc3066173e7547500d9e79c410e34.tar.gz
rpg-fb55b51ef82bc3066173e7547500d9e79c410e34.tar.bz2
changed PAGEUTILS_ID_HIDEPAGE to has BEFORE/AFTER
Diffstat (limited to '_test')
-rw-r--r--_test/tests/inc/PageUtilsIsHiddenPage.test.php52
1 files changed, 49 insertions, 3 deletions
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;
}
}