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