Skip to content

Commit f57d8bd

Browse files
[ci] Testing with UTC hides bugs
1 parent 1a53f5f commit f57d8bd

File tree

7 files changed

+24
-28
lines changed

7 files changed

+24
-28
lines changed

Tests/Collator/Verification/CollatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class CollatorTest extends AbstractCollatorTest
2424
{
2525
protected function setUp()
2626
{
27-
IntlTestHelper::requireFullIntl($this);
27+
IntlTestHelper::requireFullIntl($this, false);
2828

2929
parent::setUp();
3030
}

Tests/DateFormatter/AbstractIntlDateFormatterTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -908,9 +908,7 @@ protected function getDateTime($timestamp, $timeZone)
908908
{
909909
$dateTime = new \DateTime();
910910
$dateTime->setTimestamp(null === $timestamp ? time() : $timestamp);
911-
if (null !== $timeZone) {
912-
$dateTime->setTimezone(new \DateTimeZone($timeZone));
913-
}
911+
$dateTime->setTimezone(new \DateTimeZone($timeZone ?: getenv('TZ') ?: 'UTC'));
914912

915913
return $dateTime;
916914
}

Tests/DateFormatter/Verification/IntlDateFormatterTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class IntlDateFormatterTest extends AbstractIntlDateFormatterTest
2525
{
2626
protected function setUp()
2727
{
28-
IntlTestHelper::requireFullIntl($this);
28+
IntlTestHelper::requireFullIntl($this, false);
2929

3030
parent::setUp();
3131
}
@@ -45,6 +45,8 @@ public function testFormatWithTimezoneFromEnvironmentVariable()
4545

4646
protected function getDateFormatter($locale, $datetype, $timetype, $timezone = null, $calendar = IntlDateFormatter::GREGORIAN, $pattern = null)
4747
{
48+
IntlTestHelper::requireFullIntl($this, '55.1');
49+
4850
if (!$formatter = new \IntlDateFormatter($locale, $datetype, $timetype, $timezone, $calendar, $pattern)) {
4951
throw new \InvalidArgumentException(intl_get_error_message());
5052
}

Tests/Globals/Verification/IntlGlobalsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class IntlGlobalsTest extends AbstractIntlGlobalsTest
2424
{
2525
protected function setUp()
2626
{
27-
IntlTestHelper::requireFullIntl($this);
27+
IntlTestHelper::requireFullIntl($this, false);
2828

2929
parent::setUp();
3030
}

Tests/Locale/Verification/LocaleTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class LocaleTest extends AbstractLocaleTest
2424
{
2525
protected function setUp()
2626
{
27-
IntlTestHelper::requireFullIntl($this);
27+
IntlTestHelper::requireFullIntl($this, false);
2828

2929
parent::setUp();
3030
}

Tests/NumberFormatter/Verification/NumberFormatterTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class NumberFormatterTest extends AbstractNumberFormatterTest
2222
{
2323
protected function setUp()
2424
{
25-
IntlTestHelper::requireFullIntl($this);
25+
IntlTestHelper::requireFullIntl($this, '55.1');
2626

2727
parent::setUp();
2828
}
@@ -32,6 +32,13 @@ public function testCreate()
3232
$this->assertInstanceOf('\NumberFormatter', \NumberFormatter::create('en', \NumberFormatter::DECIMAL));
3333
}
3434

35+
public function testGetTextAttribute()
36+
{
37+
IntlTestHelper::requireFullIntl($this);
38+
39+
parent::testGetTextAttribute();
40+
}
41+
3542
protected function getNumberFormatter($locale = 'en', $style = null, $pattern = null)
3643
{
3744
return new \NumberFormatter($locale, $style, $pattern);

Util/IntlTestHelper.php

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,21 @@ class IntlTestHelper
2828
{
2929
/**
3030
* Should be called before tests that work fine with the stub implementation.
31-
*
32-
* @param \PhpUnit_Framework_TestCase $testCase
3331
*/
34-
public static function requireIntl(\PHPUnit_Framework_TestCase $testCase)
32+
public static function requireIntl(\PHPUnit_Framework_TestCase $testCase, $minimumIcuVersion = null)
3533
{
34+
if (null === $minimumIcuVersion) {
35+
$minimumIcuVersion = Intl::getIcuStubVersion();
36+
}
37+
3638
// We only run tests if the version is *one specific version*.
3739
// This condition is satisfied if
3840
//
3941
// * the intl extension is loaded with version Intl::getIcuStubVersion()
4042
// * the intl extension is not loaded
4143

42-
if (IcuVersion::compare(Intl::getIcuVersion(), Intl::getIcuStubVersion(), '!=', 1)) {
43-
$testCase->markTestSkipped('ICU version '.Intl::getIcuStubVersion().' is required.');
44+
if (($minimumIcuVersion || defined('HHVM_VERSION_ID')) && IcuVersion::compare(Intl::getIcuVersion(), $minimumIcuVersion, '!=', 1)) {
45+
$testCase->markTestSkipped('ICU version '.$minimumIcuVersion.' is required.');
4446
}
4547

4648
// Normalize the default locale in case this is not done explicitly
@@ -60,24 +62,15 @@ public static function requireIntl(\PHPUnit_Framework_TestCase $testCase)
6062
/**
6163
* Should be called before tests that require a feature-complete intl
6264
* implementation.
63-
*
64-
* @param \PhpUnit_Framework_TestCase $testCase
6565
*/
66-
public static function requireFullIntl(\PHPUnit_Framework_TestCase $testCase)
66+
public static function requireFullIntl(\PHPUnit_Framework_TestCase $testCase, $minimumIcuVersion = null)
6767
{
6868
// We only run tests if the intl extension is loaded...
6969
if (!Intl::isExtensionLoaded()) {
7070
$testCase->markTestSkipped('Extension intl is required.');
7171
}
7272

73-
// ... and only if the version is *one specific version*
74-
if (IcuVersion::compare(Intl::getIcuVersion(), Intl::getIcuStubVersion(), '!=', 1)) {
75-
$testCase->markTestSkipped('ICU version '.Intl::getIcuStubVersion().' is required.');
76-
}
77-
78-
// Normalize the default locale in case this is not done explicitly
79-
// in the test
80-
\Locale::setDefault('en');
73+
self::requireIntl($testCase, $minimumIcuVersion);
8174

8275
// Consequently, tests will
8376
//
@@ -89,8 +82,6 @@ public static function requireFullIntl(\PHPUnit_Framework_TestCase $testCase)
8982

9083
/**
9184
* Skips the test unless the current system has a 32bit architecture.
92-
*
93-
* @param \PhpUnit_Framework_TestCase $testCase
9485
*/
9586
public static function require32Bit(\PHPUnit_Framework_TestCase $testCase)
9687
{
@@ -101,8 +92,6 @@ public static function require32Bit(\PHPUnit_Framework_TestCase $testCase)
10192

10293
/**
10394
* Skips the test unless the current system has a 64bit architecture.
104-
*
105-
* @param \PhpUnit_Framework_TestCase $testCase
10695
*/
10796
public static function require64Bit(\PHPUnit_Framework_TestCase $testCase)
10897
{

0 commit comments

Comments
 (0)