diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php index d6964d395ab1..3816b66c6b7d 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php @@ -170,9 +170,11 @@ public function testTransformWrapsIntlErrors() { $transformer = new DateTimeToLocalizedStringTransformer(); + $this->markTestIncomplete('Checking for intl errors needs to be reimplemented'); + // HOW TO REPRODUCE? - //$this->setExpectedException('Symfony\Component\Form\Extension\Core\DataTransformer\Transdate_formationFailedException'); + //$this->setExpectedException('Symfony\Component\Form\Extension\Core\DataTransformer\TransformationFailedException'); //$transformer->transform(1.5); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php index a90fa91bb05f..48146036121f 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php @@ -20,14 +20,16 @@ protected function setUp() { parent::setUp(); + \Locale::setDefault('en'); + } + + public function testReverseTransform() + { // Since we test against "de_AT", we need the full implementation IntlTestHelper::requireFullIntl($this); \Locale::setDefault('de_AT'); - } - public function testReverseTransform() - { $transformer = new IntegerToLocalizedStringTransformer(); $this->assertEquals(1, $transformer->reverseTransform('1')); @@ -45,6 +47,11 @@ public function testReverseTransformEmpty() 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')); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php index 8b91fe10a2df..99e4c8a574cf 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php @@ -16,18 +16,13 @@ class MoneyToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase { - protected function setUp() + public function testTransform() { - parent::setUp(); - // Since we test against "de_AT", we need the full implementation IntlTestHelper::requireFullIntl($this); \Locale::setDefault('de_AT'); - } - public function testTransform() - { $transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100); $this->assertEquals('1,23', $transformer->transform(123)); @@ -51,6 +46,11 @@ public function testTransformEmpty() public function testReverseTransform() { + // Since we test against "de_AT", we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + $transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100); $this->assertEquals(123, $transformer->reverseTransform('1,23')); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php index 871c88af70ec..3bb7247a342b 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php @@ -20,10 +20,7 @@ protected function setUp() { parent::setUp(); - // Since we test against "de_AT", we need the full implementation - IntlTestHelper::requireFullIntl($this); - - \Locale::setDefault('de_AT'); + \Locale::setDefault('en'); } public function provideTransformations() @@ -44,6 +41,9 @@ public function provideTransformations() */ public function testTransform($from, $to, $locale) { + // Since we test against other locales, we need the full implementation + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault($locale); $transformer = new NumberToLocalizedStringTransformer(); @@ -67,6 +67,9 @@ public function provideTransformationsWithGrouping() */ public function testTransformWithGrouping($from, $to, $locale) { + // Since we test against other locales, we need the full implementation + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault($locale); $transformer = new NumberToLocalizedStringTransformer(null, true); @@ -76,6 +79,11 @@ public function testTransformWithGrouping($from, $to, $locale) public function testTransformWithPrecision() { + // Since we test against "de_AT", we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + $transformer = new NumberToLocalizedStringTransformer(2); $this->assertEquals('1234,50', $transformer->transform(1234.5)); @@ -84,6 +92,11 @@ public function testTransformWithPrecision() public function testTransformWithRoundingMode() { + // Since we test against "de_AT", we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + $transformer = new NumberToLocalizedStringTransformer(null, null, NumberToLocalizedStringTransformer::ROUND_DOWN); $this->assertEquals('1234,547', $transformer->transform(1234.547), '->transform() only applies rounding mode if precision set'); @@ -96,6 +109,9 @@ public function testTransformWithRoundingMode() */ public function testReverseTransform($to, $from, $locale) { + // Since we test against other locales, we need the full implementation + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault($locale); $transformer = new NumberToLocalizedStringTransformer(); @@ -108,6 +124,9 @@ public function testReverseTransform($to, $from, $locale) */ public function testReverseTransformWithGrouping($to, $from, $locale) { + // Since we test against other locales, we need the full implementation + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault($locale); $transformer = new NumberToLocalizedStringTransformer(null, true); @@ -122,6 +141,9 @@ public function testReverseTransformWithGroupingAndFixedSpaces() $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); @@ -131,6 +153,11 @@ public function testReverseTransformWithGroupingAndFixedSpaces() public function testReverseTransformWithGroupingButWithoutGroupSeparator() { + // Since we test against "de_AT", we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + $transformer = new NumberToLocalizedStringTransformer(null, true); // omit group separator @@ -140,6 +167,9 @@ public function testReverseTransformWithGroupingButWithoutGroupSeparator() public function testDecimalSeparatorMayBeDotIfGroupingSeparatorIsNotDot() { + // Since we test against other locales, we need the full implementation + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault('fr'); $transformer = new NumberToLocalizedStringTransformer(null, true); @@ -157,6 +187,11 @@ public function testDecimalSeparatorMayBeDotIfGroupingSeparatorIsNotDot() */ public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDot() { + // Since we test against "de_AT", we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + $transformer = new NumberToLocalizedStringTransformer(null, true); $transformer->reverseTransform('1.234.5'); @@ -167,6 +202,11 @@ public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDot() */ public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDotWithNoGroupSep() { + // Since we test against "de_AT", we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + $transformer = new NumberToLocalizedStringTransformer(null, true); $transformer->reverseTransform('1234.5'); @@ -174,6 +214,9 @@ public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDotWithNoGro public function testDecimalSeparatorMayBeDotIfGroupingSeparatorIsDotButNoGroupingUsed() { + // Since we test against other locales, we need the full implementation + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault('fr'); $transformer = new NumberToLocalizedStringTransformer(); @@ -183,6 +226,9 @@ public function testDecimalSeparatorMayBeDotIfGroupingSeparatorIsDotButNoGroupin public function testDecimalSeparatorMayBeCommaIfGroupingSeparatorIsNotComma() { + // Since we test against other locales, we need the full implementation + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault('bg'); $transformer = new NumberToLocalizedStringTransformer(null, true); @@ -200,7 +246,6 @@ public function testDecimalSeparatorMayBeCommaIfGroupingSeparatorIsNotComma() */ public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsComma() { - \Locale::setDefault('en'); $transformer = new NumberToLocalizedStringTransformer(null, true); $transformer->reverseTransform('1,234,5'); @@ -211,7 +256,6 @@ public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsComma() */ public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsCommaWithNoGroupSep() { - \Locale::setDefault('en'); $transformer = new NumberToLocalizedStringTransformer(null, true); $transformer->reverseTransform('1234,5'); @@ -219,7 +263,6 @@ public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsCommaWithN public function testDecimalSeparatorMayBeCommaIfGroupingSeparatorIsCommaButNoGroupingUsed() { - \Locale::setDefault('en'); $transformer = new NumberToLocalizedStringTransformer(); $this->assertEquals(1234.5, $transformer->reverseTransform('1234,5')); @@ -339,6 +382,9 @@ public function testReverseTransformDisallowsCenteredExtraCharactersMultibyte() $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); @@ -356,6 +402,9 @@ public function testReverseTransformIgnoresTrailingSpacesInExceptionMessage() $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); @@ -384,6 +433,9 @@ public function testReverseTransformDisallowsTrailingExtraCharactersMultibyte() $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); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php index 104941c9b350..ce972774a1ff 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php @@ -20,10 +20,7 @@ protected function setUp() { parent::setUp(); - // Since we test against "de_AT", we need the full implementation - IntlTestHelper::requireFullIntl($this); - - \Locale::setDefault('de_AT'); + \Locale::setDefault('en'); } public function testTransform() @@ -55,6 +52,11 @@ public function testTransformWithInteger() public function testTransformWithPrecision() { + // Since we test against "de_AT", we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + $transformer = new PercentToLocalizedStringTransformer(2); $this->assertEquals('12,34', $transformer->transform(0.1234)); @@ -89,6 +91,11 @@ public function testReverseTransformWithInteger() 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')); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php index 8f51e2607ca1..fc003a07d34b 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php @@ -13,13 +13,12 @@ use Symfony\Component\Form\FormError; use Symfony\Component\Form\Test\TypeTestCase as TestCase; -use Symfony\Component\Intl\Util\IntlTestHelper; class DateTimeTypeTest extends TestCase { protected function setUp() { - IntlTestHelper::requireIntl($this); + \Locale::setDefault('en'); parent::setUp(); } @@ -271,16 +270,6 @@ public function testInitializeWithDateTime() $this->factory->create('datetime', new \DateTime()); } - public function testSingleTextWidgetShouldUseTheRightInputType() - { - $form = $this->factory->create('datetime', null, array( - 'widget' => 'single_text', - )); - - $view = $form->createView(); - $this->assertEquals('datetime', $view->vars['type']); - } - public function testPassDefaultEmptyValueToViewIfNotRequired() { $form = $this->factory->create('datetime', null, array( diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php index e5aba86efe76..6835ce882055 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php @@ -22,10 +22,7 @@ protected function setUp() { parent::setUp(); - // we test against "de_AT", so we need the full implementation - IntlTestHelper::requireFullIntl($this); - - \Locale::setDefault('de_AT'); + \Locale::setDefault('en'); } /** @@ -65,6 +62,11 @@ public function testSubmitFromSingleTextDateTimeWithDefaultFormat() public function testSubmitFromSingleTextDateTime() { + // we test against "de_AT", so we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + $form = $this->factory->create('date', null, array( 'format' => \IntlDateFormatter::MEDIUM, 'model_timezone' => 'UTC', @@ -81,6 +83,11 @@ public function testSubmitFromSingleTextDateTime() public function testSubmitFromSingleTextString() { + // we test against "de_AT", so we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + $form = $this->factory->create('date', null, array( 'format' => \IntlDateFormatter::MEDIUM, 'model_timezone' => 'UTC', @@ -97,6 +104,11 @@ public function testSubmitFromSingleTextString() public function testSubmitFromSingleTextTimestamp() { + // we test against "de_AT", so we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + $form = $this->factory->create('date', null, array( 'format' => \IntlDateFormatter::MEDIUM, 'model_timezone' => 'UTC', @@ -115,6 +127,11 @@ public function testSubmitFromSingleTextTimestamp() public function testSubmitFromSingleTextRaw() { + // we test against "de_AT", so we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + $form = $this->factory->create('date', null, array( 'format' => \IntlDateFormatter::MEDIUM, 'model_timezone' => 'UTC', @@ -373,6 +390,11 @@ public function testThrowExceptionIfDaysIsInvalid() public function testSetDataWithDifferentTimezones() { + // we test against "de_AT", so we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + $form = $this->factory->create('date', null, array( 'format' => \IntlDateFormatter::MEDIUM, 'model_timezone' => 'America/New_York', @@ -388,6 +410,11 @@ public function testSetDataWithDifferentTimezones() public function testSetDataWithDifferentTimezonesDateTime() { + // we test against "de_AT", so we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + $form = $this->factory->create('date', null, array( 'format' => \IntlDateFormatter::MEDIUM, 'model_timezone' => 'America/New_York', @@ -422,18 +449,24 @@ public function testMonthsOption() { $form = $this->factory->create('date', null, array( 'months' => array(6, 7), + 'format' => \IntlDateFormatter::SHORT, )); $view = $form->createView(); $this->assertEquals(array( - new ChoiceView('6', '6', '06'), - new ChoiceView('7', '7', '07'), + new ChoiceView(6, '6', '06'), + new ChoiceView(7, '7', '07'), ), $view['month']->vars['choices']); } public function testMonthsOptionShortFormat() { + // we test against "de_AT", so we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + $form = $this->factory->create('date', null, array( 'months' => array(1, 4), 'format' => 'dd.MMM.yy', @@ -442,13 +475,18 @@ public function testMonthsOptionShortFormat() $view = $form->createView(); $this->assertEquals(array( - new ChoiceView('1', '1', 'Jän'), - new ChoiceView('4', '4', 'Apr.'), + new ChoiceView(1, '1', 'Jän'), + new ChoiceView(4, '4', 'Apr.'), ), $view['month']->vars['choices']); } public function testMonthsOptionLongFormat() { + // we test against "de_AT", so we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + $form = $this->factory->create('date', null, array( 'months' => array(1, 4), 'format' => 'dd.MMMM.yy', @@ -457,13 +495,18 @@ public function testMonthsOptionLongFormat() $view = $form->createView(); $this->assertEquals(array( - new ChoiceView('1', '1', 'Jänner'), - new ChoiceView('4', '4', 'April'), + new ChoiceView(1, '1', 'Jänner'), + new ChoiceView(4, '4', 'April'), ), $view['month']->vars['choices']); } public function testMonthsOptionLongFormatWithDifferentTimezone() { + // we test against "de_AT", so we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + $form = $this->factory->create('date', null, array( 'months' => array(1, 4), 'format' => 'dd.MMMM.yy', @@ -472,8 +515,8 @@ public function testMonthsOptionLongFormatWithDifferentTimezone() $view = $form->createView(); $this->assertEquals(array( - new ChoiceView('1', '1', 'Jänner'), - new ChoiceView('4', '4', 'April'), + new ChoiceView(1, '1', 'Jänner'), + new ChoiceView(4, '4', 'April'), ), $view['month']->vars['choices']); } @@ -486,8 +529,8 @@ public function testIsDayWithinRangeReturnsTrueIfWithin() $view = $form->createView(); $this->assertEquals(array( - new ChoiceView('6', '6', '06'), - new ChoiceView('7', '7', '07'), + new ChoiceView(6, '6', '06'), + new ChoiceView(7, '7', '07'), ), $view['day']->vars['choices']); } @@ -565,6 +608,11 @@ public function testIsPartiallyFilledReturnsTrueIfChoiceAndDayEmpty() public function testPassDatePatternToView() { + // we test against "de_AT", so we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + $form = $this->factory->create('date'); $view = $form->createView(); @@ -573,6 +621,11 @@ public function testPassDatePatternToView() public function testPassDatePatternToViewDifferentFormat() { + // we test against "de_AT", so we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + $form = $this->factory->create('date', null, array( 'format' => \IntlDateFormatter::LONG, )); @@ -616,6 +669,9 @@ public function testDontPassDatePatternIfText() 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('date', null, array( @@ -646,16 +702,6 @@ public function testInitializeWithDateTime() $this->factory->create('date', new \DateTime()); } - public function testSingleTextWidgetShouldUseTheRightInputType() - { - $form = $this->factory->create('date', null, array( - 'widget' => 'single_text', - )); - - $view = $form->createView(); - $this->assertEquals('date', $view->vars['type']); - } - public function testPassDefaultEmptyValueToViewIfNotRequired() { $form = $this->factory->create('date', null, array( diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php index 087d4c171e88..bf12cefdccbe 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php @@ -14,17 +14,9 @@ use Symfony\Component\Form\Extension\Core\View\ChoiceView; use Symfony\Component\Form\FormError; use Symfony\Component\Form\Test\TypeTestCase as TestCase; -use Symfony\Component\Intl\Util\IntlTestHelper; class TimeTypeTest extends TestCase { - protected function setUp() - { - IntlTestHelper::requireIntl($this); - - parent::setUp(); - } - public function testSubmitDateTime() { $form = $this->factory->create('time', null, array( diff --git a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php index 3346570105a2..f7284c3d7c2e 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php @@ -12,7 +12,7 @@ namespace Symfony\Component\Intl\Tests\Data\Bundle\Reader; use Symfony\Component\Intl\Data\Bundle\Reader\IntlBundleReader; -use Symfony\Component\Intl\Util\IntlTestHelper; +use Symfony\Component\Intl\Intl; /** * @author Bernhard Schussek @@ -26,7 +26,10 @@ class IntlBundleReaderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - IntlTestHelper::requireFullIntl($this); + // We only run tests if the intl extension is loaded... + if (!Intl::isExtensionLoaded()) { + $this->markTestSkipped('The intl extension is not available.'); + } $this->reader = new IntlBundleReader(); } @@ -52,6 +55,14 @@ public function testReadFollowsAlias() public function testReadDoesNotFollowFallback() { + if (PHP_VERSION_ID < 50307 || PHP_VERSION_ID === 50400) { + $this->markTestSkipped('ResourceBundle handles disabling fallback properly only as of PHP 5.3.7 and 5.4.1.'); + } + + if (defined('HHVM_VERSION')) { + $this->markTestSkipped('ResourceBundle does not support disabling fallback properly on HHVM.'); + } + // "ro_MD" -> "ro" $data = $this->reader->read(__DIR__.'/Fixtures/res', 'ro_MD'); @@ -64,6 +75,14 @@ public function testReadDoesNotFollowFallback() public function testReadDoesNotFollowFallbackAlias() { + if (PHP_VERSION_ID < 50307 || PHP_VERSION_ID === 50400) { + $this->markTestSkipped('ResourceBundle handles disabling fallback properly only as of PHP 5.3.7 and 5.4.1.'); + } + + if (defined('HHVM_VERSION')) { + $this->markTestSkipped('ResourceBundle does not support disabling fallback properly on HHVM.'); + } + // "mo" = "ro_MD" -> "ro" $data = $this->reader->read(__DIR__.'/Fixtures/res', 'mo'); diff --git a/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/JsonBundleWriterTest.php b/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/JsonBundleWriterTest.php index c449cf82db6f..5cf92a54e4d3 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/JsonBundleWriterTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/JsonBundleWriterTest.php @@ -13,7 +13,7 @@ use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Intl\Data\Bundle\Writer\JsonBundleWriter; -use Symfony\Component\Intl\Util\IntlTestHelper; +use Symfony\Component\Intl\Intl; /** * @author Bernhard Schussek @@ -74,7 +74,10 @@ public function testWrite() public function testWriteResourceBundle() { - IntlTestHelper::requireFullIntl($this); + // We only run tests if the intl extension is loaded... + if (!Intl::isExtensionLoaded()) { + $this->markTestSkipped('The intl extension is not available.'); + } $bundle = new \ResourceBundle('rb', __DIR__.'/Fixtures', false); diff --git a/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/PhpBundleWriterTest.php b/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/PhpBundleWriterTest.php index a855fbffefd3..efc3519e3a7b 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/PhpBundleWriterTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/PhpBundleWriterTest.php @@ -13,7 +13,7 @@ use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Intl\Data\Bundle\Writer\PhpBundleWriter; -use Symfony\Component\Intl\Util\IntlTestHelper; +use Symfony\Component\Intl\Intl; /** * @author Bernhard Schussek @@ -66,7 +66,14 @@ public function testWrite() public function testWriteResourceBundle() { - IntlTestHelper::requireFullIntl($this); + // We only run tests if the intl extension is loaded... + if (!Intl::isExtensionLoaded()) { + $this->markTestSkipped('The intl extension is not available.'); + } + + if (PHP_VERSION_ID < 50315 || (PHP_VERSION_ID >= 50400 && PHP_VERSION_ID < 50404)) { + $this->markTestSkipped('ResourceBundle implements Traversable only as of PHP 5.3.15 and 5.4.4'); + } $bundle = new \ResourceBundle('rb', __DIR__.'/Fixtures', false); diff --git a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php index a2b90324f514..5585255ebf85 100644 --- a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php @@ -56,8 +56,6 @@ public function formatCurrencyWithDecimalStyleProvider() */ public function testFormatCurrencyWithCurrencyStyle($value, $currency, $expected) { - IntlTestHelper::requireFullIntl($this); - $formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY); $this->assertEquals($expected, $formatter->formatCurrency($value, $currency)); } @@ -84,8 +82,6 @@ public function formatCurrencyWithCurrencyStyleProvider() */ public function testFormatCurrencyWithCurrencyStyleCostaRicanColonsRounding($value, $currency, $symbol, $expected) { - IntlTestHelper::requireFullIntl($this); - $formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY); $this->assertEquals(sprintf($expected, $symbol), $formatter->formatCurrency($value, $currency)); } @@ -104,8 +100,6 @@ public function formatCurrencyWithCurrencyStyleCostaRicanColonsRoundingProvider( */ public function testFormatCurrencyWithCurrencyStyleBrazilianRealRounding($value, $currency, $symbol, $expected) { - IntlTestHelper::requireFullIntl($this); - $formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY); $this->assertEquals(sprintf($expected, $symbol), $formatter->formatCurrency($value, $currency)); } @@ -133,8 +127,6 @@ public function formatCurrencyWithCurrencyStyleBrazilianRealRoundingProvider() */ 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)); } diff --git a/src/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php b/src/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php index 519e753bd5be..6f2d2fdeef4a 100644 --- a/src/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php @@ -13,7 +13,6 @@ use Symfony\Component\Intl\Globals\IntlGlobals; use Symfony\Component\Intl\NumberFormatter\NumberFormatter; -use Symfony\Component\Intl\Util\IntlTestHelper; /** * Note that there are some values written like -2147483647 - 1. This is the lower 32bit int max and is a known @@ -21,13 +20,6 @@ */ class NumberFormatterTest extends AbstractNumberFormatterTest { - protected function setUp() - { - IntlTestHelper::requireIntl($this); - - parent::setUp(); - } - /** * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException */ diff --git a/src/Symfony/Component/Locale/Tests/LocaleTest.php b/src/Symfony/Component/Locale/Tests/LocaleTest.php index 9eb353438447..122529ba6ef0 100644 --- a/src/Symfony/Component/Locale/Tests/LocaleTest.php +++ b/src/Symfony/Component/Locale/Tests/LocaleTest.php @@ -11,7 +11,6 @@ namespace Symfony\Component\Locale\Tests; -use Symfony\Component\Intl\Util\IntlTestHelper; use Symfony\Component\Locale\Locale; /** @@ -25,8 +24,7 @@ protected function setUp() { $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - // Locale extends \Locale, so intl must be present - IntlTestHelper::requireIntl($this); + \Locale::setDefault('en'); } public function testGetDisplayCountries() diff --git a/src/Symfony/Component/Locale/Tests/Stub/StubLocaleTest.php b/src/Symfony/Component/Locale/Tests/Stub/StubLocaleTest.php index 44b5ab7961ca..a2cb3b5b317b 100644 --- a/src/Symfony/Component/Locale/Tests/Stub/StubLocaleTest.php +++ b/src/Symfony/Component/Locale/Tests/Stub/StubLocaleTest.php @@ -11,7 +11,6 @@ namespace Symfony\Component\Locale\Tests\Stub; -use Symfony\Component\Intl\Util\IntlTestHelper; use Symfony\Component\Locale\Stub\StubLocale; /** @@ -22,9 +21,6 @@ class StubLocaleTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - // Locale extends \Locale, so intl must be present - IntlTestHelper::requireIntl($this); } public function testGetCurrenciesData() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php index 2a435a287a21..57d5be77131c 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php @@ -17,13 +17,6 @@ class CountryValidatorTest extends AbstractConstraintValidatorTest { - protected function setUp() - { - IntlTestHelper::requireFullIntl($this); - - parent::setUp(); - } - protected function createValidator() { return new CountryValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php index 9d26a6f5d105..1d87c8a1b7b0 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php @@ -17,13 +17,6 @@ class CurrencyValidatorTest extends AbstractConstraintValidatorTest { - protected function setUp() - { - IntlTestHelper::requireFullIntl($this); - - parent::setUp(); - } - protected function createValidator() { return new CurrencyValidator(); @@ -66,6 +59,8 @@ public function testValidCurrencies($currency) **/ public function testValidCurrenciesWithCountrySpecificLocale($currency) { + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault('en_GB'); $this->validator->validate($currency, new Currency()); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php index a9197970be07..0441831ab9ba 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php @@ -22,13 +22,6 @@ protected function createValidator() return new LanguageValidator(); } - protected function setUp() - { - IntlTestHelper::requireFullIntl($this); - - parent::setUp(); - } - public function testNullIsValid() { $this->validator->validate(null, new Language()); @@ -96,6 +89,8 @@ public function getInvalidLanguages() public function testValidateUsingCountrySpecificLocale() { + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault('fr_FR'); $existingLanguage = 'en'; diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php index f9bfcab95128..e93ee80e5277 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php @@ -11,7 +11,6 @@ namespace Symfony\Component\Validator\Tests\Constraints; -use Symfony\Component\Intl\Util\IntlTestHelper; use Symfony\Component\Validator\Constraints\Locale; use Symfony\Component\Validator\Constraints\LocaleValidator; @@ -22,13 +21,6 @@ protected function createValidator() return new LocaleValidator(); } - protected function setUp() - { - IntlTestHelper::requireIntl($this); - - parent::setUp(); - } - public function testNullIsValid() { $this->validator->validate(null, new Locale());