LocaleTest.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Intl\Tests\Locale;
  11. class LocaleTest extends AbstractLocaleTest
  12. {
  13. /**
  14. * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
  15. */
  16. public function testAcceptFromHttp()
  17. {
  18. $this->call('acceptFromHttp', 'pt-br,en-us;q=0.7,en;q=0.5');
  19. }
  20. /**
  21. * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
  22. */
  23. public function testComposeLocale()
  24. {
  25. $subtags = array(
  26. 'language' => 'pt',
  27. 'script' => 'Latn',
  28. 'region' => 'BR',
  29. );
  30. $this->call('composeLocale', $subtags);
  31. }
  32. /**
  33. * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
  34. */
  35. public function testFilterMatches()
  36. {
  37. $this->call('filterMatches', 'pt-BR', 'pt-BR');
  38. }
  39. /**
  40. * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
  41. */
  42. public function testGetAllVariants()
  43. {
  44. $this->call('getAllVariants', 'pt_BR_Latn');
  45. }
  46. /**
  47. * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
  48. */
  49. public function testGetDisplayLanguage()
  50. {
  51. $this->call('getDisplayLanguage', 'pt-Latn-BR', 'en');
  52. }
  53. /**
  54. * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
  55. */
  56. public function testGetDisplayName()
  57. {
  58. $this->call('getDisplayName', 'pt-Latn-BR', 'en');
  59. }
  60. /**
  61. * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
  62. */
  63. public function testGetDisplayRegion()
  64. {
  65. $this->call('getDisplayRegion', 'pt-Latn-BR', 'en');
  66. }
  67. /**
  68. * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
  69. */
  70. public function testGetDisplayScript()
  71. {
  72. $this->call('getDisplayScript', 'pt-Latn-BR', 'en');
  73. }
  74. /**
  75. * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
  76. */
  77. public function testGetDisplayVariant()
  78. {
  79. $this->call('getDisplayVariant', 'pt-Latn-BR', 'en');
  80. }
  81. /**
  82. * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
  83. */
  84. public function testGetKeywords()
  85. {
  86. $this->call('getKeywords', 'pt-BR@currency=BRL');
  87. }
  88. /**
  89. * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
  90. */
  91. public function testGetPrimaryLanguage()
  92. {
  93. $this->call('getPrimaryLanguage', 'pt-Latn-BR');
  94. }
  95. /**
  96. * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
  97. */
  98. public function testGetRegion()
  99. {
  100. $this->call('getRegion', 'pt-Latn-BR');
  101. }
  102. /**
  103. * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
  104. */
  105. public function testGetScript()
  106. {
  107. $this->call('getScript', 'pt-Latn-BR');
  108. }
  109. /**
  110. * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
  111. */
  112. public function testLookup()
  113. {
  114. $langtag = array(
  115. 'pt-Latn-BR',
  116. 'pt-BR',
  117. );
  118. $this->call('lookup', $langtag, 'pt-BR-x-priv1');
  119. }
  120. /**
  121. * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
  122. */
  123. public function testParseLocale()
  124. {
  125. $this->call('parseLocale', 'pt-Latn-BR');
  126. }
  127. /**
  128. * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
  129. */
  130. public function testSetDefault()
  131. {
  132. $this->call('setDefault', 'pt_BR');
  133. }
  134. public function testSetDefaultAcceptsEn()
  135. {
  136. $this->call('setDefault', 'en');
  137. $this->assertSame('en', $this->call('getDefault'));
  138. }
  139. protected function call($methodName)
  140. {
  141. $args = array_slice(func_get_args(), 1);
  142. return call_user_func_array(array('Symfony\Component\Intl\Locale\Locale', $methodName), $args);
  143. }
  144. }