r110112 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110111‎ | r110112 | r110113 >
Date:11:13, 27 January 2012
Author:santhosh
Status:ok (Comments)
Tags:
Comment:
Add PHPUnit tests for plural rules. For languages cs, cu, cy, dsb, fr, ga, gd, gv, hr, hsb, hy, ksh, ln
Modified paths:
  • /trunk/phase3/tests/phpunit/languages/LanguageCsTest.php (added) (history)
  • /trunk/phase3/tests/phpunit/languages/LanguageCuTest.php (added) (history)
  • /trunk/phase3/tests/phpunit/languages/LanguageCyTest.php (added) (history)
  • /trunk/phase3/tests/phpunit/languages/LanguageDsbTest.php (added) (history)
  • /trunk/phase3/tests/phpunit/languages/LanguageFrTest.php (added) (history)
  • /trunk/phase3/tests/phpunit/languages/LanguageGaTest.php (added) (history)
  • /trunk/phase3/tests/phpunit/languages/LanguageGdTest.php (added) (history)
  • /trunk/phase3/tests/phpunit/languages/LanguageGvTest.php (added) (history)
  • /trunk/phase3/tests/phpunit/languages/LanguageHrTest.php (added) (history)
  • /trunk/phase3/tests/phpunit/languages/LanguageHsbTest.php (added) (history)
  • /trunk/phase3/tests/phpunit/languages/LanguageHyTest.php (added) (history)
  • /trunk/phase3/tests/phpunit/languages/LanguageKshTest.php (added) (history)
  • /trunk/phase3/tests/phpunit/languages/LanguageLnTest.php (added) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/languages/LanguageKshTest.php
@@ -0,0 +1,34 @@
 2+<?php
 3+/**
 4+ * @author Santhosh Thottingal
 5+ * @copyright Copyright © 2012, Santhosh Thottingal
 6+ * @file
 7+ */
 8+
 9+/** Tests for MediaWiki languages/classes/LanguageKsh.php */
 10+class LanguageKshTest extends MediaWikiTestCase {
 11+ private $lang;
 12+
 13+ function setUp() {
 14+ $this->lang = Language::factory( 'ksh' );
 15+ }
 16+ function tearDown() {
 17+ unset( $this->lang );
 18+ }
 19+
 20+ /** @dataProvider providerPlural */
 21+ function testPlural( $result, $value ) {
 22+ $forms = array( 'one', 'other', 'zero' );
 23+ $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
 24+ }
 25+
 26+ function providerPlural() {
 27+ return array (
 28+ array( 'zero', 0 ),
 29+ array( 'one', 1 ),
 30+ array( 'other', 2 ),
 31+ array( 'other', 200 ),
 32+ );
 33+ }
 34+
 35+}
Property changes on: trunk/phase3/tests/phpunit/languages/LanguageKshTest.php
___________________________________________________________________
Added: svn:eol-style
136 + native
Index: trunk/phase3/tests/phpunit/languages/LanguageGaTest.php
@@ -0,0 +1,34 @@
 2+<?php
 3+/**
 4+ * @author Santhosh Thottingal
 5+ * @copyright Copyright © 2012, Santhosh Thottingal
 6+ * @file
 7+ */
 8+
 9+/** Tests for MediaWiki languages/classes/LanguageGa.php */
 10+class LanguageGaTest extends MediaWikiTestCase {
 11+ private $lang;
 12+
 13+ function setUp() {
 14+ $this->lang = Language::factory( 'ga' );
 15+ }
 16+ function tearDown() {
 17+ unset( $this->lang );
 18+ }
 19+
 20+ /** @dataProvider providerPlural */
 21+ function testPlural( $result, $value ) {
 22+ $forms = array( 'one', 'two', 'other' );
 23+ $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
 24+ }
 25+
 26+ function providerPlural() {
 27+ return array (
 28+ array( 'other', 0 ),
 29+ array( 'one', 1 ),
 30+ array( 'two', 2 ),
 31+ array( 'other', 200 ),
 32+ );
 33+ }
 34+
 35+}
Property changes on: trunk/phase3/tests/phpunit/languages/LanguageGaTest.php
___________________________________________________________________
Added: svn:eol-style
136 + native
Index: trunk/phase3/tests/phpunit/languages/LanguageGdTest.php
@@ -0,0 +1,38 @@
 2+<?php
 3+/**
 4+ * @author Santhosh Thottingal
 5+ * @copyright Copyright © 2012, Santhosh Thottingal
 6+ * @file
 7+ */
 8+
 9+/** Tests for MediaWiki languages/classes/LanguageGd.php */
 10+class LanguageGdTest extends MediaWikiTestCase {
 11+ private $lang;
 12+
 13+ function setUp() {
 14+ $this->lang = Language::factory( 'gd' );
 15+ }
 16+ function tearDown() {
 17+ unset( $this->lang );
 18+ }
 19+
 20+ /** @dataProvider providerPlural */
 21+ function testPlural( $result, $value ) {
 22+ // The CLDR ticket for this plural forms is not same as mw plural forms. See http://unicode.org/cldr/trac/ticket/2883
 23+ $forms = array( 'Form 1', 'Form 2', 'Form 3', 'Form 4', 'Form 5', 'Form 6' );
 24+ $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
 25+ }
 26+ function providerPlural() {
 27+ return array (
 28+ array( 'Form 6', 0 ),
 29+ array( 'Form 1', 1 ),
 30+ array( 'Form 2', 2 ),
 31+ array( 'Form 3', 11 ),
 32+ array( 'Form 4', 12 ),
 33+ array( 'Form 5', 3 ),
 34+ array( 'Form 5', 19 ),
 35+ array( 'Form 6', 200 ),
 36+ );
 37+ }
 38+
 39+}
Property changes on: trunk/phase3/tests/phpunit/languages/LanguageGdTest.php
___________________________________________________________________
Added: svn:eol-style
140 + native
Index: trunk/phase3/tests/phpunit/languages/LanguageCsTest.php
@@ -0,0 +1,40 @@
 2+<?php
 3+/**
 4+ * @author Santhosh Thottingal
 5+ * @copyright Copyright © 2012, Santhosh Thottingal
 6+ * @file
 7+ */
 8+
 9+/** Tests for MediaWiki languages/classes/Languagecs.php */
 10+class LanguageCsTest extends MediaWikiTestCase {
 11+ private $lang;
 12+
 13+ function setUp() {
 14+ $this->lang = Language::factory( 'cs' );
 15+ }
 16+ function tearDown() {
 17+ unset( $this->lang );
 18+ }
 19+
 20+ /** @dataProvider providerPlural */
 21+ function testPlural( $result, $value ) {
 22+ $forms = array( 'one', 'few', 'other' );
 23+ $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
 24+ }
 25+
 26+ function providerPlural() {
 27+ return array (
 28+ array( 'other', 0 ),
 29+ array( 'one', 1 ),
 30+ array( 'few', 2 ),
 31+ array( 'few', 3 ),
 32+ array( 'few', 4 ),
 33+ array( 'other', 5 ),
 34+ array( 'other', 11 ),
 35+ array( 'other', 20 ),
 36+ array( 'other', 25 ),
 37+ array( 'other', 200 ),
 38+ );
 39+ }
 40+
 41+}
Property changes on: trunk/phase3/tests/phpunit/languages/LanguageCsTest.php
___________________________________________________________________
Added: svn:eol-style
142 + native
Index: trunk/phase3/tests/phpunit/languages/LanguageCuTest.php
@@ -0,0 +1,41 @@
 2+<?php
 3+/**
 4+ * @author Santhosh Thottingal
 5+ * @copyright Copyright © 2012, Santhosh Thottingal
 6+ * @file
 7+ */
 8+
 9+/** Tests for MediaWiki languages/LanguageCu.php */
 10+class LanguageCuTest extends MediaWikiTestCase {
 11+ private $lang;
 12+
 13+ function setUp() {
 14+ $this->lang = Language::factory( 'cu' );
 15+ }
 16+ function tearDown() {
 17+ unset( $this->lang );
 18+ }
 19+
 20+ /** @dataProvider providerPlural */
 21+ function testPlural( $result, $value ) {
 22+ $forms = array( 'one', 'few', 'many', 'other' );
 23+ $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
 24+ }
 25+
 26+ function providerPlural() {
 27+ return array (
 28+ array( 'other', 0 ),
 29+ array( 'one', 1 ),
 30+ array( 'few', 2 ),
 31+ array( 'many', 3 ),
 32+ array( 'many', 4 ),
 33+ array( 'other', 5 ),
 34+ array( 'one', 11 ),
 35+ array( 'other', 20 ),
 36+ array( 'few', 22 ),
 37+ array( 'many', 223 ),
 38+ array( 'other', 200 ),
 39+ );
 40+ }
 41+
 42+}
Property changes on: trunk/phase3/tests/phpunit/languages/LanguageCuTest.php
___________________________________________________________________
Added: svn:eol-style
143 + native
Index: trunk/phase3/tests/phpunit/languages/LanguageFrTest.php
@@ -0,0 +1,34 @@
 2+<?php
 3+/**
 4+ * @author Santhosh Thottingal
 5+ * @copyright Copyright © 2012, Santhosh Thottingal
 6+ * @file
 7+ */
 8+
 9+/** Tests for MediaWiki languages/classes/LanguageFr.php */
 10+class LanguageFrTest extends MediaWikiTestCase {
 11+ private $lang;
 12+
 13+ function setUp() {
 14+ $this->lang = Language::factory( 'fr' );
 15+ }
 16+ function tearDown() {
 17+ unset( $this->lang );
 18+ }
 19+
 20+ /** @dataProvider providePlural */
 21+ function testPlural( $result, $value ) {
 22+ $forms = array( 'one', 'other' );
 23+ $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
 24+ }
 25+
 26+ function providePlural() {
 27+ return array (
 28+ array( 'one', 0 ),
 29+ array( 'one', 1 ),
 30+ array( 'other', 2 ),
 31+ array( 'other', 200 ),
 32+ );
 33+ }
 34+
 35+}
Property changes on: trunk/phase3/tests/phpunit/languages/LanguageFrTest.php
___________________________________________________________________
Added: svn:eol-style
136 + native
Index: trunk/phase3/tests/phpunit/languages/LanguageDsbTest.php
@@ -0,0 +1,40 @@
 2+<?php
 3+/**
 4+ * @author Santhosh Thottingal
 5+ * @copyright Copyright © 2012, Santhosh Thottingal
 6+ * @file
 7+ */
 8+
 9+/** Tests for MediaWiki languages/classes/LanguageDsb.php */
 10+class LanguageDsbTest extends MediaWikiTestCase {
 11+ private $lang;
 12+
 13+ function setUp() {
 14+ $this->lang = Language::factory( 'dsb' );
 15+ }
 16+ function tearDown() {
 17+ unset( $this->lang );
 18+ }
 19+
 20+ /** @dataProvider providePlural */
 21+ function testPlural( $result, $value ) {
 22+ $forms = array( 'one', 'two', 'few', 'other' );
 23+ $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
 24+ }
 25+
 26+ function providePlural() {
 27+ return array (
 28+ array( 'other', 0 ),
 29+ array( 'one', 1 ),
 30+ array( 'one', 101 ),
 31+ array( 'one', 90001 ),
 32+ array( 'two', 2 ),
 33+ array( 'few', 3 ),
 34+ array( 'few', 203 ),
 35+ array( 'few', 4 ),
 36+ array( 'other', 99 ),
 37+ array( 'other', 555 ),
 38+ );
 39+ }
 40+
 41+}
Property changes on: trunk/phase3/tests/phpunit/languages/LanguageDsbTest.php
___________________________________________________________________
Added: svn:eol-style
142 + native
Index: trunk/phase3/tests/phpunit/languages/LanguageHrTest.php
@@ -0,0 +1,41 @@
 2+<?php
 3+/**
 4+ * @author Santhosh Thottingal
 5+ * @copyright Copyright © 2012, Santhosh Thottingal
 6+ * @file
 7+ */
 8+
 9+/** Tests for MediaWiki languages/classes/LanguageHr.php */
 10+class LanguageHrTest extends MediaWikiTestCase {
 11+ private $lang;
 12+
 13+ function setUp() {
 14+ $this->lang = Language::factory( 'hr' );
 15+ }
 16+ function tearDown() {
 17+ unset( $this->lang );
 18+ }
 19+
 20+ /** @dataProvider providerPlural */
 21+ function testPlural( $result, $value ) {
 22+ $forms = array( 'one', 'few', 'many', 'other' );
 23+ $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
 24+ }
 25+
 26+ function providerPlural() {
 27+ return array (
 28+ array( 'many', 0 ),
 29+ array( 'one', 1 ),
 30+ array( 'few', 2 ),
 31+ array( 'few', 4 ),
 32+ array( 'many', 5 ),
 33+ array( 'many', 11 ),
 34+ array( 'many', 20 ),
 35+ array( 'one', 21 ),
 36+ array( 'few', 24 ),
 37+ array( 'many', 25 ),
 38+ array( 'many', 200 ),
 39+ );
 40+ }
 41+
 42+}
Property changes on: trunk/phase3/tests/phpunit/languages/LanguageHrTest.php
___________________________________________________________________
Added: svn:eol-style
143 + native
Index: trunk/phase3/tests/phpunit/languages/LanguageLnTest.php
@@ -0,0 +1,34 @@
 2+<?php
 3+/**
 4+ * @author Santhosh Thottingal
 5+ * @copyright Copyright © 2012, Santhosh Thottingal
 6+ * @file
 7+ */
 8+
 9+/** Tests for MediaWiki languages/classes/LanguageLn.php */
 10+class LanguageLnTest extends MediaWikiTestCase {
 11+ private $lang;
 12+
 13+ function setUp() {
 14+ $this->lang = Language::factory( 'ln' );
 15+ }
 16+ function tearDown() {
 17+ unset( $this->lang );
 18+ }
 19+
 20+ /** @dataProvider providePlural */
 21+ function testPlural( $result, $value ) {
 22+ $forms = array( 'one', 'other' );
 23+ $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
 24+ }
 25+
 26+ function providePlural() {
 27+ return array (
 28+ array( 'one', 0 ),
 29+ array( 'one', 1 ),
 30+ array( 'other', 2 ),
 31+ array( 'other', 200 ),
 32+ );
 33+ }
 34+
 35+}
Property changes on: trunk/phase3/tests/phpunit/languages/LanguageLnTest.php
___________________________________________________________________
Added: svn:eol-style
136 + native
Index: trunk/phase3/tests/phpunit/languages/LanguageCyTest.php
@@ -0,0 +1,42 @@
 2+<?php
 3+/**
 4+ * @author Santhosh Thottingal
 5+ * @copyright Copyright © 2012, Santhosh Thottingal
 6+ * @file
 7+ */
 8+
 9+/** Tests for MediaWiki languages/classes/LanguageCy.php */
 10+class LanguageCyTest extends MediaWikiTestCase {
 11+ private $lang;
 12+
 13+ function setUp() {
 14+ $this->lang = Language::factory( 'cy' );
 15+ }
 16+ function tearDown() {
 17+ unset( $this->lang );
 18+ }
 19+
 20+ /** @dataProvider providerPlural */
 21+ function testPlural( $result, $value ) {
 22+ $forms = array( 'zero', 'one', 'two', 'few', 'many', 'other' );
 23+ $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
 24+ }
 25+
 26+ function providerPlural() {
 27+ return array (
 28+ array( 'zero', 0 ),
 29+ array( 'one', 1 ),
 30+ array( 'two', 2 ),
 31+ array( 'few', 3 ),
 32+ array( 'many', 6 ),
 33+ array( 'other', 4 ),
 34+ array( 'other', 5 ),
 35+ array( 'other', 11 ),
 36+ array( 'other', 20 ),
 37+ array( 'other', 22 ),
 38+ array( 'other', 223 ),
 39+ array( 'other', 200.00 ),
 40+ );
 41+ }
 42+
 43+}
Property changes on: trunk/phase3/tests/phpunit/languages/LanguageCyTest.php
___________________________________________________________________
Added: svn:eol-style
144 + native
Index: trunk/phase3/tests/phpunit/languages/LanguageGvTest.php
@@ -0,0 +1,39 @@
 2+<?php
 3+/**
 4+ * @author Santhosh Thottingal
 5+ * @copyright Copyright © 2012, Santhosh Thottingal
 6+ * @file
 7+ */
 8+
 9+/** Tests for MediaWiki languages/classes/LanguageGv.php */
 10+class LanguageGvTest extends MediaWikiTestCase {
 11+ private $lang;
 12+
 13+ function setUp() {
 14+ $this->lang = Language::factory( 'gv' );
 15+ }
 16+ function tearDown() {
 17+ unset( $this->lang );
 18+ }
 19+
 20+ /** @dataProvider providerPlural */
 21+ function testPlural( $result, $value ) {
 22+ // This is not compatible with CLDR plural rules http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#gv
 23+ $forms = array( 'Form 1', 'Form 2', 'Form 3', 'Form 4' );
 24+ $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
 25+ }
 26+ function providerPlural() {
 27+ return array (
 28+ array( 'Form 4', 0 ),
 29+ array( 'Form 2', 1 ),
 30+ array( 'Form 3', 2 ),
 31+ array( 'Form 4', 3 ),
 32+ array( 'Form 1', 20 ),
 33+ array( 'Form 2', 21 ),
 34+ array( 'Form 3', 22 ),
 35+ array( 'Form 4', 23 ),
 36+ array( 'Form 4', 50 ),
 37+ );
 38+ }
 39+
 40+}
Property changes on: trunk/phase3/tests/phpunit/languages/LanguageGvTest.php
___________________________________________________________________
Added: svn:eol-style
141 + native
Index: trunk/phase3/tests/phpunit/languages/LanguageHsbTest.php
@@ -0,0 +1,40 @@
 2+<?php
 3+/**
 4+ * @author Santhosh Thottingal
 5+ * @copyright Copyright © 2012, Santhosh Thottingal
 6+ * @file
 7+ */
 8+
 9+/** Tests for MediaWiki languages/classes/LanguageHsb.php */
 10+class LanguageHsbTest extends MediaWikiTestCase {
 11+ private $lang;
 12+
 13+ function setUp() {
 14+ $this->lang = Language::factory( 'hsb' );
 15+ }
 16+ function tearDown() {
 17+ unset( $this->lang );
 18+ }
 19+
 20+ /** @dataProvider providePlural */
 21+ function testPlural( $result, $value ) {
 22+ $forms = array( 'one', 'two', 'few', 'other' );
 23+ $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
 24+ }
 25+
 26+ function providePlural() {
 27+ return array (
 28+ array( 'other', 0 ),
 29+ array( 'one', 1 ),
 30+ array( 'one', 101 ),
 31+ array( 'one', 90001 ),
 32+ array( 'two', 2 ),
 33+ array( 'few', 3 ),
 34+ array( 'few', 203 ),
 35+ array( 'few', 4 ),
 36+ array( 'other', 99 ),
 37+ array( 'other', 555 ),
 38+ );
 39+ }
 40+
 41+}
Property changes on: trunk/phase3/tests/phpunit/languages/LanguageHsbTest.php
___________________________________________________________________
Added: svn:eol-style
142 + native
Index: trunk/phase3/tests/phpunit/languages/LanguageHyTest.php
@@ -0,0 +1,34 @@
 2+<?php
 3+/**
 4+ * @author Santhosh Thottingal
 5+ * @copyright Copyright © 2012, Santhosh Thottingal
 6+ * @file
 7+ */
 8+
 9+/** Tests for MediaWiki languages/LanguageHy.php */
 10+class LanguageHyTest extends MediaWikiTestCase {
 11+ private $lang;
 12+
 13+ function setUp() {
 14+ $this->lang = Language::factory( 'hy' );
 15+ }
 16+ function tearDown() {
 17+ unset( $this->lang );
 18+ }
 19+
 20+ /** @dataProvider providerPlural */
 21+ function testPlural( $result, $value ) {
 22+ $forms = array( 'one', 'other' );
 23+ $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
 24+ }
 25+
 26+ function providerPlural() {
 27+ return array (
 28+ array( 'one', 0 ),
 29+ array( 'one', 1 ),
 30+ array( 'other', 2 ),
 31+ array( 'other', 200 ),
 32+ );
 33+ }
 34+
 35+}
Property changes on: trunk/phase3/tests/phpunit/languages/LanguageHyTest.php
___________________________________________________________________
Added: svn:eol-style
136 + native

Comments

#Comment by Siebrand (talk | contribs)   12:23, 27 January 2012

Shouldn't all tests also have a number with decimals in it?

#Comment by Santhosh.thottingal (talk | contribs)   12:42, 27 January 2012

Yes, but as of now plural rule for fractional numbers is mostly undefined for many languages. See Bug 28128. We need to address this.

Status & tagging log