[3.0] Fix tests
This commit is contained in:
parent
6a41f11fac
commit
37e1f1a943
@ -10,7 +10,6 @@ addons:
|
||||
matrix:
|
||||
include:
|
||||
- php: hhvm
|
||||
- php: 5.5.9
|
||||
- php: 5.5
|
||||
- php: 5.6
|
||||
- php: 5.6
|
||||
|
@ -47,6 +47,6 @@ class TransNodeTest extends \PHPUnit_Framework_TestCase
|
||||
return sprintf('(isset($context["%s"]) || array_key_exists("%s", $context) ? $context["%s"] : $this->notFound("%s", 0))', $name, $name, $name, $name);
|
||||
}
|
||||
|
||||
return sprintf('$this->getContext($context, "%s")', $name);
|
||||
return sprintf('(isset($context["%1$s"]) ? $context["%1$s"] : $this->getContext($context, "%1$s"))', $name);
|
||||
}
|
||||
}
|
||||
|
@ -295,12 +295,11 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testHandleDeprecation()
|
||||
{
|
||||
$that = $this;
|
||||
$logArgCheck = function ($level, $message, $context) use ($that) {
|
||||
$that->assertEquals(LogLevel::INFO, $level);
|
||||
$that->assertArrayHasKey('level', $context);
|
||||
$that->assertEquals(E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED, $context['level']);
|
||||
$that->assertArrayHasKey('stack', $context);
|
||||
$logArgCheck = function ($level, $message, $context) {
|
||||
$this->assertEquals(LogLevel::INFO, $level);
|
||||
$this->assertArrayHasKey('level', $context);
|
||||
$this->assertEquals(E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED, $context['level']);
|
||||
$this->assertArrayHasKey('stack', $context);
|
||||
};
|
||||
|
||||
$logger = $this->getMock('Psr\Log\LoggerInterface');
|
||||
|
@ -207,10 +207,7 @@ class IntlDateFormatter
|
||||
// behave like the intl extension
|
||||
$argumentError = null;
|
||||
if (!is_int($timestamp) && !$timestamp instanceof \DateTime) {
|
||||
$argumentError = 'datefmt_format: takes either an array or an integer timestamp value or a DateTime object';
|
||||
if (!is_int($timestamp)) {
|
||||
$argumentError = sprintf('datefmt_format: string \'%s\' is not numeric, which would be required for it to be a valid date', $timestamp);
|
||||
}
|
||||
$argumentError = sprintf('datefmt_format: string \'%s\' is not numeric, which would be required for it to be a valid date', $timestamp);
|
||||
}
|
||||
|
||||
if (null !== $argumentError) {
|
||||
|
@ -857,6 +857,10 @@ class NumberFormatter
|
||||
return false;
|
||||
}
|
||||
|
||||
if (PHP_INT_SIZE !== 8 && ($value > self::$int32Range['positive'] || $value < self::$int32Range['negative'])) {
|
||||
return (float) $value;
|
||||
}
|
||||
|
||||
return (int) $value;
|
||||
}
|
||||
|
||||
|
@ -55,10 +55,6 @@ class IntlBundleReaderTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
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.');
|
||||
}
|
||||
@ -75,10 +71,6 @@ class IntlBundleReaderTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
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.');
|
||||
}
|
||||
|
@ -71,10 +71,6 @@ class PhpBundleWriterTest extends \PHPUnit_Framework_TestCase
|
||||
$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);
|
||||
|
||||
$this->writer->write($this->directory, 'en', $bundle);
|
||||
|
@ -306,10 +306,6 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
array(0, 'Europe/Dublin', '1970-01-01 01:00:00'),
|
||||
array(0, 'Europe/Warsaw', '1970-01-01 01:00:00'),
|
||||
array(0, 'Pacific/Fiji', '1970-01-01 12:00:00'),
|
||||
array(0, 'Foo/Bar', '1970-01-01 00:00:00'),
|
||||
array(0, 'Foo/Bar', '1970-01-01 00:00:00'),
|
||||
array(0, 'UTC+04:30', '1970-01-01 00:00:00'),
|
||||
array(0, 'UTC+04:AA', '1970-01-01 00:00:00'),
|
||||
);
|
||||
|
||||
return $data;
|
||||
@ -382,25 +378,6 @@ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('GMT+03:00', $formatter->format(0));
|
||||
}
|
||||
|
||||
public function testFormatWithTimezoneFromEnvironmentVariable()
|
||||
{
|
||||
$tz = getenv('TZ');
|
||||
putenv('TZ=Europe/London');
|
||||
|
||||
$formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT);
|
||||
$formatter->setPattern('yyyy-MM-dd HH:mm:ss');
|
||||
|
||||
$this->assertEquals(
|
||||
$this->getDateTime(0, 'Europe/London')->format('Y-m-d H:i:s'),
|
||||
$formatter->format(0)
|
||||
);
|
||||
|
||||
$this->assertEquals('Europe/London', getenv('TZ'));
|
||||
|
||||
// Restores TZ.
|
||||
putenv('TZ='.$tz);
|
||||
}
|
||||
|
||||
public function testFormatWithTimezoneFromPhp()
|
||||
{
|
||||
$tz = date_default_timezone_get();
|
||||
|
@ -30,19 +30,6 @@ class IntlDateFormatterTest extends AbstractIntlDateFormatterTest
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* It seems IntlDateFormatter caches the timezone id when not explicitly set via constructor or by the
|
||||
* setTimeZoneId() method. Since testFormatWithDefaultTimezoneIntl() runs using the default environment
|
||||
* time zone, this test would use it too if not running in a separated process.
|
||||
*
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
public function testFormatWithTimezoneFromEnvironmentVariable()
|
||||
{
|
||||
parent::testFormatWithTimezoneFromEnvironmentVariable();
|
||||
}
|
||||
|
||||
protected function getDateFormatter($locale, $datetype, $timetype, $timezone = null, $calendar = IntlDateFormatter::GREGORIAN, $pattern = null)
|
||||
{
|
||||
if (!$formatter = new \IntlDateFormatter($locale, $datetype, $timetype, $timezone, $calendar, $pattern)) {
|
||||
|
@ -683,9 +683,7 @@ abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(2147483647, $parsedValue);
|
||||
|
||||
$parsedValue = $formatter->parse('-2,147,483,648', NumberFormatter::TYPE_INT64);
|
||||
|
||||
$this->assertInternalType('int', $parsedValue);
|
||||
|
||||
$this->assertEquals(-2147483648, $parsedValue);
|
||||
}
|
||||
|
||||
|
@ -125,10 +125,6 @@ abstract class AbstractComparisonValidatorTestCase extends AbstractConstraintVal
|
||||
// Make sure we have the correct version loaded
|
||||
if ($dirtyValue instanceof \DateTime || $dirtyValue instanceof \DateTimeInterface) {
|
||||
IntlTestHelper::requireIntl($this);
|
||||
|
||||
if (PHP_VERSION_ID < 50304 && !(extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
|
||||
$this->markTestSkipped('Intl supports formatting DateTime objects since 5.3.4');
|
||||
}
|
||||
}
|
||||
|
||||
$constraint = $this->createConstraint(array('value' => $comparedValue));
|
||||
|
@ -87,9 +87,6 @@ class NotIdenticalToValidatorTest extends AbstractComparisonValidatorTestCase
|
||||
array($object, '2', $object, '2', __NAMESPACE__.'\ComparisonTest_Class'),
|
||||
);
|
||||
|
||||
$immutableDate = new \DateTimeImmutable('2000-01-01');
|
||||
$comparisons[] = array($immutableDate, 'Jan 1, 2000, 12:00 AM', $immutableDate, 'Jan 1, 2000, 12:00 AM', 'DateTime');
|
||||
|
||||
return $comparisons;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user