Skip to content

Commit

Permalink
Remove skipping of tests based on ICU data version whenever possible
Browse files Browse the repository at this point in the history
Many tests being skipped based on the ICU data version don't actually
need it. They might be testing code paths not relying on Intl, or not
performing assertions on the values depending on the ICU data and so not
dependant on the exact ICU version being used.
  • Loading branch information
stof committed Jul 30, 2015
1 parent 6b02601 commit 7994513
Show file tree
Hide file tree
Showing 19 changed files with 200 additions and 123 deletions.
Expand Up @@ -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);
}
Expand Down
Expand Up @@ -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'));
Expand All @@ -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'));
Expand Down
Expand Up @@ -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));
Expand All @@ -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'));
Expand Down
Expand Up @@ -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()
Expand All @@ -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();
Expand All @@ -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);
Expand All @@ -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));
Expand All @@ -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');

Expand All @@ -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();
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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
Expand All @@ -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);

Expand All @@ -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');
Expand All @@ -167,13 +202,21 @@ 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');
}

public function testDecimalSeparatorMayBeDotIfGroupingSeparatorIsDotButNoGroupingUsed()
{
// Since we test against other locales, we need the full implementation
IntlTestHelper::requireFullIntl($this);

\Locale::setDefault('fr');
$transformer = new NumberToLocalizedStringTransformer();

Expand All @@ -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);

Expand All @@ -200,7 +246,6 @@ public function testDecimalSeparatorMayBeCommaIfGroupingSeparatorIsNotComma()
*/
public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsComma()
{
\Locale::setDefault('en');
$transformer = new NumberToLocalizedStringTransformer(null, true);

$transformer->reverseTransform('1,234,5');
Expand All @@ -211,15 +256,13 @@ public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsComma()
*/
public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsCommaWithNoGroupSep()
{
\Locale::setDefault('en');
$transformer = new NumberToLocalizedStringTransformer(null, true);

$transformer->reverseTransform('1234,5');
}

public function testDecimalSeparatorMayBeCommaIfGroupingSeparatorIsCommaButNoGroupingUsed()
{
\Locale::setDefault('en');
$transformer = new NumberToLocalizedStringTransformer();

$this->assertEquals(1234.5, $transformer->reverseTransform('1234,5'));
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Expand Up @@ -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()
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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'));
Expand Down
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 7994513

Please sign in to comment.