IcuLocaleBundleTest.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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\Icu\Tests;
  11. use Symfony\Component\Icu\IcuData;
  12. use Symfony\Component\Icu\IcuLocaleBundle;
  13. /**
  14. * @author Bernhard Schussek <bschussek@gmail.com>
  15. */
  16. class IcuLocaleBundleTest extends IcuTestCase
  17. {
  18. /**
  19. * @var string
  20. */
  21. private $resDir;
  22. /**
  23. * @var IcuLocaleBundle
  24. */
  25. private $bundle;
  26. /**
  27. * @var \PHPUnit_Framework_MockObject_MockObject
  28. */
  29. private $reader;
  30. protected function setUp()
  31. {
  32. parent::setUp();
  33. $this->resDir = IcuData::getResourceDirectory() . '/locales';
  34. $this->reader = $this->getMock('Symfony\Component\Intl\ResourceBundle\Reader\StructuredBundleReaderInterface');
  35. $this->bundle = new IcuLocaleBundle($this->reader);
  36. }
  37. public function testGetLocaleNames()
  38. {
  39. $locales = array(
  40. 'en_GB' => 'English (United Kingdom)',
  41. 'en_IE' => 'English (Ireland)',
  42. 'en_US' => 'English (United States)',
  43. );
  44. $this->reader->expects($this->once())
  45. ->method('readEntry')
  46. ->with($this->resDir, 'en', array('Locales'))
  47. ->will($this->returnValue($locales));
  48. $sortedLocales = array(
  49. 'en_IE' => 'English (Ireland)',
  50. 'en_GB' => 'English (United Kingdom)',
  51. 'en_US' => 'English (United States)',
  52. );
  53. $this->assertSame($sortedLocales, $this->bundle->getLocaleNames('en'));
  54. }
  55. }