LanguageBe_taraskTest.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. // phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
  3. /**
  4. * @covers LanguageBe_tarask
  5. */
  6. class LanguageBe_taraskTest extends LanguageClassesTestCase {
  7. // phpcs:enable
  8. /**
  9. * Make sure the language code we are given is indeed
  10. * be-tarask. This is to ensure LanguageClassesTestCase
  11. * does not give us the wrong language.
  12. */
  13. public function testBeTaraskTestsUsesBeTaraskCode() {
  14. $this->assertEquals( 'be-tarask',
  15. $this->getLang()->getCode()
  16. );
  17. }
  18. /**
  19. * @see T25156 & r64981
  20. * @covers Language::commafy
  21. */
  22. public function testSearchRightSingleQuotationMarkAsApostroph() {
  23. $this->assertEquals(
  24. "'",
  25. $this->getLang()->normalizeForSearch( '’' ),
  26. 'T25156: U+2019 conversion to U+0027'
  27. );
  28. }
  29. /**
  30. * @see T25156 & r64981
  31. * @covers Language::commafy
  32. */
  33. public function testCommafy() {
  34. $this->assertEquals( '1,234,567', $this->getLang()->commafy( '1234567' ) );
  35. $this->assertEquals( '12,345', $this->getLang()->commafy( '12345' ) );
  36. }
  37. /**
  38. * @see T25156 & r64981
  39. * @covers Language::commafy
  40. */
  41. public function testDoesNotCommafyFourDigitsNumber() {
  42. $this->assertEquals( '1234', $this->getLang()->commafy( '1234' ) );
  43. }
  44. /**
  45. * @dataProvider providePlural
  46. * @covers Language::convertPlural
  47. */
  48. public function testPlural( $result, $value ) {
  49. $forms = [ 'one', 'few', 'many', 'other' ];
  50. $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
  51. }
  52. /**
  53. * @dataProvider providePlural
  54. * @covers Language::getPluralRuleType
  55. */
  56. public function testGetPluralRuleType( $result, $value ) {
  57. $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) );
  58. }
  59. public static function providePlural() {
  60. return [
  61. [ 'one', 1 ],
  62. [ 'many', 11 ],
  63. [ 'one', 91 ],
  64. [ 'one', 121 ],
  65. [ 'few', 2 ],
  66. [ 'few', 3 ],
  67. [ 'few', 4 ],
  68. [ 'few', 334 ],
  69. [ 'many', 5 ],
  70. [ 'many', 15 ],
  71. [ 'many', 120 ],
  72. ];
  73. }
  74. /**
  75. * @dataProvider providePluralTwoForms
  76. * @covers Language::convertPlural
  77. */
  78. public function testPluralTwoForms( $result, $value ) {
  79. $forms = [ '1=one', 'other' ];
  80. $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
  81. }
  82. public static function providePluralTwoForms() {
  83. return [
  84. [ 'other', 0 ],
  85. [ 'one', 1 ],
  86. [ 'other', 11 ],
  87. [ 'other', 91 ],
  88. [ 'other', 121 ],
  89. ];
  90. }
  91. }