1<?php
2
3if (!defined('DOKU_INC')) die();
4
5/**
6 * Test the conversion of media references in link titles
7 *
8 * @group plugin_include
9 * @group plugins
10 */
11class plugin_include_media_linktitle_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('wiki:included', <<<EOF
23  * [[test|{{dokuwiki.png}}]]
24  * [[#test|{{dokuwiki.png?w=200}}]]
25  * [[doku>test|{{dokuwiki.png?w=300}}]]
26  * [[test|{{https://www.dokuwiki.org/lib/tpl/dokuwiki/images/logo.png}}]]
27EOF
28            , 'Test setup');
29        idx_addPage('wiki:included');
30
31        saveWikiText('test:include', '{{page>..:wiki:included}}', 'Test setup');
32        idx_addPage('test:include');
33    }
34
35    public function testInternalLinkTitleConversion() {
36        $html = p_wiki_xhtml('test:include');
37        $this->assertStringContainsString('src="'.ml('wiki:dokuwiki.png').'"', $html);
38    }
39
40    public function testLocalLinkTitleConversion() {
41        $html = p_wiki_xhtml('test:include');
42        $this->assertStringContainsString('src="'.ml('wiki:dokuwiki.png', array('w' => '200')).'"', $html);
43    }
44
45    public function testInterWikiLinkTitleConversion() {
46        $html = p_wiki_xhtml('test:include');
47        $this->assertStringContainsString('src="'.ml('wiki:dokuwiki.png', array('w' => '300')).'"', $html);
48    }
49
50    public function testExternalMediaNotConverted() {
51        $html = p_wiki_xhtml('test:include');
52        $this->assertStringContainsString('src="'.ml('https://www.dokuwiki.org/lib/tpl/dokuwiki/images/logo.png').'"', $html);
53    }
54}
55