|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Symfony package. |
| 5 | + * |
| 6 | + * (c) Fabien Potencier <fabien@symfony.com> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Symfony\Component\Intl\Tests; |
| 13 | + |
| 14 | +use Symfony\Component\Intl\Intl; |
| 15 | +use PHPUnit\Framework\TestCase; |
| 16 | + |
| 17 | +class IntlTest extends TestCase |
| 18 | +{ |
| 19 | + /** |
| 20 | + * @requires extension intl |
| 21 | + */ |
| 22 | + public function testIsExtensionLoadedChecksIfIntlExtensionIsLoaded() |
| 23 | + { |
| 24 | + $this->assertTrue(Intl::isExtensionLoaded()); |
| 25 | + } |
| 26 | + |
| 27 | + public function testGetCurrencyBundleCreatesTheCurrencyBundle() |
| 28 | + { |
| 29 | + $this->assertInstanceOf('Symfony\Component\Intl\ResourceBundle\CurrencyBundleInterface', Intl::getCurrencyBundle()); |
| 30 | + } |
| 31 | + |
| 32 | + public function testGetLanguageBundleCreatesTheLanguageBundle() |
| 33 | + { |
| 34 | + $this->assertInstanceOf('Symfony\Component\Intl\ResourceBundle\LanguageBundleInterface', Intl::getLanguageBundle()); |
| 35 | + } |
| 36 | + |
| 37 | + public function testGetLocaleBundleCreatesTheLocaleBundle() |
| 38 | + { |
| 39 | + $this->assertInstanceOf('Symfony\Component\Intl\ResourceBundle\LocaleBundleInterface', Intl::getLocaleBundle()); |
| 40 | + } |
| 41 | + |
| 42 | + public function testGetRegionBundleCreatesTheRegionBundle() |
| 43 | + { |
| 44 | + $this->assertInstanceOf('Symfony\Component\Intl\ResourceBundle\LocaleBundleInterface', Intl::getLocaleBundle()); |
| 45 | + } |
| 46 | + |
| 47 | + public function testGetIcuVersionReadsTheVersionOfInstalledIcuLibrary() |
| 48 | + { |
| 49 | + $this->assertStringMatchesFormat('%d.%d', Intl::getIcuVersion()); |
| 50 | + } |
| 51 | + |
| 52 | + public function testGetIcuDataVersionReadsTheVersionOfInstalledIcuData() |
| 53 | + { |
| 54 | + $this->assertStringMatchesFormat('%d.%d', Intl::getIcuDataVersion()); |
| 55 | + } |
| 56 | + |
| 57 | + public function testGetIcuStubVersionReadsTheVersionOfBundledStubs() |
| 58 | + { |
| 59 | + $this->assertStringMatchesFormat('%d.%d', Intl::getIcuStubVersion()); |
| 60 | + } |
| 61 | + |
| 62 | + public function testGetDataDirectoryReturnsThePathToIcuData() |
| 63 | + { |
| 64 | + $this->assertTrue(is_dir(Intl::getDataDirectory())); |
| 65 | + } |
| 66 | + |
| 67 | + /** |
| 68 | + * @requires extension intl |
| 69 | + */ |
| 70 | + public function testLocaleAliasesAreLoaded() |
| 71 | + { |
| 72 | + \Locale::setDefault('zh_TW'); |
| 73 | + $countryNameZhTw = Intl::getRegionBundle()->getCountryName('AD'); |
| 74 | + |
| 75 | + \Locale::setDefault('zh_Hant_TW'); |
| 76 | + $countryNameHantZhTw = Intl::getRegionBundle()->getCountryName('AD'); |
| 77 | + |
| 78 | + \Locale::setDefault('zh'); |
| 79 | + $countryNameZh = Intl::getRegionBundle()->getCountryName('AD'); |
| 80 | + |
| 81 | + $this->assertSame($countryNameZhTw, $countryNameHantZhTw, 'zh_TW is an alias to zh_Hant_TW'); |
| 82 | + $this->assertNotSame($countryNameZh, $countryNameZhTw, 'zh_TW does not fall back to zh'); |
| 83 | + } |
| 84 | +} |
0 commit comments