protected function setUp() { IntlTestHelper::requireFullIntl($this); $this->context = $this->getMock('Symfony\\Component\\Validator\\ExecutionContext', array(), array(), '', false); $this->validator = new CurrencyValidator(); $this->validator->initialize($this->context); }
public function testWriteResourceBundle() { IntlTestHelper::requireFullIntl($this); $bundle = new \ResourceBundle('rb', __DIR__ . '/Fixtures', false); $this->writer->write($this->directory, 'en', $bundle); $this->assertFileEquals(__DIR__ . '/Fixtures/rb.php', $this->directory . '/en.php'); }
protected function setUp() { // we test against different locales, so we need the full // implementation IntlTestHelper::requireFullIntl($this); parent::setUp(); }
/** * @dataProvider getValidCurrencies **/ public function testValidCurrenciesWithCountrySpecificLocale($currency) { IntlTestHelper::requireFullIntl($this); \Locale::setDefault('en_GB'); $this->validator->validate($currency, new Currency()); $this->assertNoViolation(); }
protected function setUp() { parent::setUp(); // we test against "de_DE", so we need the full implementation IntlTestHelper::requireFullIntl($this); \Locale::setDefault('de_DE'); }
protected function setUp() { parent::setUp(); // we test against "de_AT", so we need the full implementation IntlTestHelper::requireFullIntl($this); \Locale::setDefault('de_AT'); $this->defaultTimezone = date_default_timezone_get(); }
public function testReverseTransform() { // Since we test against "de_AT", we need the full implementation IntlTestHelper::requireFullIntl($this, false); \Locale::setDefault('de_AT'); $transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100); $this->assertEquals(123, $transformer->reverseTransform('1,23')); }
protected function getDateFormatter($locale, $datetype, $timetype, $timezone = null, $calendar = IntlDateFormatter::GREGORIAN, $pattern = null) { IntlTestHelper::requireFullIntl($this, '55.1'); if (!($formatter = new \IntlDateFormatter($locale, $datetype, $timetype, $timezone, $calendar, $pattern))) { throw new \InvalidArgumentException(intl_get_error_message()); } return $formatter; }
public function testValidateUsingCountrySpecificLocale() { IntlTestHelper::requireFullIntl($this); \Locale::setDefault('fr_FR'); $existingLanguage = 'en'; $this->validator->validate($existingLanguage, new Language(array('message' => 'aMessage'))); $this->assertNoViolation(); }
public function testReverseTransformWithPrecision() { // Since we test against "de_AT", we need the full implementation IntlTestHelper::requireFullIntl($this); \Locale::setDefault('de_AT'); $transformer = new PercentToLocalizedStringTransformer(2); $this->assertEquals(0.1234, $transformer->reverseTransform('12,34')); }
public function testValidateUsingCountrySpecificLocale() { // in order to test with "en_GB" IntlTestHelper::requireFullIntl($this); \Locale::setDefault('en_GB'); $existingCountry = 'GB'; $this->validator->validate($existingCountry, new Country()); $this->assertNoViolation(); }
public function testValidateUsingCountrySpecificLocale() { // in order to test with "en_GB" IntlTestHelper::requireFullIntl($this); \Locale::setDefault('en_GB'); $existingCountry = 'GB'; $this->context->expects($this->never())->method('addViolation'); $this->validator->validate($existingCountry, new Country()); }
protected function setUp() { parent::setUp(); // Since we test against "de_AT", we need the full implementation IntlTestHelper::requireFullIntl($this); \Locale::setDefault('de_AT'); $this->dateTime = new \DateTime('2010-02-03 04:05:06 UTC'); $this->dateTimeWithoutSeconds = new \DateTime('2010-02-03 04:05:00 UTC'); }
public function testGetLocaleReturnsDefaultLocaleIfNotSet() { // in order to test with "pt_BR" IntlTestHelper::requireFullIntl($this); $translator = new IdentityTranslator(); \Locale::setDefault('en'); $this->assertEquals('en', $translator->getLocale()); \Locale::setDefault('pt_BR'); $this->assertEquals('pt_BR', $translator->getLocale()); }
public function testReverseTransformWithGrouping() { // Since we test against "de_AT", we need the full implementation IntlTestHelper::requireFullIntl($this); \Locale::setDefault('de_AT'); $transformer = new IntegerToLocalizedStringTransformer(null, true); $this->assertEquals(1234, $transformer->reverseTransform('1.234,5')); $this->assertEquals(12345, $transformer->reverseTransform('12.345,912')); $this->assertEquals(1234, $transformer->reverseTransform('1234,5')); $this->assertEquals(12345, $transformer->reverseTransform('12345,912')); }
public function testDatePatternFormatWithQuotedStrings() { // we test against "es_ES", so we need the full implementation IntlTestHelper::requireFullIntl($this); \Locale::setDefault('es_ES'); $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array( // EEEE, d 'de' MMMM 'de' y 'format' => \IntlDateFormatter::FULL, )); $view = $form->createView(); $this->assertEquals('{{ day }}{{ month }}{{ year }}', $view->vars['date_pattern']); }
public function testCountryChoiceTranslations() { IntlTestHelper::requireFullIntl($this); Locale::setDefault('fr'); $form = $this->factory->create(new PhoneNumberType(), null, array('widget' => PhoneNumberType::WIDGET_COUNTRY_CHOICE)); $view = $form->createView(); $choices = $view['country']->vars['choices']; $this->assertContains($this->createChoiceView('Royaume-Uni (+44)', 'GB'), $choices, '', false, false); $this->assertFalse($view['country']->vars['choice_translation_domain']); }
/** * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException * @expectedExceptionMessage The number contains unrecognized characters: "foo" */ public function testReverseTransformDisallowsTrailingExtraCharactersMultibyte() { if (!function_exists('mb_detect_encoding')) { $this->markTestSkipped('The "mbstring" extension is required for this test.'); } // Since we test against other locales, we need the full implementation IntlTestHelper::requireFullIntl($this); \Locale::setDefault('ru'); $transformer = new NumberToLocalizedStringTransformer(null, true); $transformer->reverseTransform("12 345,678foo"); }
protected function setUp() { IntlTestHelper::requireFullIntl($this); $this->reader = new IntlBundleReader(); }
public function testDatePatternFormatWithQuotedStrings() { // we test against "es_ES", so we need the full implementation IntlTestHelper::requireFullIntl($this); \Locale::setDefault('es_ES'); $form = $this->factory->create(DateType::class, null, ['format' => \IntlDateFormatter::FULL]); $view = $form->createView(); $this->assertEquals('{{ day }}{{ month }}{{ year }}', $view->vars['date_pattern']); }
protected function setUp() { IntlTestHelper::requireFullIntl($this, false); parent::setUp(); }
public function testGetDisplayCountriesForSwitzerland() { IntlTestHelper::requireFullIntl($this); $countries = Locale::getDisplayCountries('de_CH'); $this->assertEquals('Schweiz', $countries['CH']); }
public function testGetTextAttribute() { IntlTestHelper::requireFullIntl($this); parent::testGetTextAttribute(); }
/** * @dataProvider formatCurrencyWithCurrencyStyleSwissRoundingProvider */ public function testFormatCurrencyWithCurrencyStyleSwissRounding($value, $currency, $symbol, $expected) { IntlTestHelper::requireFullIntl($this); $formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY); $this->assertEquals(sprintf($expected, $symbol), $formatter->formatCurrency($value, $currency)); }
/** * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException * @expectedExceptionMessage The number contains unrecognized characters: "foo" */ public function testReverseTransformDisallowsTrailingExtraCharactersMultibyte() { // Since we test against other locales, we need the full implementation IntlTestHelper::requireFullIntl($this); \Locale::setDefault('ru'); $transformer = new NumberToLocalizedStringTransformer(null, true); $transformer->reverseTransform("12 345,678foo"); }