123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- <?php
- namespace Symfony\Tests\Component\Locale\Stub;
- use Symfony\Component\Locale\Stub\StubLocale;
- /*
- * This file is part of the Symfony framework.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * This source file is subject to the MIT license that is bundled
- * with this source code in the file LICENSE.
- */
- class StubLocaleTest extends \PHPUnit_Framework_TestCase
- {
- /**
- * @expectedException InvalidArgumentException
- */
- public function testGetDisplayCountriesWithUnsupportedLocale()
- {
- $countries = StubLocale::getDisplayCountries('pt_BR');
- }
- public function testGetDisplayCountries()
- {
- $countries = StubLocale::getDisplayCountries('en');
- $this->assertEquals('Brazil', $countries['BR']);
- }
- public function testGetCountries()
- {
- $countries = StubLocale::getCountries();
- $this->assertTrue(in_array('BR', $countries));
- }
- /**
- * @expectedException InvalidArgumentException
- */
- public function testGetDisplayLanguagesWithUnsupportedLocale()
- {
- $countries = StubLocale::getDisplayLanguages('pt_BR');
- }
- public function testGetDisplayLanguages()
- {
- $languages = StubLocale::getDisplayLanguages('en');
- $this->assertEquals('Brazilian Portuguese', $languages['pt_BR']);
- }
- public function testGetLanguages()
- {
- $languages = StubLocale::getLanguages();
- $this->assertTrue(in_array('pt_BR', $languages));
- }
- /**
- * @expectedException InvalidArgumentException
- */
- public function testGetCurrenciesDataWithUnsupportedLocale()
- {
- $currencies = StubLocale::getCurrenciesData('pt_BR');
- }
- public function testGetCurrenciesData()
- {
- $currencies = StubLocale::getCurrenciesData('en');
- $this->assertEquals('R$', $currencies['BRL']['symbol']);
- $this->assertEquals('Brazilian Real', $currencies['BRL']['name']);
- $this->assertEquals(2, $currencies['BRL']['fractionDigits']);
- $this->assertEquals(0, $currencies['BRL']['roundingIncrement']);
- }
- public function testGetDisplayCurrencies()
- {
- $currencies = StubLocale::getDisplayCurrencies('en');
- $this->assertEquals('Brazilian Real', $currencies['BRL']);
- // Checking that the cache is being used
- $currencies = StubLocale::getDisplayCurrencies('en');
- $this->assertEquals('Argentine Peso', $currencies['ARS']);
- }
- public function testGetCurrencies()
- {
- $currencies = StubLocale::getCurrencies();
- $this->assertTrue(in_array('BRL', $currencies));
- }
- /**
- * @expectedException InvalidArgumentException
- */
- public function testGetDisplayLocalesWithUnsupportedLocale()
- {
- $locales = StubLocale::getDisplayLocales('pt');
- }
- public function testGetDisplayLocales()
- {
- $locales = StubLocale::getDisplayLocales('en');
- $this->assertEquals('Portuguese', $locales['pt']);
- }
- public function testGetLocales()
- {
- $locales = StubLocale::getLocales();
- $this->assertTrue(in_array('pt', $locales));
- }
- /**
- * @expectedException Symfony\Component\Locale\Exception\MethodNotImplementedException
- */
- public function testAcceptFromHttp()
- {
- StubLocale::acceptFromHttp('pt-br,en-us;q=0.7,en;q=0.5');
- }
- /**
- * @expectedException Symfony\Component\Locale\Exception\MethodNotImplementedException
- */
- public function testComposeLocale()
- {
- $subtags = array(
- 'language' => 'pt',
- 'script' => 'Latn',
- 'region' => 'BR'
- );
- StubLocale::composeLocale($subtags);
- }
- /**
- * @expectedException Symfony\Component\Locale\Exception\MethodNotImplementedException
- */
- public function testFilterMatches()
- {
- StubLocale::filterMatches('pt-BR', 'pt-BR');
- }
- /**
- * @expectedException Symfony\Component\Locale\Exception\MethodNotImplementedException
- */
- public function testGetAllVariants()
- {
- StubLocale::getAllVariants('pt_BR_Latn');
- }
- public function testGetDefault()
- {
- $this->assertEquals('en', StubLocale::getDefault());
- }
- /**
- * @expectedException Symfony\Component\Locale\Exception\MethodNotImplementedException
- */
- public function testGetDisplayLanguage()
- {
- StubLocale::getDisplayLanguage('pt-Latn-BR', 'en');
- }
- /**
- * @expectedException Symfony\Component\Locale\Exception\MethodNotImplementedException
- */
- public function testGetDisplayName()
- {
- StubLocale::getDisplayName('pt-Latn-BR', 'en');
- }
- /**
- * @expectedException Symfony\Component\Locale\Exception\MethodNotImplementedException
- */
- public function testGetDisplayRegion()
- {
- StubLocale::getDisplayRegion('pt-Latn-BR', 'en');
- }
- /**
- * @expectedException Symfony\Component\Locale\Exception\MethodNotImplementedException
- */
- public function testGetDisplayScript()
- {
- StubLocale::getDisplayScript('pt-Latn-BR', 'en');
- }
- /**
- * @expectedException Symfony\Component\Locale\Exception\MethodNotImplementedException
- */
- public function testGetDisplayVariant()
- {
- StubLocale::getDisplayVariant('pt-Latn-BR', 'en');
- }
- /**
- * @expectedException Symfony\Component\Locale\Exception\MethodNotImplementedException
- */
- public function testGetKeywords()
- {
- StubLocale::getKeywords('pt-BR@currency=BRL');
- }
- /**
- * @expectedException Symfony\Component\Locale\Exception\MethodNotImplementedException
- */
- public function testGetPrimaryLanguage()
- {
- StubLocale::getPrimaryLanguage('pt-Latn-BR');
- }
- /**
- * @expectedException Symfony\Component\Locale\Exception\MethodNotImplementedException
- */
- public function testGetRegion()
- {
- StubLocale::getRegion('pt-Latn-BR');
- }
- /**
- * @expectedException Symfony\Component\Locale\Exception\MethodNotImplementedException
- */
- public function testGetScript()
- {
- StubLocale::getScript('pt-Latn-BR');
- }
- /**
- * @expectedException Symfony\Component\Locale\Exception\MethodNotImplementedException
- */
- public function testLookup()
- {
- $langtag = array(
- 'pt-Latn-BR',
- 'pt-BR'
- );
- StubLocale::lookup($langtag, 'pt-BR-x-priv1');
- }
- /**
- * @expectedException Symfony\Component\Locale\Exception\MethodNotImplementedException
- */
- public function testParseLocale()
- {
- StubLocale::parseLocale('pt-Latn-BR');
- }
- /**
- * @expectedException Symfony\Component\Locale\Exception\MethodNotImplementedException
- */
- public function testSetDefault()
- {
- StubLocale::setDefault('pt_BR');
- }
- }
|