Esempio n. 1
0
 protected function setUp()
 {
     // we test against different locales, so we need the full
     // implementation
     IntlTestHelper::requireFullIntl($this);
     parent::setUp();
 }
 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');
 }
Esempio n. 3
0
 /**
  * @dataProvider getValidCurrencies
  **/
 public function testValidCurrenciesWithCountrySpecificLocale($currency)
 {
     IntlTestHelper::requireFullIntl($this);
     \Locale::setDefault('en_GB');
     $this->validator->validate($currency, new Currency());
     $this->assertNoViolation();
 }
Esempio n. 4
0
 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()
 {
     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 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'));
 }
Esempio n. 7
0
 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();
 }
Esempio n. 8
0
 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 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'));
 }
Esempio n. 10
0
 public function testValidateUsingCountrySpecificLocale()
 {
     IntlTestHelper::requireFullIntl($this);
     \Locale::setDefault('fr_FR');
     $existingLanguage = 'en';
     $this->validator->validate($existingLanguage, new Language(array('message' => 'aMessage')));
     $this->assertNoViolation();
 }
 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');
 }
Esempio n. 12
0
 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());
 }
Esempio n. 14
0
 /**
  * @dataProvider buildFormProvider
  *
  * @param array  $configData
  * @param string $defaultLang
  * @param array  $choicesKeysExpected
  */
 public function testBuildForm(array $configData, $defaultLang, array $choicesKeysExpected)
 {
     IntlTestHelper::requireIntl($this);
     \Locale::setDefault($defaultLang);
     $this->cmMock->expects($this->at(0))->method('get')->with($this->equalTo(LanguageType::CONFIG_KEY), $this->equalTo(true))->will($this->returnValue($defaultLang));
     $this->cmMock->expects($this->at(1))->method('get')->with($this->equalTo(TranslationStatusInterface::CONFIG_KEY))->will($this->returnValue($configData));
     $form = $this->factory->create($this->formType);
     $choices = $form->getConfig()->getOption('choices');
     $this->assertEquals($choicesKeysExpected, array_keys($choices));
 }
 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'));
 }
 /**
  * @dataProvider provideInvalidComparisons
  * @param mixed  $dirtyValue
  * @param mixed  $dirtyValueAsString
  * @param mixed  $comparedValue
  * @param mixed  $comparedValueString
  * @param string $comparedValueType
  */
 public function testInvalidComparisonToValue($dirtyValue, $dirtyValueAsString, $comparedValue, $comparedValueString, $comparedValueType)
 {
     // Conversion of dates to string differs between ICU versions
     // Make sure we have the correct version loaded
     if ($dirtyValue instanceof \DateTime) {
         IntlTestHelper::requireIntl($this);
     }
     $constraint = $this->createConstraint(array('value' => $comparedValue));
     $constraint->message = 'Constraint Message';
     $this->validator->validate($dirtyValue, $constraint);
     $this->assertViolation('Constraint Message', array('{{ value }}' => $dirtyValueAsString, '{{ compared_value }}' => $comparedValueString, '{{ compared_value_type }}' => $comparedValueType));
 }
 /**
  * @dataProvider provideInvalidComparisons
  *
  * @param mixed  $dirtyValue
  * @param mixed  $dirtyValueAsString
  * @param mixed  $comparedValue
  * @param mixed  $comparedValueString
  * @param string $comparedValueType
  */
 public function testInvalidComparisonToValue($dirtyValue, $dirtyValueAsString, $comparedValue, $comparedValueString, $comparedValueType)
 {
     // Conversion of dates to string differs between ICU versions
     // Make sure we have the correct version loaded
     if ($dirtyValue instanceof \DateTime) {
         IntlTestHelper::requireIntl($this);
         if (PHP_VERSION_ID < 50304 && !(extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
             $this->markTestSkipped('Intl supports formatting DateTime objects since 5.3.4');
         }
     }
     $constraint = $this->createConstraint(array('value' => $comparedValue));
     $constraint->message = 'Constraint Message';
     $this->validator->validate($dirtyValue, $constraint);
     $this->buildViolation('Constraint Message')->setParameter('{{ value }}', $dirtyValueAsString)->setParameter('{{ compared_value }}', $comparedValueString)->setParameter('{{ compared_value_type }}', $comparedValueType)->assertRaised();
 }
Esempio n. 19
0
 protected function setUp()
 {
     IntlTestHelper::requireFullIntl($this, false);
     parent::setUp();
 }
Esempio n. 20
0
 public function testGetTextAttribute()
 {
     IntlTestHelper::requireFullIntl($this);
     parent::testGetTextAttribute();
 }
Esempio n. 21
0
 protected function setUp()
 {
     IntlTestHelper::requireIntl($this);
     parent::setUp();
 }
Esempio n. 22
0
 protected function setUp()
 {
     $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
     // Locale extends \Locale, so intl must be present
     IntlTestHelper::requireIntl($this);
 }
Esempio n. 23
0
    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']);
    }
Esempio n. 24
0
 protected function setUp()
 {
     // Locale extends \Locale, so intl must be present
     IntlTestHelper::requireIntl($this);
 }
 /**
  * If PHP is compiled in 64bit mode, the returned value for a 64bit integer are 32bit integer numbers.
  */
 public function testParseTypeInt64With64BitIntegerInPhp64Bit()
 {
     IntlTestHelper::require64Bit($this);
     $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
     $parsedValue = $formatter->parse('2,147,483,648', NumberFormatter::TYPE_INT64);
     $this->assertInternalType('integer', $parsedValue);
     $this->assertEquals(2147483648, $parsedValue, '->parse() TYPE_INT64 uses true 64 bit integers (PHP >= 5.3.14 and PHP >= 5.4.4).');
     $parsedValue = $formatter->parse('-2,147,483,649', NumberFormatter::TYPE_INT64);
     $this->assertInternalType('integer', $parsedValue);
     $this->assertEquals(-2147483649, $parsedValue, '->parse() TYPE_INT64 uses true 64 bit integers (PHP >= 5.3.14 and PHP >= 5.4.4).');
 }
 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']);
 }
 /**
  * If PHP is compiled in 64bit mode, the returned value for a 64bit integer are 32bit integer numbers.
  */
 public function testParseTypeInt64With64BitIntegerInPhp64Bit()
 {
     IntlTestHelper::require64Bit($this);
     $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
     $parsedValue = $formatter->parse('2,147,483,648', NumberFormatter::TYPE_INT64);
     $this->assertInternalType('integer', $parsedValue);
     // Bug #59597 was fixed on PHP 5.3.14 and 5.4.4
     // A 32 bit integer was being generated instead of a 64 bit integer
     if (version_compare(PHP_VERSION, '5.3.14', '<') || version_compare(PHP_VERSION, '5.4.0', '>=') && version_compare(PHP_VERSION, '5.4.4', '<')) {
         $this->assertEquals(-2147483648, $parsedValue, '->parse() TYPE_INT64 does not use true 64 bit integers, using only the 32 bit range (PHP < 5.3.14 and PHP < 5.4.4).');
     } else {
         $this->assertEquals(2147483648, $parsedValue, '->parse() TYPE_INT64 uses true 64 bit integers (PHP >= 5.3.14 and PHP >= 5.4.4).');
     }
     $parsedValue = $formatter->parse('-2,147,483,649', NumberFormatter::TYPE_INT64);
     $this->assertInternalType('integer', $parsedValue);
     // Bug #59597 was fixed on PHP 5.3.14 and 5.4.4
     // A 32 bit integer was being generated instead of a 64 bit integer
     if (version_compare(PHP_VERSION, '5.3.14', '<') || version_compare(PHP_VERSION, '5.4.0', '>=') && version_compare(PHP_VERSION, '5.4.4', '<')) {
         $this->assertEquals(2147483647, $parsedValue, '->parse() TYPE_INT64 does not use true 64 bit integers, using only the 32 bit range  (PHP < 5.3.14 and PHP < 5.4.4).');
     } else {
         $this->assertEquals(-2147483649, $parsedValue, '->parse() TYPE_INT64 uses true 64 bit integers (PHP >= 5.3.14 and PHP >= 5.4.4).');
     }
 }
 protected function setUp()
 {
     IntlTestHelper::requireFullIntl($this);
     $this->reader = new IntlBundleReader();
 }
 /**
  * @dataProvider getSoonerThanTenthMarch2014
  */
 public function testInvalidDatesCombinedMin($value, $dateTimeAsString)
 {
     // Conversion of dates to string differs between ICU versions
     // Make sure we have the correct version loaded
     IntlTestHelper::requireIntl($this);
     $constraint = new Range(array('min' => 'March 10, 2014', 'max' => 'March 20, 2014', 'minMessage' => 'myMinMessage', 'maxMessage' => 'myMaxMessage'));
     $this->validator->validate($value, $constraint);
     $this->buildViolation('myMinMessage')->setParameter('{{ value }}', $dateTimeAsString)->setParameter('{{ limit }}', 'Mar 10, 2014, 12:00 AM')->setCode(Range::BELOW_RANGE_ERROR)->assertRaised();
 }
 /**
  * @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");
 }