1*2e43b799SAndreas Gohr<?php 2*2e43b799SAndreas Gohr 3*2e43b799SAndreas Gohrnamespace dokuwiki\test\Parsing; 4*2e43b799SAndreas Gohr 5*2e43b799SAndreas Gohr/** 6*2e43b799SAndreas Gohr * Locale files are core assets authored in DokuWiki syntax. They must render 7*2e43b799SAndreas Gohr * as 'dw' even when the wiki is configured for Markdown — otherwise bracket 8*2e43b799SAndreas Gohr * and apostrophe pairs would survive into the output as literal text. 9*2e43b799SAndreas Gohr */ 10*2e43b799SAndreas Gohrclass LocaleXhtmlTest extends \DokuWikiTest 11*2e43b799SAndreas Gohr{ 12*2e43b799SAndreas Gohr /** Stage a locale file under the (temporary) DOKU_CONF lang dir. */ 13*2e43b799SAndreas Gohr private function stageLocale(string $id, string $content): void 14*2e43b799SAndreas Gohr { 15*2e43b799SAndreas Gohr global $conf; 16*2e43b799SAndreas Gohr $dir = DOKU_CONF . 'lang/' . $conf['lang']; 17*2e43b799SAndreas Gohr io_makeFileDir($dir . '/' . $id . '.txt'); 18*2e43b799SAndreas Gohr io_saveFile($dir . '/' . $id . '.txt', $content); 19*2e43b799SAndreas Gohr } 20*2e43b799SAndreas Gohr 21*2e43b799SAndreas Gohr public function testLocaleRendersAsDwUnderMarkdownConfig() 22*2e43b799SAndreas Gohr { 23*2e43b799SAndreas Gohr global $conf; 24*2e43b799SAndreas Gohr $conf['syntax'] = 'md'; 25*2e43b799SAndreas Gohr 26*2e43b799SAndreas Gohr $this->stageLocale('synctest', "A [[wiki:syntax]] link."); 27*2e43b799SAndreas Gohr 28*2e43b799SAndreas Gohr $html = p_locale_xhtml('synctest'); 29*2e43b799SAndreas Gohr 30*2e43b799SAndreas Gohr // Rendered as DW: the bracket pair becomes a real link, not literal text 31*2e43b799SAndreas Gohr $this->assertStringContainsString('<a ', $html, 'locale link must render as a link under md config'); 32*2e43b799SAndreas Gohr $this->assertStringNotContainsString('[[wiki:syntax]]', $html, 'bracket pair must not survive as literal text'); 33*2e43b799SAndreas Gohr } 34*2e43b799SAndreas Gohr} 35