summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/Translate/tests/phpunit/ffs/DtdFFSTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/Translate/tests/phpunit/ffs/DtdFFSTest.php')
-rw-r--r--www/wiki/extensions/Translate/tests/phpunit/ffs/DtdFFSTest.php54
1 files changed, 54 insertions, 0 deletions
diff --git a/www/wiki/extensions/Translate/tests/phpunit/ffs/DtdFFSTest.php b/www/wiki/extensions/Translate/tests/phpunit/ffs/DtdFFSTest.php
new file mode 100644
index 00000000..9e76454d
--- /dev/null
+++ b/www/wiki/extensions/Translate/tests/phpunit/ffs/DtdFFSTest.php
@@ -0,0 +1,54 @@
+<?php
+/**
+ * The DtdFFS class is responsible for loading messages from .dtd
+ * files.
+ * These tests check that the message keys are loaded and saved correctly.
+ * @author Niklas Laxström
+ * @author Amir E. Aharoni
+ * @file
+ * @license GPL-2.0-or-later
+ */
+
+class DtdFFSTest extends MediaWikiTestCase {
+
+ protected $groupConfiguration = [
+ 'BASIC' => [
+ 'class' => 'FileBasedMessageGroup',
+ 'id' => 'test-id',
+ 'label' => 'Test Label',
+ 'namespace' => 'NS_MEDIAWIKI',
+ 'description' => 'Test description',
+ ],
+ 'FILES' => [
+ 'class' => 'DtdFFS',
+ ],
+ ];
+
+ public function testParsing() {
+ $file =
+ <<<DTD
+ <!--
+# Messages for Interlingua (interlingua)
+# Exported from translatewiki.net
+
+# Author: McDutchie
+-->
+<!ENTITY okawix.title "Okawix &okawix.vernum; - Navigator de Wikipedia">
+<!ENTITY okawix.back
+"Retro">
+DTD;
+
+ /**
+ * @var FileBasedMessageGroup $group
+ */
+ $group = MessageGroupBase::factory( $this->groupConfiguration );
+ $ffs = new DtdFFS( $group );
+ $parsed = $ffs->readFromVariable( $file );
+ $expected = [
+ 'okawix.title' => 'Okawix &okawix.vernum; - Navigator de Wikipedia',
+ 'okawix.back' => 'Retro',
+ ];
+ $expected = [ 'MESSAGES' => $expected, 'AUTHORS' => [ 'McDutchie' ] ];
+ $this->assertEquals( $expected, $parsed );
+ }
+}