phpunit testcases on the plural rules for am, ar, be, be_tarask, bh, bs and hi languages
authorSanthosh Thottingal <santhosh@users.mediawiki.org>
Fri, 27 Jan 2012 06:01:43 +0000 (06:01 +0000)
committerSanthosh Thottingal <santhosh@users.mediawiki.org>
Fri, 27 Jan 2012 06:01:43 +0000 (06:01 +0000)
tests/phpunit/languages/LanguageAmTest.php [new file with mode: 0644]
tests/phpunit/languages/LanguageArTest.php
tests/phpunit/languages/LanguageBeTest.php [new file with mode: 0644]
tests/phpunit/languages/LanguageBe_taraskTest.php
tests/phpunit/languages/LanguageBhTest.php [new file with mode: 0644]
tests/phpunit/languages/LanguageBsTest.php [new file with mode: 0644]
tests/phpunit/languages/LanguageHiTest.php [new file with mode: 0644]

diff --git a/tests/phpunit/languages/LanguageAmTest.php b/tests/phpunit/languages/LanguageAmTest.php
new file mode 100644 (file)
index 0000000..3a648de
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+/**
+ * @author Santhosh Thottingal
+ * @copyright Copyright © 2012, Santhosh Thottingal
+ * @file
+ */
+
+/** Tests for MediaWiki languages/LanguageAm.php */
+class LanguageAmTest extends MediaWikiTestCase {
+       private $lang;
+
+       function setUp() {
+               $this->lang = Language::factory( 'Am' );
+       }
+       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 ),
+               );
+       }
+}
index 81488ad..b23e053 100644 (file)
@@ -52,4 +52,27 @@ class LanguageArTest extends MediaWikiTestCase {
                        ),
                );
        }
+       /** @dataProvider providePlural */
+       function testPlural( $result, $value ) {
+               $forms =  array( 'zero', 'one', 'two', 'few', 'many', 'other' );
+               $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
+       }
+       function providePlural() {
+               return array (
+                       array( 'zero', 0 ),
+                       array( 'one', 1 ),
+                       array( 'two', 2 ),
+                       array( 'few', 3 ),
+                       array( 'few', 9 ),
+                       array( 'few', 110 ),
+                       array( 'many', 11 ),
+                       array( 'many', 15 ),
+                       array( 'many', 99 ),
+                       array( 'many', 9999 ),
+                       array( 'other', 100 ),
+                       array( 'other', 102 ),
+                       array( 'other', 1000 ),
+                       array( 'other', 1.7 ),
+               );
+       }
 }
diff --git a/tests/phpunit/languages/LanguageBeTest.php b/tests/phpunit/languages/LanguageBeTest.php
new file mode 100644 (file)
index 0000000..735ccc6
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+/**
+ * @author Santhosh Thottingal
+ * @copyright Copyright © 2012, Santhosh Thottingal
+ * @file
+ */
+
+/** Tests for MediaWiki languages/LanguageBe.php */
+class LanguageBeTest extends MediaWikiTestCase {
+       private $lang;
+
+       function setUp() {
+               $this->lang = Language::factory( 'Be' );
+       }
+       function tearDown() {
+               unset( $this->lang );
+       }
+
+       /** @dataProvider providePlural */
+       function testPlural( $result, $value ) {
+               $forms =  array( 'one', 'few', 'many', 'other' );
+               $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
+       }
+
+       function providePlural() {
+               return array (
+                       array( 'one', 1 ),
+                       array( 'many', 11 ),
+                       array( 'one', 91 ),
+                       array( 'one', 121 ),
+                       array( 'few', 2 ),
+                       array( 'few', 3 ),
+                       array( 'few', 4 ),
+                       array( 'few', 334 ),
+                       array( 'many', 5 ),
+                       array( 'many', 15 ),
+                       array( 'many', 120 ),
+               );
+       }
+}
index e7fdb7c..765cdb8 100644 (file)
@@ -27,4 +27,39 @@ class LanguageBeTaraskTest extends MediaWikiTestCase {
        function testDoesNotCommafyFourDigitsNumber() {
                $this->assertEquals(      '1234', $this->lang->commafy(    '1234' ) );
        }
+       /** @dataProvider providePluralFourForms */
+       function testPluralFourForms( $result, $value ) {
+               $forms =  array( 'one', 'few', 'many', 'other' );
+               $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
+       }
+
+       function providePluralFourForms() {
+               return array (
+                       array( 'one', 1 ),
+                       array( 'many', 11 ),
+                       array( 'one', 91 ),
+                       array( 'one', 121 ),
+                       array( 'few', 2 ),
+                       array( 'few', 3 ),
+                       array( 'few', 4 ),
+                       array( 'few', 334 ),
+                       array( 'many', 5 ),
+                       array( 'many', 15 ),
+                       array( 'many', 120 ),
+               );
+       }
+       /** @dataProvider providePluralTwoForms */
+       function testPluralTwoForms( $result, $value ) {
+               $forms =  array( 'one', 'several' );
+               $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
+       }
+       function providePluralTwoForms() {
+               return array (
+                       array( 'one', 1 ),
+                       array( 'several', 11 ),
+                       array( 'several', 91 ),
+                       array( 'several', 121 ),
+               );
+       }
+
 }
diff --git a/tests/phpunit/languages/LanguageBhTest.php b/tests/phpunit/languages/LanguageBhTest.php
new file mode 100644 (file)
index 0000000..e1e2a13
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+/**
+ * @author Santhosh Thottingal
+ * @copyright Copyright © 2012, Santhosh Thottingal
+ * @file
+ */
+
+/** Tests for MediaWiki languages/LanguageBh.php */
+class LanguageBhTest extends MediaWikiTestCase {
+       private $lang;
+
+       function setUp() {
+               $this->lang = Language::factory( 'Bh' );
+       }
+       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 ),
+               );
+       }
+
+}
diff --git a/tests/phpunit/languages/LanguageBsTest.php b/tests/phpunit/languages/LanguageBsTest.php
new file mode 100644 (file)
index 0000000..b6631c0
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+/**
+ * @author Santhosh Thottingal
+ * @copyright Copyright © 2012, Santhosh Thottingal
+ * @file
+ */
+
+/** Tests for MediaWiki languages/LanguageBs.php */
+class LanguageBsTest extends MediaWikiTestCase {
+       private $lang;
+
+       function setUp() {
+               $this->lang = Language::factory( 'Bs' );
+       }
+       function tearDown() {
+               unset( $this->lang );
+       }
+
+       /** @dataProvider providePlural */
+       function testPlural( $result, $value ) {
+               $forms =  array( 'one', 'few', 'many', 'other' );
+               $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
+       }
+
+       function providePlural() {
+               return array (
+                       array( 'many', 0 ),
+                       array( 'one', 1 ),
+                       array( 'few', 2 ),
+                       array( 'few', 4 ),
+                       array( 'many', 5 ),
+                       array( 'many', 11 ),
+                       array( 'many', 20 ),
+                       array( 'one', 21 ),
+                       array( 'few', 24 ),
+                       array( 'many', 25 ),
+                       array( 'many', 200 ),
+               );
+       }
+
+}
diff --git a/tests/phpunit/languages/LanguageHiTest.php b/tests/phpunit/languages/LanguageHiTest.php
new file mode 100644 (file)
index 0000000..ead9e02
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+/**
+ * @author Santhosh Thottingal
+ * @copyright Copyright © 2012, Santhosh Thottingal
+ * @file
+ */
+
+/** Tests for MediaWiki languages/LanguageHi.php */
+class LanguageHiTest extends MediaWikiTestCase {
+       private $lang;
+
+       function setUp() {
+               $this->lang = Language::factory( 'Hi' );
+       }
+       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 ),
+               );
+       }
+
+}