RegionBundleTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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\RegionBundle;
  12. /**
  13. * @author Bernhard Schussek <bschussek@gmail.com>
  14. */
  15. class RegionBundleTest extends \PHPUnit_Framework_TestCase
  16. {
  17. const RES_DIR = '/base/region';
  18. /**
  19. * @var RegionBundle
  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 RegionBundle(self::RES_DIR, $this->reader);
  30. }
  31. public function testGetCountryName()
  32. {
  33. $this->reader->expects($this->once())
  34. ->method('readEntry')
  35. ->with(self::RES_DIR, 'en', array('Countries', 'AT'), true)
  36. ->will($this->returnValue('Austria'));
  37. $this->assertSame('Austria', $this->bundle->getCountryName('AT', 'en'));
  38. }
  39. public function testGetCountryNames()
  40. {
  41. $sortedCountries = array(
  42. 'AT' => 'Austria',
  43. 'DE' => 'Germany',
  44. );
  45. $this->reader->expects($this->once())
  46. ->method('readEntry')
  47. ->with(self::RES_DIR, 'en', array('Countries'), true)
  48. ->will($this->returnValue($sortedCountries));
  49. $this->assertSame($sortedCountries, $this->bundle->getCountryNames('en'));
  50. }
  51. }