LocaleTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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\Locale\Tests;
  11. use Symfony\Component\Intl\Intl;
  12. use Symfony\Component\Intl\Util\IntlTestHelper;
  13. use Symfony\Component\Locale\Locale;
  14. /**
  15. * Test case for the {@link Locale} class.
  16. *
  17. * @author Bernhard Schussek <bschussek@gmail.com>
  18. */
  19. class LocaleTest extends \PHPUnit_Framework_TestCase
  20. {
  21. protected function setUp()
  22. {
  23. // Locale extends \Locale, so intl must be present
  24. IntlTestHelper::requireIntl($this);
  25. }
  26. public function testGetDisplayCountries()
  27. {
  28. $countries = Locale::getDisplayCountries('en');
  29. $this->assertEquals('Brazil', $countries['BR']);
  30. }
  31. public function testGetCountries()
  32. {
  33. $countries = Locale::getCountries();
  34. $this->assertTrue(in_array('BR', $countries));
  35. }
  36. public function testGetDisplayLanguages()
  37. {
  38. $languages = Locale::getDisplayLanguages('en');
  39. $this->assertEquals('Brazilian Portuguese', $languages['pt_BR']);
  40. }
  41. public function testGetLanguages()
  42. {
  43. $languages = Locale::getLanguages();
  44. $this->assertTrue(in_array('pt_BR', $languages));
  45. }
  46. public function testGetDisplayLocales()
  47. {
  48. $locales = Locale::getDisplayLocales('en');
  49. $this->assertEquals('Portuguese', $locales['pt']);
  50. }
  51. public function testGetLocales()
  52. {
  53. $locales = Locale::getLocales();
  54. $this->assertTrue(in_array('pt', $locales));
  55. }
  56. }