summaryrefslogtreecommitdiff
path: root/platform/www/lib/plugins/tag/_test/topic_sort.test.php
diff options
context:
space:
mode:
Diffstat (limited to 'platform/www/lib/plugins/tag/_test/topic_sort.test.php')
-rw-r--r--platform/www/lib/plugins/tag/_test/topic_sort.test.php59
1 files changed, 59 insertions, 0 deletions
diff --git a/platform/www/lib/plugins/tag/_test/topic_sort.test.php b/platform/www/lib/plugins/tag/_test/topic_sort.test.php
new file mode 100644
index 0000000..aca59f4
--- /dev/null
+++ b/platform/www/lib/plugins/tag/_test/topic_sort.test.php
@@ -0,0 +1,59 @@
+<?php
+
+if (!defined('DOKU_INC')) die();
+
+/**
+ * Tests the tagRefine function of the tag plugin
+ */
+class plugin_tag_topic_sorting_test extends DokuWikiTest {
+ private $pages = array(
+ 'a',
+ 'aa',
+ 'a:a',
+ 'a:aa',
+ 'a:a:c',
+ 'a:a:b:a',
+ 'a:b:c'
+ );
+ /** @var helper_plugin_tag $helper */
+ private $helper;
+
+ public function setUp() {
+ global $conf;
+ $this->pluginsEnabled[] = 'tag';
+ parent::setUp();
+
+ $conf['plugin']['tag']['sortkey'] = 'ns';
+
+ $this->helper = plugin_load('helper', 'tag');
+
+
+ foreach ($this->pages as $page) {
+ saveWikiText(
+ $page,
+ '{{tag>mytag}}', 'Test'
+ );
+ idx_addPage($page);
+ }
+ }
+
+ public function test_ns_sort() {
+ $this->assertEquals($this->pages, $this->extract_ids($this->helper->getTopic('', null, 'mytag')));
+ }
+
+
+ /**
+ * Extract the id attribute of the supplied pages
+ *
+ * @param array $pages The pages that shall be used
+ * @return array The ids of the pages
+ */
+ private function extract_ids($pages) {
+ $result = array();
+ foreach ($pages as $page) {
+ $result[] = $page['id'];
+ }
+ return $result;
+ }
+
+}