1<?php
2
3if (!defined('DOKU_INC')) die();
4
5/**
6 * Test the conversion of local links to internal links if the page hasn't been fully included
7 *
8 * @group plugin_include
9 * @group plugins
10 */
11class plugin_include_locallink_conversion_test extends DokuWikiTest {
12    /** @var helper_plugin_include $helper */
13    private $helper;
14
15    public function setUp() : void
16    {
17        $this->pluginsEnabled[] = 'include';
18        parent::setUp();
19
20        $this->helper = plugin_load('helper', 'include');
21
22        saveWikiText('included', 'Example content with link [[#jump]]', 'Test setup');
23        idx_addPage('test:included');
24
25        saveWikiText('test:includefull', '{{page>..:included}}', 'Test setup');
26        idx_addPage('test:includefull');
27
28        saveWikiText('test:includefirst', '{{page>..:included&firstseconly}}', 'Test setup');
29        idx_addPage('test:includefirst');
30    }
31
32    public function testLocalConverted() {
33        $html = p_wiki_xhtml('test:includefirst');
34        $this->assertContains('href="'.wl('included').'#jump"', $html);
35        $this->assertNotContains('href="#jump"', $html);
36    }
37
38    public function testLocalExistsIfIncluded() {
39        $html = p_wiki_xhtml('test:includefull');
40        $this->assertContains('href="#jump"', $html);
41    }
42}
43