1<?php
2
3/**
4 * Tests the basic functionality of the tag and topic syntax
5 */
6class topic_tag_test extends DokuWikiTest {
7    function setup() : void {
8        $this->pluginsEnabled[] = 'tag';
9        $this->pluginsEnabled[] = 'pagelist';
10        parent::setup();
11    }
12
13    function test_topic_tag() {
14        saveWikiText(
15            'tagged_page',
16            '{{tag>mytag test2tag}}', 'Test'
17        );
18        saveWikiText(
19            'topic_page',
20            '{{topic>mytag}}'.DOKU_LF.DOKU_LF.'{{tag>topictag mytag}}'.DOKU_LF, 'Test'
21        );
22        idx_addPage('topic_page');
23        idx_addPage('tagged_page');
24        $this->assertContains('tag:topictag', p_wiki_xhtml('topic_page'), 'Page with tag syntax doesn\'t contain tag output');
25        $this->assertNotContains('tag:test2tag', p_wiki_xhtml('topic_page'), 'Page with tag and topic syntax tag which is listed in a page that is listed in the topic syntax but not on the page itself');
26        $this->assertContains('topic_page', p_wiki_xhtml('topic_page'), 'Page with topic and tag syntax doesn\'t list itself in the topic syntax');
27        $this->assertContains('tagged_page', p_wiki_xhtml('topic_page'), 'Page with topic syntax doesn\'t list matching page');
28        $this->assertContains('tag:mytag', p_wiki_xhtml('tagged_page'), 'Page with tag syntax doesn\'t contain tag output');
29        $this->assertContains('tag:test2tag', p_wiki_xhtml('tagged_page'), 'Page with tag syntax doesn\'t contain tag output');
30        $this->assertNotContains('tag:topictag', p_wiki_xhtml('tagged_page'), 'Page with tag syntax contains tag from a page in which it is listed in the topic syntax');
31        saveWikiText('tagged_page', '{{tag>test2tag}}', 'Deleted mytag');
32        $this->assertNotContains('tagged_page', p_wiki_xhtml('topic_page'), 'Page that no longer contains the tag is still listed in the topic syntax (caching problems?)');
33        $this->assertNotContains('tag:mytag', p_wiki_xhtml('tagged_page'), 'Removed tag is still listed in XHTML output');
34
35    }
36}
37