LanguageUkTest.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. /**
  3. * @author Amir E. Aharoni
  4. * based on LanguageBe_tarask.php
  5. * @copyright Copyright © 2012, Amir E. Aharoni
  6. * @file
  7. */
  8. class LanguageUkTest 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. * Test explicit plural forms - n=FormN forms
  19. * @covers Language::convertPlural
  20. */
  21. public function testExplicitPlural() {
  22. $forms = [ 'one', 'few', 'many', 'other', '12=dozen' ];
  23. $this->assertEquals( 'dozen', $this->getLang()->convertPlural( 12, $forms ) );
  24. $forms = [ 'one', 'few', 'many', '100=hundred', 'other', '12=dozen' ];
  25. $this->assertEquals( 'hundred', $this->getLang()->convertPlural( 100, $forms ) );
  26. }
  27. /**
  28. * @dataProvider providePlural
  29. * @covers Language::getPluralRuleType
  30. */
  31. public function testGetPluralRuleType( $result, $value ) {
  32. $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) );
  33. }
  34. public static function providePlural() {
  35. return [
  36. [ 'one', 1 ],
  37. [ 'many', 11 ],
  38. [ 'one', 91 ],
  39. [ 'one', 121 ],
  40. [ 'few', 2 ],
  41. [ 'few', 3 ],
  42. [ 'few', 4 ],
  43. [ 'few', 334 ],
  44. [ 'many', 5 ],
  45. [ 'many', 15 ],
  46. [ 'many', 120 ],
  47. ];
  48. }
  49. /**
  50. * @dataProvider providePluralTwoForms
  51. * @covers Language::convertPlural
  52. */
  53. public function testPluralTwoForms( $result, $value ) {
  54. $forms = [ '1=one', 'other' ];
  55. $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
  56. }
  57. public static function providePluralTwoForms() {
  58. return [
  59. [ 'one', 1 ],
  60. [ 'other', 11 ],
  61. [ 'other', 91 ],
  62. [ 'other', 121 ],
  63. ];
  64. }
  65. /**
  66. * @dataProvider providerGrammar
  67. * @covers Language::convertGrammar
  68. */
  69. public function testGrammar( $result, $word, $case ) {
  70. $this->assertEquals( $result, $this->getLang()->convertGrammar( $word, $case ) );
  71. }
  72. public static function providerGrammar() {
  73. return [
  74. [
  75. 'Вікіпедії',
  76. 'Вікіпедія',
  77. 'genitive',
  78. ],
  79. [
  80. 'Віківидів',
  81. 'Віківиди',
  82. 'genitive',
  83. ],
  84. [
  85. 'Вікіцитат',
  86. 'Вікіцитати',
  87. 'genitive',
  88. ],
  89. [
  90. 'Вікіпідручника',
  91. 'Вікіпідручник',
  92. 'genitive',
  93. ],
  94. [
  95. 'Вікіпедію',
  96. 'Вікіпедія',
  97. 'accusative',
  98. ],
  99. ];
  100. }
  101. }