1<?php 2 3namespace dokuwiki\test\Extension; 4 5use dokuwiki\Extension\PluginTrait; 6 7/** 8 * PluginTrait::render_text() defaults to rendering DokuWiki syntax, because 9 * its historical callers pass DW-syntax strings. Passing null instead honors 10 * the configured wiki syntax — for rendering user content. 11 */ 12class PluginRenderTextTest extends \DokuWikiTest 13{ 14 /** A bare object carrying the plugin trait, enough to call render_text(). */ 15 private function plugin(): object 16 { 17 return new class { 18 use PluginTrait; 19 }; 20 } 21 22 public function testDefaultRendersAsDwEvenUnderMarkdownConfig() 23 { 24 global $conf; 25 $conf['syntax'] = 'md'; 26 27 // default $syntax = 'dw' wins, so [[a]] becomes a real link 28 $html = $this->plugin()->render_text('[[a]]'); 29 $this->assertStringContainsString('<a ', $html); 30 $this->assertStringNotContainsString('[[a]]', $html); 31 } 32 33 public function testNullHonoursConfiguredSyntax() 34 { 35 global $conf; 36 $conf['syntax'] = 'md'; 37 38 // passing null honors the configured 'md' syntax, where DW internallink 39 // is not loaded, so [[a]] survives as literal text 40 $html = $this->plugin()->render_text('[[a]]', 'xhtml', null); 41 $this->assertStringContainsString('[[a]]', $html); 42 } 43} 44