RubyYamlFFSTest.php

Go to the documentation of this file.
00001 <?php
00002 
00003 class RubyYamlFFSTest extends MediaWikiTestCase {
00007     protected $group;
00008 
00009     protected $groupConfiguration = array(
00010         'BASIC' => array(
00011             'class' => 'FileBasedMessageGroup',
00012             'id' => 'test-id',
00013             'label' => 'Test Label',
00014             'namespace' => 'NS_MEDIAWIKI',
00015             'description' => 'Test description',
00016         ),
00017         'FILES' => array(
00018             'class' => 'RubyYamlFFS',
00019         ),
00020     );
00021 
00022     protected function setUp() {
00023         parent::setUp();
00024         $group = MessageGroupBase::factory( $this->groupConfiguration );
00026         $this->ffs = $group->getFFS();
00027     }
00028 
00029     public function testFlattenPluralWithNoPlurals() {
00030         $input = array(
00031             'much' => 'a lot',
00032             'less' => 'not so much',
00033         );
00034         $output = false;
00035         $this->assertEquals( $output, $this->ffs->flattenPlural( $input ) );
00036     }
00037 
00038     public function testFlattenPluralWithPlurals() {
00039         $input = array(
00040             'one' => 'just a tiny bit',
00041             'two' => 'not so much',
00042             'other' => 'maybe a lot',
00043         );
00044         $output = '{{PLURAL|one=just a tiny bit|two=not so much|maybe a lot}}';
00045         $this->assertEquals( $output, $this->ffs->flattenPlural( $input ) );
00046     }
00047 
00048     public function testFlattenPluralWithArrays() {
00049         $input = array(
00050             'one' => array(
00051                 'multi' => 'he lives in a multistorey house',
00052                 'row' => 'he lives in a row house',
00053             ),
00054             'other' => array(
00055                 'multi' => 'he lives in mountain cave',
00056                 'row' => 'he lives in a cave near the river',
00057             ),
00058         );
00059         $output = false;
00060         $this->assertEquals( $output, $this->ffs->flattenPlural( $input ) );
00061     }
00062 
00069     public function testFlattenPluralsWithMixedKeywords( $input, $comment ) {
00070         $this->ffs->flattenPlural( $input );
00071     }
00072 
00073     public function flattenPluralsWithMixedKeywordsProvider() {
00074         return array(
00075             array(
00076                 array(
00077                     'carrot' => 'I like carrots',
00078                     'other' => 'I like milk',
00079                 ),
00080                 'reserved keyword at the end',
00081             ),
00082             array(
00083                 array(
00084                     'one' => 'I am the one leader',
00085                     'club' => 'I am the club leader',
00086                 ),
00087                 'reserved keyword at the beginning',
00088             )
00089         );
00090     }
00091 
00095     public function testUnflattenPural( $key, $value, $result ) {
00096         $this->assertEquals(
00097             $result,
00098             $this->ffs->unflattenPlural( $key, $value )
00099         );
00100     }
00101 
00102     public function unflattenDataProvider() {
00103         return array(
00104             array( 'key', '{{PLURAL}}', false ),
00105             array( 'key', 'value', array( 'key' => 'value' ) ),
00106             array( 'key', '{{PLURAL|one=cat|other=cats}}',
00107                 array( 'key.one' => 'cat', 'key.other' => 'cats' )
00108             ),
00109             array( 'key', '{{PLURAL|one=шляху %{related_ways}|шляхоў %{related_ways}}}',
00110                 array(
00111                     'key.one' => 'шляху %{related_ways}',
00112                     'key.other' => 'шляхоў %{related_ways}'
00113                 )
00114             ),
00115             array( 'key', '{{PLURAL|foo=cat}}',
00116                 array( 'key.other' => 'foo=cat' )
00117             ),
00118             array( 'key', '{{PLURAL|zero=0|one=1|two=2|few=3|many=160|other=898}}',
00119                 array( 'key.zero' => '0', 'key.one' => '1', 'key.two' => '2',
00120                     'key.few' => '3', 'key.many' => '160', 'key.other' => '898' )
00121             ),
00122         );
00123     }
00124 }
Generated on Tue Oct 29 00:00:24 2013 for MediaWiki Translate Extension by  doxygen 1.6.3