[Intl] Removed ICU version comparisons from the tests

This commit is contained in:
Bernhard Schussek 2013-03-16 11:49:45 +01:00
parent 5d17de545b
commit a717ce9dc2
2 changed files with 32 additions and 58 deletions

View File

@ -222,21 +222,18 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
array('s', 3601, '1'),
array('s', 3630, '30'),
array('s', 43200, '0'), // 12 hours
);
// Timezone
if (Intl::isExtensionLoaded() && IcuVersion::compare(Intl::getIcuVersion(), '4.8', '>=')) {
// general
$formatData[] = array("yyyy.MM.dd 'at' HH:mm:ss zzz", 0, '1970.01.01 at 00:00:00 GMT');
$formatData[] = array('K:mm a, z', 0, '0:00 AM, GMT');
array("yyyy.MM.dd 'at' HH:mm:ss zzz", 0, '1970.01.01 at 00:00:00 GMT'),
array('K:mm a, z', 0, '0:00 AM, GMT'),
// timezone
$formatData[] = array('z', 0, 'GMT');
$formatData[] = array('zz', 0, 'GMT');
$formatData[] = array('zzz', 0, 'GMT');
$formatData[] = array('zzzz', 0, 'GMT');
$formatData[] = array('zzzzz', 0, 'GMT');
}
array('z', 0, 'GMT'),
array('zz', 0, 'GMT'),
array('zzz', 0, 'GMT'),
array('zzzz', 0, 'GMT'),
array('zzzzz', 0, 'GMT'),
);
// As of PHP 5.3.4, IntlDateFormatter::format() accepts DateTime instances
if (version_compare(PHP_VERSION, '5.3.4', '>=')) {
@ -248,10 +245,8 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
$formatData[] = array('h:mm a', $dateTime, '12:00 AM');
$formatData[] = array('yyyyy.MMMM.dd hh:mm aaa', $dateTime, '01970.January.01 12:00 AM');
if (Intl::isExtensionLoaded() && IcuVersion::compare(Intl::getIcuVersion(), '4.8', '>=')) {
$formatData[] = array("yyyy.MM.dd 'at' HH:mm:ss zzz", $dateTime, '1970.01.01 at 00:00:00 GMT');
$formatData[] = array('K:mm a, z', $dateTime, '0:00 AM, GMT');
}
$formatData[] = array("yyyy.MM.dd 'at' HH:mm:ss zzz", $dateTime, '1970.01.01 at 00:00:00 GMT');
$formatData[] = array('K:mm a, z', $dateTime, '0:00 AM, GMT');
}
return $formatData;
@ -446,22 +441,16 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
public function dateAndTimeTypeProvider()
{
$data = array(
return array(
array(0, StubIntlDateFormatter::FULL, StubIntlDateFormatter::NONE, 'Thursday, January 1, 1970'),
array(0, StubIntlDateFormatter::LONG, StubIntlDateFormatter::NONE, 'January 1, 1970'),
array(0, StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::NONE, 'Jan 1, 1970'),
array(0, StubIntlDateFormatter::SHORT, StubIntlDateFormatter::NONE, '1/1/70'),
array(0, StubIntlDateFormatter::NONE, StubIntlDateFormatter::FULL, '12:00:00 AM GMT'),
array(0, StubIntlDateFormatter::NONE, StubIntlDateFormatter::LONG, '12:00:00 AM GMT'),
array(0, StubIntlDateFormatter::NONE, StubIntlDateFormatter::MEDIUM, '12:00:00 AM'),
array(0, StubIntlDateFormatter::NONE, StubIntlDateFormatter::SHORT, '12:00 AM'),
);
if (Intl::isExtensionLoaded() && IcuVersion::compare(Intl::getIcuVersion(), '4.8', '>=')) {
$data[] = array(0, StubIntlDateFormatter::NONE, StubIntlDateFormatter::FULL, '12:00:00 AM GMT');
$data[] = array(0, StubIntlDateFormatter::NONE, StubIntlDateFormatter::LONG, '12:00:00 AM GMT');
}
$data[] = array(0, StubIntlDateFormatter::NONE, StubIntlDateFormatter::MEDIUM, '12:00:00 AM');
$data[] = array(0, StubIntlDateFormatter::NONE, StubIntlDateFormatter::SHORT, '12:00 AM');
return $data;
}
public function testGetCalendar()
@ -808,7 +797,7 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
public function parseErrorProvider()
{
$data = array(
return array(
// 1 char month
array('y-MMMMM-d', '1970-J-1'),
array('y-MMMMM-d', '1970-S-1'),
@ -817,13 +806,6 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
array('y-LLLLL-d', '1970-J-1'),
array('y-LLLLL-d', '1970-S-1'),
);
if (!Intl::isExtensionLoaded() || IcuVersion::compare(Intl::getIcuVersion(), '4.8', '<')) {
$data[] = array('y-M-d', '1970/1/1');
$data[] = array('yy-M-d', '70/1/1');
}
return $data;
}
/*

View File

@ -91,12 +91,10 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
public function formatCurrencyWithCurrencyStyleCostaRicanColonsRoundingProvider()
{
$crc = Intl::isExtensionLoaded() && IcuVersion::compare(Intl::getIcuVersion(), '4.8', '>=') ? 'CRC' : '₡';
return array(
array(100, 'CRC', $crc, '%s100'),
array(-100, 'CRC', $crc, '(%s100)'),
array(1000.12, 'CRC', $crc, '%s1,000'),
array(100, 'CRC', 'CRC', '%s100'),
array(-100, 'CRC', 'CRC', '(%s100)'),
array(1000.12, 'CRC', 'CRC', '%s1,000'),
);
}
@ -138,29 +136,23 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
public function formatCurrencyWithCurrencyStyleSwissRoundingProvider()
{
// The currency symbol was updated from 4.2 to the 4.4 version. The ICU CLDR data was updated in 2010-03-03,
// the 4.2 release is from 2009-05-08 and the 4.4 from 2010-03-17. It's ugly we want to compare if the
// stub implementation is behaving like the intl one
// http://bugs.icu-project.org/trac/changeset/27776/icu/trunk/source/data/curr/en.txt
$chf = Intl::isExtensionLoaded() && IcuVersion::compare(Intl::getIcuVersion(), '4.4', '<') ? 'Fr.' : 'CHF';
return array(
array(100, 'CHF', $chf, '%s100.00'),
array(-100, 'CHF', $chf, '(%s100.00)'),
array(1000.12, 'CHF', $chf, '%s1,000.10'),
array('1000.12', 'CHF', $chf, '%s1,000.10'),
array(100, 'CHF', 'CHF', '%s100.00'),
array(-100, 'CHF', 'CHF', '(%s100.00)'),
array(1000.12, 'CHF', 'CHF', '%s1,000.10'),
array('1000.12', 'CHF', 'CHF', '%s1,000.10'),
// Rounding checks
array(1000.121, 'CHF', $chf, '%s1,000.10'),
array(1000.123, 'CHF', $chf, '%s1,000.10'),
array(1000.125, 'CHF', $chf, '%s1,000.10'),
array(1000.127, 'CHF', $chf, '%s1,000.15'),
array(1000.129, 'CHF', $chf, '%s1,000.15'),
array(1000.121, 'CHF', 'CHF', '%s1,000.10'),
array(1000.123, 'CHF', 'CHF', '%s1,000.10'),
array(1000.125, 'CHF', 'CHF', '%s1,000.10'),
array(1000.127, 'CHF', 'CHF', '%s1,000.15'),
array(1000.129, 'CHF', 'CHF', '%s1,000.15'),
array(1200000.00, 'CHF', $chf, '%s1,200,000.00'),
array(1200000.1, 'CHF', $chf, '%s1,200,000.10'),
array(1200000.10, 'CHF', $chf, '%s1,200,000.10'),
array(1200000.101, 'CHF', $chf, '%s1,200,000.10')
array(1200000.00, 'CHF', 'CHF', '%s1,200,000.00'),
array(1200000.1, 'CHF', 'CHF', '%s1,200,000.10'),
array(1200000.10, 'CHF', 'CHF', '%s1,200,000.10'),
array(1200000.101, 'CHF', 'CHF', '%s1,200,000.10')
);
}