phpunit testcases for lv, mg,and ml languages to test Plural
authorSanthosh Thottingal <santhosh@users.mediawiki.org>
Mon, 30 Jan 2012 11:40:28 +0000 (11:40 +0000)
committerSanthosh Thottingal <santhosh@users.mediawiki.org>
Mon, 30 Jan 2012 11:40:28 +0000 (11:40 +0000)
tests/phpunit/languages/LanguageLvTest.php [new file with mode: 0644]
tests/phpunit/languages/LanguageMgTest.php [new file with mode: 0644]
tests/phpunit/languages/LanguageMkTest.php [new file with mode: 0644]

diff --git a/tests/phpunit/languages/LanguageLvTest.php b/tests/phpunit/languages/LanguageLvTest.php
new file mode 100644 (file)
index 0000000..0636da5
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+/**
+ * @author Santhosh Thottingal
+ * @copyright Copyright © 2012, Santhosh Thottingal
+ * @file
+ */
+
+/** Tests for MediaWiki languages/classes/LanguageLv.php */
+class LanguageLvTest extends MediaWikiTestCase {
+       private $lang;
+
+       function setUp() {
+               $this->lang = Language::factory( 'lv' );
+       }
+       function tearDown() {
+               unset( $this->lang );
+       }
+
+       /** @dataProvider providerPlural */
+       function testPlural( $result, $value ) {
+               $forms =  array( 'one', 'other' );
+               $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
+       }
+
+       function providerPlural() {
+               return array (
+                       array( 'other', 0 ), #this must be zero form as per CLDR
+                       array( 'one', 1 ),
+                       array( 'other', 11 ),
+                       array( 'one', 21 ),
+                       array( 'other', 411 ),
+                       array( 'other', 12.345 ),
+                       array( 'other', 20 ),
+                       array( 'one', 31 ),
+                       array( 'other', 200 ),
+               );
+       }
+
+}
diff --git a/tests/phpunit/languages/LanguageMgTest.php b/tests/phpunit/languages/LanguageMgTest.php
new file mode 100644 (file)
index 0000000..06b5654
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+/**
+ * @author Santhosh Thottingal
+ * @copyright Copyright © 2012, Santhosh Thottingal
+ * @file
+ */
+
+/** Tests for MediaWiki languages/classes/LanguageMg.php */
+class LanguageMgTest extends MediaWikiTestCase {
+       private $lang;
+
+       function setUp() {
+               $this->lang = Language::factory( 'mg' );
+       }
+       function tearDown() {
+               unset( $this->lang );
+       }
+
+       /** @dataProvider providePlural */
+       function testPlural( $result, $value ) {
+               $forms =  array( 'one', 'other' );
+               $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
+       }
+
+       function providePlural() {
+               return array (
+                       array( 'one', 0 ),
+                       array( 'one', 1 ),
+                       array( 'other', 2 ),
+                       array( 'other', 200 ),
+                       array( 'other', 123.3434 ),
+               );
+       }
+
+}
diff --git a/tests/phpunit/languages/LanguageMkTest.php b/tests/phpunit/languages/LanguageMkTest.php
new file mode 100644 (file)
index 0000000..cf5ec3d
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+/**
+ * @author Santhosh Thottingal
+ * @copyright Copyright © 2012, Santhosh Thottingal
+ * @file
+ */
+
+/** Tests for MediaWiki languages/classes/LanguageMk.php */
+class LanguageMkTest extends MediaWikiTestCase {
+       private $lang;
+
+       function setUp() {
+               $this->lang = Language::factory( 'mk' );
+       }
+       function tearDown() {
+               unset( $this->lang );
+       }
+
+       /** @dataProvider providerPlural */
+       function testPlural( $result, $value ) {
+               $forms =  array( 'one', 'other' );
+               $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
+       }
+
+
+       function providerPlural() {
+               return array (
+                       array( 'other', 0 ),
+                       array( 'one', 1 ),
+                       array( 'other', 11 ),
+                       array( 'one', 21 ),
+                       array( 'other', 411 ),
+                       array( 'other', 12.345 ),
+                       array( 'other', 20 ),
+                       array( 'one', 31 ),
+                       array( 'other', 200 ),
+               );
+       }
+
+
+}