xref: /plugin/include/_test/locallink_conversion.test.php (revision 7026615f898023645af6886f50a1e72a14fef9f1)
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 */
8class plugin_include_locallink_conversion_test extends DokuWikiTest {
9    /** @var helper_plugin_include $helper */
10    private $helper;
11
12    public function setUp() {
13        $this->pluginsEnabled[] = 'include';
14        parent::setUp();
15
16        $this->helper = plugin_load('helper', 'include');
17
18        saveWikiText('included', 'Example content with link [[#jump]]', 'Test setup');
19        idx_addPage('test:included');
20
21        saveWikiText('test:includefull', '{{page>..:included}}', 'Test setup');
22        idx_addPage('test:includefull');
23
24        saveWikiText('test:includefirst', '{{page>..:included&firstseconly}}', 'Test setup');
25        idx_addPage('test:includefirst');
26    }
27
28    public function testLocalConverted() {
29        $html = p_wiki_xhtml('test:includefirst');
30        $this->assertContains('href="'.wl('included').'#jump"', $html);
31        $this->assertNotContains('href="#jump"', $html);
32    }
33
34    public function testLocalExistsIfIncluded() {
35        $html = p_wiki_xhtml('test:includefull');
36        $this->assertContains('href="#jump"', $html);
37    }
38}
39