minor #20551 [ci] Testing with UTC hides bugs (nicolas-grekas)

This PR was merged into the 2.7 branch.

Discussion
----------

[ci] Testing with UTC hides bugs

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

As shown by #20550, we're having bugs because we don't in proper TZ conditions.
Let's do Europe on Travis, and America on Windows.

Commits
-------

e0f9bda [ci] Testing with UTC hides bugs
This commit is contained in:
Nicolas Grekas 2016-11-18 15:46:21 -05:00
commit e968d0ff5d
26 changed files with 72 additions and 75 deletions

View File

@ -47,6 +47,7 @@ before_install:
# A sigchild-enabled-PHP is used to test the Process component on the lowest PHP matrix line # A sigchild-enabled-PHP is used to test the Process component on the lowest PHP matrix line
- if [[ ! $deps && $PHP = ${MIN_PHP%.*} && ! -d php-$MIN_PHP/sapi ]]; then wget http://museum.php.net/php5/php-$MIN_PHP.tar.bz2 -O - | tar -xj; (cd php-$MIN_PHP; ./configure --enable-sigchild --enable-pcntl; make -j2); fi - if [[ ! $deps && $PHP = ${MIN_PHP%.*} && ! -d php-$MIN_PHP/sapi ]]; then wget http://museum.php.net/php5/php-$MIN_PHP.tar.bz2 -O - | tar -xj; (cd php-$MIN_PHP; ./configure --enable-sigchild --enable-pcntl; make -j2); fi
- if [[ ! $PHP = hhvm* ]]; then INI_FILE=~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; else INI_FILE=/etc/hhvm/php.ini; fi - if [[ ! $PHP = hhvm* ]]; then INI_FILE=~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; else INI_FILE=/etc/hhvm/php.ini; fi
- if [[ ! $skip ]]; then echo date.timezone = Europe/Paris >> $INI_FILE; fi
- if [[ ! $skip ]]; then echo memory_limit = -1 >> $INI_FILE; fi - if [[ ! $skip ]]; then echo memory_limit = -1 >> $INI_FILE; fi
- if [[ ! $skip ]]; then echo session.gc_probability = 0 >> $INI_FILE; fi - if [[ ! $skip ]]; then echo session.gc_probability = 0 >> $INI_FILE; fi
- if [[ ! $skip && $PHP = 5.* ]]; then echo extension = mongo.so >> $INI_FILE; fi - if [[ ! $skip && $PHP = 5.* ]]; then echo extension = mongo.so >> $INI_FILE; fi

View File

@ -33,7 +33,7 @@ install:
- cd .. - cd ..
- copy /Y php.ini-development php.ini-min - copy /Y php.ini-development php.ini-min
- echo max_execution_time=1200 >> php.ini-min - echo max_execution_time=1200 >> php.ini-min
- echo date.timezone="UTC" >> php.ini-min - echo date.timezone="America/Los_Angeles" >> php.ini-min
- echo extension_dir=ext >> php.ini-min - echo extension_dir=ext >> php.ini-min
- copy /Y php.ini-min php.ini-max - copy /Y php.ini-min php.ini-max
- echo extension=php_openssl.dll >> php.ini-max - echo extension=php_openssl.dll >> php.ini-max

View File

@ -87,7 +87,7 @@ class IntegerToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCas
public function testReverseTransform() public function testReverseTransform()
{ {
// Since we test against "de_AT", we need the full implementation // Since we test against "de_AT", we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('de_AT'); \Locale::setDefault('de_AT');
@ -109,7 +109,7 @@ class IntegerToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCas
public function testReverseTransformWithGrouping() public function testReverseTransformWithGrouping()
{ {
// Since we test against "de_AT", we need the full implementation // Since we test against "de_AT", we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('de_AT'); \Locale::setDefault('de_AT');

View File

@ -19,7 +19,7 @@ class MoneyToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase
public function testTransform() public function testTransform()
{ {
// Since we test against "de_AT", we need the full implementation // Since we test against "de_AT", we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('de_AT'); \Locale::setDefault('de_AT');
@ -47,7 +47,7 @@ class MoneyToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase
public function testReverseTransform() public function testReverseTransform()
{ {
// Since we test against "de_AT", we need the full implementation // Since we test against "de_AT", we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('de_AT'); \Locale::setDefault('de_AT');

View File

@ -42,7 +42,7 @@ class NumberToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase
public function testTransform($from, $to, $locale) public function testTransform($from, $to, $locale)
{ {
// Since we test against other locales, we need the full implementation // Since we test against other locales, we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault($locale); \Locale::setDefault($locale);
@ -68,7 +68,7 @@ class NumberToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase
public function testTransformWithGrouping($from, $to, $locale) public function testTransformWithGrouping($from, $to, $locale)
{ {
// Since we test against other locales, we need the full implementation // Since we test against other locales, we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault($locale); \Locale::setDefault($locale);
@ -80,7 +80,7 @@ class NumberToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase
public function testTransformWithScale() public function testTransformWithScale()
{ {
// Since we test against "de_AT", we need the full implementation // Since we test against "de_AT", we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('de_AT'); \Locale::setDefault('de_AT');
@ -185,7 +185,7 @@ class NumberToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase
public function testTransformWithRounding($scale, $input, $output, $roundingMode) public function testTransformWithRounding($scale, $input, $output, $roundingMode)
{ {
// Since we test against "de_AT", we need the full implementation // Since we test against "de_AT", we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('de_AT'); \Locale::setDefault('de_AT');
@ -197,7 +197,7 @@ class NumberToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase
public function testTransformDoesNotRoundIfNoScale() public function testTransformDoesNotRoundIfNoScale()
{ {
// Since we test against "de_AT", we need the full implementation // Since we test against "de_AT", we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('de_AT'); \Locale::setDefault('de_AT');
@ -212,7 +212,7 @@ class NumberToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase
public function testReverseTransform($to, $from, $locale) public function testReverseTransform($to, $from, $locale)
{ {
// Since we test against other locales, we need the full implementation // Since we test against other locales, we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault($locale); \Locale::setDefault($locale);
@ -227,7 +227,7 @@ class NumberToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase
public function testReverseTransformWithGrouping($to, $from, $locale) public function testReverseTransformWithGrouping($to, $from, $locale)
{ {
// Since we test against other locales, we need the full implementation // Since we test against other locales, we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault($locale); \Locale::setDefault($locale);
@ -244,7 +244,7 @@ class NumberToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase
public function testReverseTransformWithGroupingAndFixedSpaces() public function testReverseTransformWithGroupingAndFixedSpaces()
{ {
// Since we test against other locales, we need the full implementation // Since we test against other locales, we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('ru'); \Locale::setDefault('ru');
@ -256,7 +256,7 @@ class NumberToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase
public function testReverseTransformWithGroupingButWithoutGroupSeparator() public function testReverseTransformWithGroupingButWithoutGroupSeparator()
{ {
// Since we test against "de_AT", we need the full implementation // Since we test against "de_AT", we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('de_AT'); \Locale::setDefault('de_AT');
@ -376,7 +376,7 @@ class NumberToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase
public function testDecimalSeparatorMayBeDotIfGroupingSeparatorIsNotDot() public function testDecimalSeparatorMayBeDotIfGroupingSeparatorIsNotDot()
{ {
// Since we test against other locales, we need the full implementation // Since we test against other locales, we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('fr'); \Locale::setDefault('fr');
$transformer = new NumberToLocalizedStringTransformer(null, true); $transformer = new NumberToLocalizedStringTransformer(null, true);
@ -396,7 +396,7 @@ class NumberToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase
public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDot() public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDot()
{ {
// Since we test against "de_AT", we need the full implementation // Since we test against "de_AT", we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('de_AT'); \Locale::setDefault('de_AT');
@ -411,7 +411,7 @@ class NumberToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase
public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDotWithNoGroupSep() public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDotWithNoGroupSep()
{ {
// Since we test against "de_AT", we need the full implementation // Since we test against "de_AT", we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('de_AT'); \Locale::setDefault('de_AT');
@ -423,7 +423,7 @@ class NumberToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase
public function testDecimalSeparatorMayBeDotIfGroupingSeparatorIsDotButNoGroupingUsed() public function testDecimalSeparatorMayBeDotIfGroupingSeparatorIsDotButNoGroupingUsed()
{ {
// Since we test against other locales, we need the full implementation // Since we test against other locales, we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('fr'); \Locale::setDefault('fr');
$transformer = new NumberToLocalizedStringTransformer(); $transformer = new NumberToLocalizedStringTransformer();
@ -435,7 +435,7 @@ class NumberToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase
public function testDecimalSeparatorMayBeCommaIfGroupingSeparatorIsNotComma() public function testDecimalSeparatorMayBeCommaIfGroupingSeparatorIsNotComma()
{ {
// Since we test against other locales, we need the full implementation // Since we test against other locales, we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('bg'); \Locale::setDefault('bg');
$transformer = new NumberToLocalizedStringTransformer(null, true); $transformer = new NumberToLocalizedStringTransformer(null, true);
@ -588,7 +588,7 @@ class NumberToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase
public function testReverseTransformDisallowsCenteredExtraCharactersMultibyte() public function testReverseTransformDisallowsCenteredExtraCharactersMultibyte()
{ {
// Since we test against other locales, we need the full implementation // Since we test against other locales, we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('ru'); \Locale::setDefault('ru');
@ -605,7 +605,7 @@ class NumberToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase
public function testReverseTransformIgnoresTrailingSpacesInExceptionMessage() public function testReverseTransformIgnoresTrailingSpacesInExceptionMessage()
{ {
// Since we test against other locales, we need the full implementation // Since we test against other locales, we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('ru'); \Locale::setDefault('ru');
@ -633,7 +633,7 @@ class NumberToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase
public function testReverseTransformDisallowsTrailingExtraCharactersMultibyte() public function testReverseTransformDisallowsTrailingExtraCharactersMultibyte()
{ {
// Since we test against other locales, we need the full implementation // Since we test against other locales, we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('ru'); \Locale::setDefault('ru');

View File

@ -53,7 +53,7 @@ class PercentToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCas
public function testTransformWithScale() public function testTransformWithScale()
{ {
// Since we test against "de_AT", we need the full implementation // Since we test against "de_AT", we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('de_AT'); \Locale::setDefault('de_AT');
@ -92,7 +92,7 @@ class PercentToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCas
public function testReverseTransformWithScale() public function testReverseTransformWithScale()
{ {
// Since we test against "de_AT", we need the full implementation // Since we test against "de_AT", we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('de_AT'); \Locale::setDefault('de_AT');

View File

@ -19,7 +19,7 @@ class CountryTypeTest extends TestCase
{ {
protected function setUp() protected function setUp()
{ {
IntlTestHelper::requireIntl($this); IntlTestHelper::requireIntl($this, false);
parent::setUp(); parent::setUp();
} }

View File

@ -19,7 +19,7 @@ class CurrencyTypeTest extends TestCase
{ {
protected function setUp() protected function setUp()
{ {
IntlTestHelper::requireIntl($this); IntlTestHelper::requireIntl($this, false);
parent::setUp(); parent::setUp();
} }

View File

@ -70,7 +70,7 @@ class DateTypeTest extends TestCase
public function testSubmitFromSingleTextDateTime() public function testSubmitFromSingleTextDateTime()
{ {
// we test against "de_AT", so we need the full implementation // we test against "de_AT", so we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('de_AT'); \Locale::setDefault('de_AT');
@ -91,7 +91,7 @@ class DateTypeTest extends TestCase
public function testSubmitFromSingleTextString() public function testSubmitFromSingleTextString()
{ {
// we test against "de_AT", so we need the full implementation // we test against "de_AT", so we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('de_AT'); \Locale::setDefault('de_AT');
@ -112,7 +112,7 @@ class DateTypeTest extends TestCase
public function testSubmitFromSingleTextTimestamp() public function testSubmitFromSingleTextTimestamp()
{ {
// we test against "de_AT", so we need the full implementation // we test against "de_AT", so we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('de_AT'); \Locale::setDefault('de_AT');
@ -135,7 +135,7 @@ class DateTypeTest extends TestCase
public function testSubmitFromSingleTextRaw() public function testSubmitFromSingleTextRaw()
{ {
// we test against "de_AT", so we need the full implementation // we test against "de_AT", so we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('de_AT'); \Locale::setDefault('de_AT');
@ -399,7 +399,7 @@ class DateTypeTest extends TestCase
public function testSetDataWithNegativeTimezoneOffsetStringInput() public function testSetDataWithNegativeTimezoneOffsetStringInput()
{ {
// we test against "de_AT", so we need the full implementation // we test against "de_AT", so we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('de_AT'); \Locale::setDefault('de_AT');
@ -421,7 +421,7 @@ class DateTypeTest extends TestCase
public function testSetDataWithNegativeTimezoneOffsetDateTimeInput() public function testSetDataWithNegativeTimezoneOffsetDateTimeInput()
{ {
// we test against "de_AT", so we need the full implementation // we test against "de_AT", so we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('de_AT'); \Locale::setDefault('de_AT');
@ -495,7 +495,7 @@ class DateTypeTest extends TestCase
public function testMonthsOptionLongFormat() public function testMonthsOptionLongFormat()
{ {
// we test against "de_AT", so we need the full implementation // we test against "de_AT", so we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('de_AT'); \Locale::setDefault('de_AT');
@ -515,7 +515,7 @@ class DateTypeTest extends TestCase
public function testMonthsOptionLongFormatWithDifferentTimezone() public function testMonthsOptionLongFormatWithDifferentTimezone()
{ {
// we test against "de_AT", so we need the full implementation // we test against "de_AT", so we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('de_AT'); \Locale::setDefault('de_AT');
@ -621,7 +621,7 @@ class DateTypeTest extends TestCase
public function testPassDatePatternToView() public function testPassDatePatternToView()
{ {
// we test against "de_AT", so we need the full implementation // we test against "de_AT", so we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('de_AT'); \Locale::setDefault('de_AT');
@ -634,7 +634,7 @@ class DateTypeTest extends TestCase
public function testPassDatePatternToViewDifferentFormat() public function testPassDatePatternToViewDifferentFormat()
{ {
// we test against "de_AT", so we need the full implementation // we test against "de_AT", so we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('de_AT'); \Locale::setDefault('de_AT');
@ -682,7 +682,7 @@ class DateTypeTest extends TestCase
public function testDatePatternFormatWithQuotedStrings() public function testDatePatternFormatWithQuotedStrings()
{ {
// we test against "es_ES", so we need the full implementation // we test against "es_ES", so we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('es_ES'); \Locale::setDefault('es_ES');

View File

@ -18,7 +18,7 @@ class IntegerTypeTest extends TestCase
{ {
protected function setUp() protected function setUp()
{ {
IntlTestHelper::requireIntl($this); IntlTestHelper::requireIntl($this, false);
parent::setUp(); parent::setUp();
} }

View File

@ -19,7 +19,7 @@ class LanguageTypeTest extends TestCase
{ {
protected function setUp() protected function setUp()
{ {
IntlTestHelper::requireIntl($this); IntlTestHelper::requireIntl($this, false);
parent::setUp(); parent::setUp();
} }

View File

@ -19,7 +19,7 @@ class LocaleTypeTest extends TestCase
{ {
protected function setUp() protected function setUp()
{ {
IntlTestHelper::requireIntl($this); IntlTestHelper::requireIntl($this, false);
parent::setUp(); parent::setUp();
} }

View File

@ -20,7 +20,7 @@ class MoneyTypeTest extends TestCase
{ {
// we test against different locales, so we need the full // we test against different locales, so we need the full
// implementation // implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
parent::setUp(); parent::setUp();
} }

View File

@ -21,7 +21,7 @@ class NumberTypeTest extends TestCase
parent::setUp(); parent::setUp();
// we test against "de_DE", so we need the full implementation // we test against "de_DE", so we need the full implementation
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('de_DE'); \Locale::setDefault('de_DE');
} }

View File

@ -24,7 +24,7 @@ class CollatorTest extends AbstractCollatorTest
{ {
protected function setUp() protected function setUp()
{ {
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
parent::setUp(); parent::setUp();
} }

View File

@ -908,9 +908,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
{ {
$dateTime = new \DateTime(); $dateTime = new \DateTime();
$dateTime->setTimestamp(null === $timestamp ? time() : $timestamp); $dateTime->setTimestamp(null === $timestamp ? time() : $timestamp);
if (null !== $timeZone) { $dateTime->setTimezone(new \DateTimeZone($timeZone ?: getenv('TZ') ?: 'UTC'));
$dateTime->setTimezone(new \DateTimeZone($timeZone));
}
return $dateTime; return $dateTime;
} }

View File

@ -25,7 +25,7 @@ class IntlDateFormatterTest extends AbstractIntlDateFormatterTest
{ {
protected function setUp() protected function setUp()
{ {
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
parent::setUp(); parent::setUp();
} }
@ -45,6 +45,8 @@ class IntlDateFormatterTest extends AbstractIntlDateFormatterTest
protected function getDateFormatter($locale, $datetype, $timetype, $timezone = null, $calendar = IntlDateFormatter::GREGORIAN, $pattern = null) 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)) { if (!$formatter = new \IntlDateFormatter($locale, $datetype, $timetype, $timezone, $calendar, $pattern)) {
throw new \InvalidArgumentException(intl_get_error_message()); throw new \InvalidArgumentException(intl_get_error_message());
} }

View File

@ -24,7 +24,7 @@ class IntlGlobalsTest extends AbstractIntlGlobalsTest
{ {
protected function setUp() protected function setUp()
{ {
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
parent::setUp(); parent::setUp();
} }

View File

@ -24,7 +24,7 @@ class LocaleTest extends AbstractLocaleTest
{ {
protected function setUp() protected function setUp()
{ {
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
parent::setUp(); parent::setUp();
} }

View File

@ -22,7 +22,7 @@ class NumberFormatterTest extends AbstractNumberFormatterTest
{ {
protected function setUp() protected function setUp()
{ {
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, '55.1');
parent::setUp(); parent::setUp();
} }
@ -32,6 +32,13 @@ class NumberFormatterTest extends AbstractNumberFormatterTest
$this->assertInstanceOf('\NumberFormatter', \NumberFormatter::create('en', \NumberFormatter::DECIMAL)); $this->assertInstanceOf('\NumberFormatter', \NumberFormatter::create('en', \NumberFormatter::DECIMAL));
} }
public function testGetTextAttribute()
{
IntlTestHelper::requireFullIntl($this);
parent::testGetTextAttribute();
}
protected function getNumberFormatter($locale = 'en', $style = null, $pattern = null) protected function getNumberFormatter($locale = 'en', $style = null, $pattern = null)
{ {
return new \NumberFormatter($locale, $style, $pattern); return new \NumberFormatter($locale, $style, $pattern);

View File

@ -28,19 +28,21 @@ class IntlTestHelper
{ {
/** /**
* Should be called before tests that work fine with the stub implementation. * Should be called before tests that work fine with the stub implementation.
*
* @param \PhpUnit_Framework_TestCase $testCase
*/ */
public static function requireIntl(\PHPUnit_Framework_TestCase $testCase) public static function requireIntl(\PHPUnit_Framework_TestCase $testCase, $minimumIcuVersion = null)
{ {
if (null === $minimumIcuVersion) {
$minimumIcuVersion = Intl::getIcuStubVersion();
}
// We only run tests if the version is *one specific version*. // We only run tests if the version is *one specific version*.
// This condition is satisfied if // This condition is satisfied if
// //
// * the intl extension is loaded with version Intl::getIcuStubVersion() // * the intl extension is loaded with version Intl::getIcuStubVersion()
// * the intl extension is not loaded // * the intl extension is not loaded
if (IcuVersion::compare(Intl::getIcuVersion(), Intl::getIcuStubVersion(), '!=', 1)) { if (($minimumIcuVersion || defined('HHVM_VERSION_ID')) && IcuVersion::compare(Intl::getIcuVersion(), $minimumIcuVersion, '!=', 1)) {
$testCase->markTestSkipped('ICU version '.Intl::getIcuStubVersion().' is required.'); $testCase->markTestSkipped('ICU version '.$minimumIcuVersion.' is required.');
} }
// Normalize the default locale in case this is not done explicitly // Normalize the default locale in case this is not done explicitly
@ -60,24 +62,15 @@ class IntlTestHelper
/** /**
* Should be called before tests that require a feature-complete intl * Should be called before tests that require a feature-complete intl
* implementation. * implementation.
*
* @param \PhpUnit_Framework_TestCase $testCase
*/ */
public static function requireFullIntl(\PHPUnit_Framework_TestCase $testCase) public static function requireFullIntl(\PHPUnit_Framework_TestCase $testCase, $minimumIcuVersion = null)
{ {
// We only run tests if the intl extension is loaded... // We only run tests if the intl extension is loaded...
if (!Intl::isExtensionLoaded()) { if (!Intl::isExtensionLoaded()) {
$testCase->markTestSkipped('Extension intl is required.'); $testCase->markTestSkipped('Extension intl is required.');
} }
// ... and only if the version is *one specific version* self::requireIntl($testCase, $minimumIcuVersion);
if (IcuVersion::compare(Intl::getIcuVersion(), Intl::getIcuStubVersion(), '!=', 1)) {
$testCase->markTestSkipped('ICU version '.Intl::getIcuStubVersion().' is required.');
}
// Normalize the default locale in case this is not done explicitly
// in the test
\Locale::setDefault('en');
// Consequently, tests will // Consequently, tests will
// //
@ -89,8 +82,6 @@ class IntlTestHelper
/** /**
* Skips the test unless the current system has a 32bit architecture. * Skips the test unless the current system has a 32bit architecture.
*
* @param \PhpUnit_Framework_TestCase $testCase
*/ */
public static function require32Bit(\PHPUnit_Framework_TestCase $testCase) public static function require32Bit(\PHPUnit_Framework_TestCase $testCase)
{ {
@ -101,8 +92,6 @@ class IntlTestHelper
/** /**
* Skips the test unless the current system has a 64bit architecture. * Skips the test unless the current system has a 64bit architecture.
*
* @param \PhpUnit_Framework_TestCase $testCase
*/ */
public static function require64Bit(\PHPUnit_Framework_TestCase $testCase) public static function require64Bit(\PHPUnit_Framework_TestCase $testCase)
{ {

View File

@ -36,7 +36,7 @@ class LocaleTest extends \PHPUnit_Framework_TestCase
public function testGetDisplayCountriesForSwitzerland() public function testGetDisplayCountriesForSwitzerland()
{ {
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
$countries = Locale::getDisplayCountries('de_CH'); $countries = Locale::getDisplayCountries('de_CH');
$this->assertEquals('Schweiz', $countries['CH']); $this->assertEquals('Schweiz', $countries['CH']);

View File

@ -60,7 +60,7 @@ class IdentityTranslatorTest extends \PHPUnit_Framework_TestCase
public function testGetLocaleReturnsDefaultLocaleIfNotSet() public function testGetLocaleReturnsDefaultLocaleIfNotSet()
{ {
// in order to test with "pt_BR" // in order to test with "pt_BR"
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
$translator = new IdentityTranslator(); $translator = new IdentityTranslator();

View File

@ -96,7 +96,7 @@ class CountryValidatorTest extends AbstractConstraintValidatorTest
public function testValidateUsingCountrySpecificLocale() public function testValidateUsingCountrySpecificLocale()
{ {
// in order to test with "en_GB" // in order to test with "en_GB"
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('en_GB'); \Locale::setDefault('en_GB');

View File

@ -65,7 +65,7 @@ class CurrencyValidatorTest extends AbstractConstraintValidatorTest
**/ **/
public function testValidCurrenciesWithCountrySpecificLocale($currency) public function testValidCurrenciesWithCountrySpecificLocale($currency)
{ {
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('en_GB'); \Locale::setDefault('en_GB');

View File

@ -95,7 +95,7 @@ class LanguageValidatorTest extends AbstractConstraintValidatorTest
public function testValidateUsingCountrySpecificLocale() public function testValidateUsingCountrySpecificLocale()
{ {
IntlTestHelper::requireFullIntl($this); IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('fr_FR'); \Locale::setDefault('fr_FR');
$existingLanguage = 'en'; $existingLanguage = 'en';