diff options
author | Yaco <franco@reevo.org> | 2022-03-12 03:48:42 +0000 |
---|---|---|
committer | Yaco <franco@reevo.org> | 2022-03-12 03:48:42 +0000 |
commit | 5a2b689265654f704d06eb2ea9ee1b21078edcfc (patch) | |
tree | b52e9ce5c8236d2ecf660950238c2dd3d42ad5d2 /platform/www/lib/plugins/bureaucracy/_test/actions_template.test.php | |
parent | 46377a425154286e3072880d55667a18b4518df1 (diff) |
add plugins: wrap, bureaucracy, phpwikify
Diffstat (limited to 'platform/www/lib/plugins/bureaucracy/_test/actions_template.test.php')
-rw-r--r-- | platform/www/lib/plugins/bureaucracy/_test/actions_template.test.php | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/platform/www/lib/plugins/bureaucracy/_test/actions_template.test.php b/platform/www/lib/plugins/bureaucracy/_test/actions_template.test.php new file mode 100644 index 0000000..befefc3 --- /dev/null +++ b/platform/www/lib/plugins/bureaucracy/_test/actions_template.test.php @@ -0,0 +1,88 @@ +<?php +/** + * @group plugin_bureaucracy + * @group plugins + */ +class syntax_plugin_bureaucracy_action_template_test extends DokuWikiTest { + + protected $pluginsEnabled = array('bureaucracy'); + + public function testPrepareLanguagePlaceholderNoTranslate() { + $action = $this->getTemplateClass(); + $action->prepareLanguagePlaceholder(); + + $this->assertEquals('en', $action->values['__lang__']); + $this->assertEquals('/@LANG@/', $action->patterns['__lang__']); + $this->assertEquals('', $action->values['__trans__']); + $this->assertEquals('/@TRANS@/', $action->patterns['__trans__']); + } + + public function testPrepareLanguagePlaceholderTranslateDefaultNS() { + global $conf; + global $ID; + + $conf['plugin']['translation']['translations'] = 'de'; + $ID = 'bla'; + + plugin_enable('translation'); + if (null === plugin_load('helper', 'translation')) return; + + $action = $this->getTemplateClass(); + $action->prepareLanguagePlaceholder(); + + $this->assertEquals('en', $action->values['__lang__']); + $this->assertEquals('/@LANG@/', $action->patterns['__lang__']); + $this->assertEquals('', $action->values['__trans__']); + $this->assertEquals('/@TRANS@/', $action->patterns['__trans__']); + } + + public function testPrepareLanguagePlaceholderTranslateLanguageNS() { + global $conf; + global $ID; + + $conf['plugin']['translation']['translations'] = 'de'; + $ID = 'de:bla'; + + plugin_enable('translation'); + $translation = plugin_load('helper', 'translation'); + if (null === $translation) return; + + $action = $this->getTemplateClass(); + $action->prepareLanguagePlaceholder(); + + $this->assertEquals('en', $action->values['__lang__']); + $this->assertEquals('/@LANG@/', $action->patterns['__lang__']); + $this->assertEquals('de', $action->values['__trans__']); + $this->assertEquals('/@TRANS@/', $action->patterns['__trans__']); + } + + public function testProcessFields() { + $data = array(); + /** @var helper_plugin_bureaucracy_fieldstatic $staticfield */ + $staticfield = plugin_load('helper', 'bureaucracy_fieldstatic'); + $staticfield->initialize(array('text', 'text1')); + $data[] = $staticfield; + + $action = $this->getTemplateClass(); + $action->prepareFieldReplacements($data, '_', ''); + + $this->assertEquals('/(@@|##)text1(?:\|(.*?))\1/si', $action->patterns['text1']); + $this->assertEquals('$2', $action->values['text1']); + $this->assertEmpty($action->targetpages); + } + + /** + * @return helper_plugin_bureaucracy_actiontemplate + */ + private function getTemplateClass() { + /** @var helper_plugin_bureaucracy_actiontemplate $templateaction */ + $templateaction = plugin_load('helper', 'bureaucracy_actiontemplate'); + $templateaction->patterns = array(); + $templateaction->values = array(); + $templateaction->targetpages = array(); + $templateaction->pagename = array(); + return $templateaction; + } + + +} |