LocaleBundleTest.php 1.7 KB

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