LanguageTrTest.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * @author Antoine Musso
  4. * @copyright Copyright © 2011, Antoine Musso
  5. * @file
  6. */
  7. /**
  8. * @covers LanguageTr
  9. */
  10. class LanguageTrTest extends LanguageClassesTestCase {
  11. /**
  12. * See T30040
  13. * Credits to irc://irc.freenode.net/wikipedia-tr users:
  14. * - berm
  15. * - []LuCkY[]
  16. * - Emperyan
  17. * @see https://en.wikipedia.org/wiki/Dotted_and_dotless_I
  18. * @dataProvider provideDottedAndDotlessI
  19. * @covers Language::ucfirst
  20. * @covers Language::lcfirst
  21. */
  22. public function testDottedAndDotlessI( $func, $input, $inputCase, $expected ) {
  23. if ( $func == 'ucfirst' ) {
  24. $res = $this->getLang()->ucfirst( $input );
  25. } elseif ( $func == 'lcfirst' ) {
  26. $res = $this->getLang()->lcfirst( $input );
  27. } else {
  28. throw new MWException( __METHOD__ . " given an invalid function name '$func'" );
  29. }
  30. $msg = "Converting $inputCase case '$input' with $func should give '$expected'";
  31. $this->assertEquals( $expected, $res, $msg );
  32. }
  33. public static function provideDottedAndDotlessI() {
  34. return [
  35. # function, input, input case, expected
  36. # Case changed:
  37. [ 'ucfirst', 'ı', 'lower', 'I' ],
  38. [ 'ucfirst', 'i', 'lower', 'İ' ],
  39. [ 'lcfirst', 'I', 'upper', 'ı' ],
  40. [ 'lcfirst', 'İ', 'upper', 'i' ],
  41. # Already using the correct case
  42. [ 'ucfirst', 'I', 'upper', 'I' ],
  43. [ 'ucfirst', 'İ', 'upper', 'İ' ],
  44. [ 'lcfirst', 'ı', 'lower', 'ı' ],
  45. [ 'lcfirst', 'i', 'lower', 'i' ],
  46. # A real example taken from T30040 using
  47. # https://tr.wikipedia.org/wiki/%C4%B0Phone
  48. [ 'lcfirst', 'iPhone', 'lower', 'iPhone' ],
  49. # next case is valid in Turkish but are different words if we
  50. # consider IPhone is English!
  51. [ 'lcfirst', 'IPhone', 'upper', 'ıPhone' ],
  52. ];
  53. }
  54. }