summaryrefslogtreecommitdiff
path: root/platform/www/lib/plugins/include/_test/locallink_conversion.test.php
blob: e4c95a371711ffc5403bea35f28d32af04f991ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php

if (!defined('DOKU_INC')) die();

/**
 * Test the conversion of local links to internal links if the page hasn't been fully included
 *
 * @group plugin_include
 * @group plugins
 */
class plugin_include_locallink_conversion_test extends DokuWikiTest {
    /** @var helper_plugin_include $helper */
    private $helper;

    public function setUp() : void
    {
        $this->pluginsEnabled[] = 'include';
        parent::setUp();

        $this->helper = plugin_load('helper', 'include');

        saveWikiText('included', 'Example content with link [[#jump]]', 'Test setup');
        idx_addPage('test:included');

        saveWikiText('test:includefull', '{{page>..:included}}', 'Test setup');
        idx_addPage('test:includefull');

        saveWikiText('test:includefirst', '{{page>..:included&firstseconly}}', 'Test setup');
        idx_addPage('test:includefirst');
    }

    public function testLocalConverted() {
        $html = p_wiki_xhtml('test:includefirst');
        $this->assertContains('href="'.wl('included').'#jump"', $html);
        $this->assertNotContains('href="#jump"', $html);
    }

    public function testLocalExistsIfIncluded() {
        $html = p_wiki_xhtml('test:includefull');
        $this->assertContains('href="#jump"', $html);
    }
}