123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355 |
- <?php
- /*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
- namespace Symfony\Component\Intl\Tests\Data\Provider;
- use Symfony\Component\Intl\Data\Provider\RegionDataProvider;
- use Symfony\Component\Intl\Intl;
- use Symfony\Component\Intl\Locale;
- /**
- * @author Bernhard Schussek <bschussek@gmail.com>
- */
- abstract class AbstractRegionDataProviderTest extends AbstractDataProviderTest
- {
- // The below arrays document the state of the ICU data bundled with this package.
- protected static $territories = array(
- 'AC',
- 'AD',
- 'AE',
- 'AF',
- 'AG',
- 'AI',
- 'AL',
- 'AM',
- 'AN',
- 'AO',
- 'AQ',
- 'AR',
- 'AS',
- 'AT',
- 'AU',
- 'AW',
- 'AX',
- 'AZ',
- 'BA',
- 'BB',
- 'BD',
- 'BE',
- 'BF',
- 'BG',
- 'BH',
- 'BI',
- 'BJ',
- 'BL',
- 'BM',
- 'BN',
- 'BO',
- 'BQ',
- 'BR',
- 'BS',
- 'BT',
- 'BV',
- 'BW',
- 'BY',
- 'BZ',
- 'CA',
- 'CC',
- 'CD',
- 'CF',
- 'CG',
- 'CH',
- 'CI',
- 'CK',
- 'CL',
- 'CM',
- 'CN',
- 'CO',
- 'CP',
- 'CR',
- 'CU',
- 'CV',
- 'CW',
- 'CX',
- 'CY',
- 'CZ',
- 'DE',
- 'DG',
- 'DJ',
- 'DK',
- 'DM',
- 'DO',
- 'DZ',
- 'EA',
- 'EC',
- 'EE',
- 'EG',
- 'EH',
- 'ER',
- 'ES',
- 'ET',
- 'EU',
- 'FI',
- 'FJ',
- 'FK',
- 'FM',
- 'FO',
- 'FR',
- 'GA',
- 'GB',
- 'GD',
- 'GE',
- 'GF',
- 'GG',
- 'GH',
- 'GI',
- 'GL',
- 'GM',
- 'GN',
- 'GP',
- 'GQ',
- 'GR',
- 'GS',
- 'GT',
- 'GU',
- 'GW',
- 'GY',
- 'HK',
- 'HM',
- 'HN',
- 'HR',
- 'HT',
- 'HU',
- 'IC',
- 'ID',
- 'IE',
- 'IL',
- 'IM',
- 'IN',
- 'IO',
- 'IQ',
- 'IR',
- 'IS',
- 'IT',
- 'JE',
- 'JM',
- 'JO',
- 'JP',
- 'KE',
- 'KG',
- 'KH',
- 'KI',
- 'KM',
- 'KN',
- 'KP',
- 'KR',
- 'KW',
- 'KY',
- 'KZ',
- 'LA',
- 'LB',
- 'LC',
- 'LI',
- 'LK',
- 'LR',
- 'LS',
- 'LT',
- 'LU',
- 'LV',
- 'LY',
- 'MA',
- 'MC',
- 'MD',
- 'ME',
- 'MF',
- 'MG',
- 'MH',
- 'MK',
- 'ML',
- 'MM',
- 'MN',
- 'MO',
- 'MP',
- 'MQ',
- 'MR',
- 'MS',
- 'MT',
- 'MU',
- 'MV',
- 'MW',
- 'MX',
- 'MY',
- 'MZ',
- 'NA',
- 'NC',
- 'NE',
- 'NF',
- 'NG',
- 'NI',
- 'NL',
- 'NO',
- 'NP',
- 'NR',
- 'NU',
- 'NZ',
- 'OM',
- 'PA',
- 'PE',
- 'PF',
- 'PG',
- 'PH',
- 'PK',
- 'PL',
- 'PM',
- 'PN',
- 'PR',
- 'PS',
- 'PT',
- 'PW',
- 'PY',
- 'QA',
- 'RE',
- 'RO',
- 'RS',
- 'RU',
- 'RW',
- 'SA',
- 'SB',
- 'SC',
- 'SD',
- 'SE',
- 'SG',
- 'SH',
- 'SI',
- 'SJ',
- 'SK',
- 'SL',
- 'SM',
- 'SN',
- 'SO',
- 'SR',
- 'SS',
- 'ST',
- 'SV',
- 'SX',
- 'SY',
- 'SZ',
- 'TA',
- 'TC',
- 'TD',
- 'TF',
- 'TG',
- 'TH',
- 'TJ',
- 'TK',
- 'TL',
- 'TM',
- 'TN',
- 'TO',
- 'TR',
- 'TT',
- 'TV',
- 'TW',
- 'TZ',
- 'UA',
- 'UG',
- 'UM',
- 'US',
- 'UY',
- 'UZ',
- 'VA',
- 'VC',
- 'VE',
- 'VG',
- 'VI',
- 'VN',
- 'VU',
- 'WF',
- 'WS',
- 'XK',
- 'YE',
- 'YT',
- 'ZA',
- 'ZM',
- 'ZW',
- );
- /**
- * @var RegionDataProvider
- */
- protected $dataProvider;
- protected function setUp()
- {
- parent::setUp();
- $this->dataProvider = new RegionDataProvider(
- $this->getDataDirectory().'/'.Intl::REGION_DIR,
- $this->createEntryReader()
- );
- }
- abstract protected function getDataDirectory();
- public function testGetRegions()
- {
- $this->assertSame(static::$territories, $this->dataProvider->getRegions());
- }
- /**
- * @dataProvider provideLocales
- */
- public function testGetNames($displayLocale)
- {
- $countries = array_keys($this->dataProvider->getNames($displayLocale));
- sort($countries);
- $this->assertSame(static::$territories, $countries);
- }
- public function testGetNamesDefaultLocale()
- {
- Locale::setDefault('de_AT');
- $this->assertSame(
- $this->dataProvider->getNames('de_AT'),
- $this->dataProvider->getNames()
- );
- }
- /**
- * @dataProvider provideLocaleAliases
- */
- public function testGetNamesSupportsAliases($alias, $ofLocale)
- {
- // Can't use assertSame(), because some aliases contain scripts with
- // different collation (=order of output) than their aliased locale
- // e.g. sr_Latn_ME => sr_ME
- $this->assertEquals(
- $this->dataProvider->getNames($ofLocale),
- $this->dataProvider->getNames($alias)
- );
- }
- /**
- * @dataProvider provideLocales
- */
- public function testGetName($displayLocale)
- {
- $names = $this->dataProvider->getNames($displayLocale);
- foreach ($names as $country => $name) {
- $this->assertSame($name, $this->dataProvider->getName($country, $displayLocale));
- }
- }
- }
|