LanguageMtTest.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /**
  3. * @author Amir E. Aharoni
  4. * @copyright Copyright © 2012, Amir E. Aharoni
  5. * @file
  6. */
  7. /** Tests for MediaWiki languages/classes/LanguageMt.php */
  8. class LanguageMtTest extends LanguageClassesTestCase {
  9. /**
  10. * @dataProvider providePlural
  11. * @covers Language::convertPlural
  12. */
  13. public function testPlural( $result, $value ) {
  14. $forms = [ 'one', 'few', 'many', 'other' ];
  15. $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
  16. }
  17. /**
  18. * @dataProvider providePlural
  19. * @covers Language::getPluralRuleType
  20. */
  21. public function testGetPluralRuleType( $result, $value ) {
  22. $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) );
  23. }
  24. public static function providePlural() {
  25. return [
  26. [ 'few', 0 ],
  27. [ 'one', 1 ],
  28. [ 'few', 2 ],
  29. [ 'few', 10 ],
  30. [ 'many', 11 ],
  31. [ 'many', 19 ],
  32. [ 'other', 20 ],
  33. [ 'other', 99 ],
  34. [ 'other', 100 ],
  35. [ 'other', 101 ],
  36. [ 'few', 102 ],
  37. [ 'few', 110 ],
  38. [ 'many', 111 ],
  39. [ 'many', 119 ],
  40. [ 'other', 120 ],
  41. [ 'other', 201 ],
  42. ];
  43. }
  44. /**
  45. * @dataProvider providePluralTwoForms
  46. * @covers Language::convertPlural
  47. */
  48. public function testPluralTwoForms( $result, $value ) {
  49. $forms = [ 'one', 'other' ];
  50. $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
  51. }
  52. public static function providePluralTwoForms() {
  53. return [
  54. [ 'other', 0 ],
  55. [ 'one', 1 ],
  56. [ 'other', 2 ],
  57. [ 'other', 10 ],
  58. [ 'other', 11 ],
  59. [ 'other', 19 ],
  60. [ 'other', 20 ],
  61. [ 'other', 99 ],
  62. [ 'other', 100 ],
  63. [ 'other', 101 ],
  64. [ 'other', 102 ],
  65. [ 'other', 110 ],
  66. [ 'other', 111 ],
  67. [ 'other', 119 ],
  68. [ 'other', 120 ],
  69. [ 'other', 201 ],
  70. ];
  71. }
  72. }