summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/Translate/tests/phpunit/ffs/AndroidXmlFFSTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/Translate/tests/phpunit/ffs/AndroidXmlFFSTest.php')
-rw-r--r--www/wiki/extensions/Translate/tests/phpunit/ffs/AndroidXmlFFSTest.php67
1 files changed, 46 insertions, 21 deletions
diff --git a/www/wiki/extensions/Translate/tests/phpunit/ffs/AndroidXmlFFSTest.php b/www/wiki/extensions/Translate/tests/phpunit/ffs/AndroidXmlFFSTest.php
index 6a526485..62b8ca41 100644
--- a/www/wiki/extensions/Translate/tests/phpunit/ffs/AndroidXmlFFSTest.php
+++ b/www/wiki/extensions/Translate/tests/phpunit/ffs/AndroidXmlFFSTest.php
@@ -1,32 +1,33 @@
<?php
/**
- * Tests for AndroidXmlFFS
- *
* @file
* @author Niklas Laxström
- * @license GPL-2.0+
+ * @license GPL-2.0-or-later
*/
class AndroidXmlFFSTest extends MediaWikiTestCase {
- protected $groupConfiguration = array(
- 'BASIC' => array(
+ protected $groupConfiguration = [
+ 'BASIC' => [
'class' => 'FileBasedMessageGroup',
'id' => 'test-id',
'label' => 'Test Label',
'namespace' => 'NS_MEDIAWIKI',
'description' => 'Test description',
- ),
- 'FILES' => array(
+ ],
+ 'FILES' => [
'class' => 'AndroidXmlFFS',
'sourcePattern' => '',
- ),
- );
+ ],
+ ];
public function testParsing() {
$file =
<<<XML
<?xml version="1.0" encoding="utf-8"?>
+<!-- Authors:
+* Imaginary translator
+-->
<resources>
<string name="wpt_voicerec">Voice recording</string>
<string name="wpt_stillimage" fuzzy="true">Picture</string>
@@ -36,6 +37,8 @@ class AndroidXmlFFSTest extends MediaWikiTestCase {
</plurals>
<string name="has_quotes">Go to \"Wikipedia\"</string>
<string name="starts_with_at">\@Wikipedia</string>
+ <string name="has_ampersand">1&amp;nbsp;000</string>
+ <string name="has_newline">first\nsecond</string>
</resources>
XML;
@@ -45,14 +48,21 @@ XML;
$group = MessageGroupBase::factory( $this->groupConfiguration );
$ffs = new AndroidXmlFFS( $group );
$parsed = $ffs->readFromVariable( $file );
- $expected = array(
- 'wpt_voicerec' => 'Voice recording',
- 'wpt_stillimage' => '!!FUZZY!!Picture',
- 'alot' => '{{PLURAL|one=bunny|other=bunnies}}',
- 'has_quotes' => 'Go to "Wikipedia"',
- 'starts_with_at' => '@Wikipedia',
- );
- $expected = array( 'MESSAGES' => $expected, 'AUTHORS' => array() );
+ $expected = [
+ 'MESSAGES' => [
+ 'wpt_voicerec' => 'Voice recording',
+ 'wpt_stillimage' => '!!FUZZY!!Picture',
+ 'alot' => '{{PLURAL|one=bunny|bunnies}}',
+ 'has_quotes' => 'Go to "Wikipedia"',
+ 'starts_with_at' => '@Wikipedia',
+ 'has_ampersand' => '1&nbsp;000',
+ 'has_newline' => "first\nsecond",
+ ],
+ 'AUTHORS' => [
+ 'Imaginary translator',
+ ]
+ ];
+
$this->assertEquals( $expected, $parsed );
}
@@ -63,16 +73,28 @@ XML;
$group = MessageGroupBase::factory( $this->groupConfiguration );
$ffs = new AndroidXmlFFS( $group );
- $messages = array(
+ $messages = [
'ko=26ra' => 'wawe',
'foobar' => '!!FUZZY!!Kissa kala <koira> "a\'b',
- 'amuch' => '{{PLURAL|one=bunny|other=bunnies}}',
- );
+ 'amuch' => '{{PLURAL|one=bunny|bunnies}}',
+ 'ampersand' => '&nbsp; &foo',
+ 'newlines' => "first\nsecond",
+ ];
+ $authors = [
+ '1 Hyphen-Fan',
+ '2 Hyphen--Lover',
+ '3 Hyphen---Fanatic-',
+ ];
+
$collection = new MockMessageCollection( $messages );
+ $collection->addCollectionAuthors( $authors, 'set' );
$xml = $ffs->writeIntoVariable( $collection );
$parsed = $ffs->readFromVariable( $xml );
- $expected = array( 'MESSAGES' => $messages, 'AUTHORS' => array() );
+ $expected = [
+ 'MESSAGES' => $messages,
+ 'AUTHORS' => $authors,
+ ];
$this->assertEquals( $expected, $parsed );
}
}
@@ -92,4 +114,7 @@ class MockMessageCollection extends MessageCollection {
public function filter( $type, $condition = true, $value = null ) {
}
+
+ public function loadTranslations() {
+ }
}