summaryrefslogtreecommitdiff
path: root/_test
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2012-07-01 11:41:22 +0200
committerAndreas Gohr <andi@splitbrain.org>2012-07-01 14:35:51 +0200
commite66d3e6dfa7ba6f0cf55b58f0b00b66b52c98321 (patch)
tree9904e4a6e8c6d7c9017626e5195e3291388101b3 /_test
parent65ee48a57f42826189844ad1039c37a8a675dbab (diff)
downloadrpg-e66d3e6dfa7ba6f0cf55b58f0b00b66b52c98321.tar.gz
rpg-e66d3e6dfa7ba6f0cf55b58f0b00b66b52c98321.tar.bz2
Improved sidebar inclusion
Template authors now can use tpl_sidebar() to include the sidebar. Sidebars can be defined in subnamespaces as well
Diffstat (limited to '_test')
-rw-r--r--_test/tests/inc/pageutils_findnearest.test.php40
-rw-r--r--_test/tests/inc/template_sidebar.test.php40
2 files changed, 80 insertions, 0 deletions
diff --git a/_test/tests/inc/pageutils_findnearest.test.php b/_test/tests/inc/pageutils_findnearest.test.php
new file mode 100644
index 000000000..e129b5e58
--- /dev/null
+++ b/_test/tests/inc/pageutils_findnearest.test.php
@@ -0,0 +1,40 @@
+<?php
+
+class pageutils_findnearest_test extends DokuWikiTest {
+ function testNoSidebar() {
+ global $ID;
+
+ $ID = 'foo:bar:baz:test';
+ $sidebar = page_findnearest('sidebar');
+ $this->assertEquals(false, $sidebar);
+ }
+
+ function testExistingSidebars() {
+ global $ID;
+
+ saveWikiText('sidebar', 'topsidebar-test', '');
+
+ $ID = 'foo:bar:baz:test';
+ $sidebar = page_findnearest('sidebar');
+ $this->assertEquals('sidebar', $sidebar);
+
+ $ID = 'foo';
+ $sidebar = page_findnearest('sidebar');
+ $this->assertEquals('sidebar', $sidebar);
+
+ saveWikiText('foo:bar:sidebar', 'bottomsidebar-test', '');
+
+ $ID = 'foo:bar:baz:test';
+ $sidebar = page_findnearest('sidebar');
+ $this->assertEquals('foo:bar:sidebar', $sidebar);
+
+ $ID = 'foo:bar:test';
+ $sidebar = page_findnearest('sidebar');
+ $this->assertEquals('foo:bar:sidebar', $sidebar);
+
+ $ID = 'foo';
+ $sidebar = page_findnearest('sidebar');
+ $this->assertEquals('sidebar', $sidebar);
+ }
+
+}
diff --git a/_test/tests/inc/template_sidebar.test.php b/_test/tests/inc/template_sidebar.test.php
new file mode 100644
index 000000000..56153894a
--- /dev/null
+++ b/_test/tests/inc/template_sidebar.test.php
@@ -0,0 +1,40 @@
+<?php
+
+class template_sidebar_test extends DokuWikiTest {
+ function testNoSidebar() {
+ global $ID;
+
+ $ID = 'foo:bar:baz:test';
+ $sidebar = tpl_sidebar(false);
+ $this->assertEquals('',$sidebar);
+ }
+
+ function testExistingSidebars() {
+ global $ID;
+
+ saveWikiText('sidebar', 'topsidebar-test', '');
+
+ $ID = 'foo:bar:baz:test';
+ $sidebar = tpl_sidebar(false);
+ $this->assertTrue(strpos($sidebar, 'topsidebar-test') > 0);
+
+ $ID = 'foo';
+ $sidebar = tpl_sidebar(false);
+ $this->assertTrue(strpos($sidebar, 'topsidebar-test') > 0);
+
+ saveWikiText('foo:bar:sidebar', 'bottomsidebar-test', '');
+
+ $ID = 'foo:bar:baz:test';
+ $sidebar = tpl_sidebar(false);
+ $this->assertTrue(strpos($sidebar, 'bottomsidebar-test') > 0);
+
+ $ID = 'foo:bar:test';
+ $sidebar = tpl_sidebar(false);
+ $this->assertTrue(strpos($sidebar, 'bottomsidebar-test') > 0);
+
+ $ID = 'foo';
+ $sidebar = tpl_sidebar(false);
+ $this->assertTrue(strpos($sidebar, 'topsidebar-test') > 0);
+ }
+
+}