media_linktitle_conversion.test.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. if (!defined('DOKU_INC')) die();
  3. /**
  4. * Test the conversion of media references in link titles
  5. *
  6. * @group plugin_include
  7. * @group plugins
  8. */
  9. class plugin_include_media_linktitle_conversion_test extends DokuWikiTest {
  10. /** @var helper_plugin_include $helper */
  11. private $helper;
  12. public function setUp() : void
  13. {
  14. $this->pluginsEnabled[] = 'include';
  15. parent::setUp();
  16. $this->helper = plugin_load('helper', 'include');
  17. saveWikiText('wiki:included', <<<EOF
  18. * [[test|{{dokuwiki.png}}]]
  19. * [[#test|{{dokuwiki.png?w=200}}]]
  20. * [[doku>test|{{dokuwiki.png?w=300}}]]
  21. * [[test|{{https://www.dokuwiki.org/lib/tpl/dokuwiki/images/logo.png}}]]
  22. EOF
  23. , 'Test setup');
  24. idx_addPage('wiki:included');
  25. saveWikiText('test:include', '{{page>..:wiki:included}}', 'Test setup');
  26. idx_addPage('test:include');
  27. }
  28. public function testInternalLinkTitleConversion() {
  29. $html = p_wiki_xhtml('test:include');
  30. $this->assertContains('src="'.ml('wiki:dokuwiki.png').'"', $html);
  31. }
  32. public function testLocalLinkTitleConversion() {
  33. $html = p_wiki_xhtml('test:include');
  34. $this->assertContains('src="'.ml('wiki:dokuwiki.png', array('w' => '200')).'"', $html);
  35. }
  36. public function testInterWikiLinkTitleConversion() {
  37. $html = p_wiki_xhtml('test:include');
  38. $this->assertContains('src="'.ml('wiki:dokuwiki.png', array('w' => '300')).'"', $html);
  39. }
  40. public function testExternalMediaNotConverted() {
  41. $html = p_wiki_xhtml('test:include');
  42. $this->assertContains('src="'.ml('https://www.dokuwiki.org/lib/tpl/dokuwiki/images/logo.png').'"', $html);
  43. }
  44. }