bug #32981 Fix tests/code for php 7.4 (jderusse)
This PR was merged into the 3.4 branch.
Discussion
----------
Fix tests/code for php 7.4
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #32844
| License | MIT
| Doc PR | NA
Fix remaining tests and deprecation
Commits
-------
05ec8a08b4
Fix remaining tests
This commit is contained in:
commit
b27c9992c7
|
@ -264,7 +264,7 @@ class Configuration implements ConfigurationInterface
|
|||
->canBeEnabled()
|
||||
->beforeNormalization()
|
||||
->always(function ($v) {
|
||||
if (true === $v['enabled']) {
|
||||
if (\is_array($v) && true === $v['enabled']) {
|
||||
$workflows = $v;
|
||||
unset($workflows['enabled']);
|
||||
|
||||
|
|
|
@ -234,7 +234,7 @@ class XmlUtils
|
|||
return true;
|
||||
case 'false' === $lowercaseValue:
|
||||
return false;
|
||||
case isset($value[1]) && '0b' == $value[0].$value[1]:
|
||||
case isset($value[1]) && '0b' == $value[0].$value[1] && preg_match('/^0b[01]*$/', $value):
|
||||
return bindec($value);
|
||||
case is_numeric($value):
|
||||
return '0x' === $value[0].$value[1] ? hexdec($value) : (float) $value;
|
||||
|
|
|
@ -470,7 +470,7 @@ class ErrorHandler
|
|||
}
|
||||
|
||||
if ($throw) {
|
||||
if (E_USER_ERROR & $type) {
|
||||
if (\PHP_VERSION_ID < 70400 && E_USER_ERROR & $type) {
|
||||
for ($i = 1; isset($backtrace[$i]); ++$i) {
|
||||
if (isset($backtrace[$i]['function'], $backtrace[$i]['type'], $backtrace[$i - 1]['function'])
|
||||
&& '__toString' === $backtrace[$i]['function']
|
||||
|
|
|
@ -283,6 +283,10 @@ class ErrorHandlerTest extends TestCase
|
|||
|
||||
public function testHandleUserError()
|
||||
{
|
||||
if (\PHP_VERSION_ID >= 70400) {
|
||||
$this->markTestSkipped('PHP 7.4 allows __toString to throw exceptions');
|
||||
}
|
||||
|
||||
try {
|
||||
$handler = ErrorHandler::register();
|
||||
$handler->throwAt(0, true);
|
||||
|
|
|
@ -57,7 +57,7 @@ class FormFieldRegistry
|
|||
$target = &$this->fields;
|
||||
while (\count($segments) > 1) {
|
||||
$path = array_shift($segments);
|
||||
if (!\array_key_exists($path, $target)) {
|
||||
if (!\is_array($target) || !\array_key_exists($path, $target)) {
|
||||
return;
|
||||
}
|
||||
$target = &$target[$path];
|
||||
|
@ -80,7 +80,7 @@ class FormFieldRegistry
|
|||
$target = &$this->fields;
|
||||
while ($segments) {
|
||||
$path = array_shift($segments);
|
||||
if (!\array_key_exists($path, $target)) {
|
||||
if (!\is_array($target) || !\array_key_exists($path, $target)) {
|
||||
throw new \InvalidArgumentException(sprintf('Unreachable field "%s"', $path));
|
||||
}
|
||||
$target = &$target[$path];
|
||||
|
|
|
@ -33,11 +33,7 @@ class SortableIteratorTest extends RealIteratorTestCase
|
|||
if (!\is_callable($mode)) {
|
||||
switch ($mode) {
|
||||
case SortableIterator::SORT_BY_ACCESSED_TIME:
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
touch(self::toAbsolute('.git'));
|
||||
} else {
|
||||
file_get_contents(self::toAbsolute('.git'));
|
||||
}
|
||||
touch(self::toAbsolute('.git'));
|
||||
sleep(1);
|
||||
file_get_contents(self::toAbsolute('.bar'));
|
||||
break;
|
||||
|
|
|
@ -471,6 +471,7 @@ class DateTypeTest extends BaseTypeTest
|
|||
|
||||
public function testMonthsOption()
|
||||
{
|
||||
\Locale::setDefault('en');
|
||||
$form = $this->factory->create(static::TESTED_TYPE, null, [
|
||||
'months' => [6, 7],
|
||||
'format' => \IntlDateFormatter::SHORT,
|
||||
|
@ -479,8 +480,8 @@ class DateTypeTest extends BaseTypeTest
|
|||
$view = $form->createView();
|
||||
|
||||
$this->assertEquals([
|
||||
new ChoiceView(6, '6', '06'),
|
||||
new ChoiceView(7, '7', '07'),
|
||||
new ChoiceView(6, '6', '6'),
|
||||
new ChoiceView(7, '7', '7'),
|
||||
], $view['month']->vars['choices']);
|
||||
}
|
||||
|
||||
|
@ -544,14 +545,15 @@ class DateTypeTest extends BaseTypeTest
|
|||
|
||||
public function testIsDayWithinRangeReturnsTrueIfWithin()
|
||||
{
|
||||
\Locale::setDefault('en');
|
||||
$view = $this->factory->create(static::TESTED_TYPE, null, [
|
||||
'days' => [6, 7],
|
||||
])
|
||||
->createView();
|
||||
|
||||
$this->assertEquals([
|
||||
new ChoiceView(6, '6', '06'),
|
||||
new ChoiceView(7, '7', '07'),
|
||||
new ChoiceView(6, '6', '6'),
|
||||
new ChoiceView(7, '7', '7'),
|
||||
], $view['day']->vars['choices']);
|
||||
}
|
||||
|
||||
|
|
|
@ -589,6 +589,7 @@ abstract class AbstractCurrencyDataProviderTest extends AbstractDataProviderTest
|
|||
* @var CurrencyDataProvider
|
||||
*/
|
||||
protected $dataProvider;
|
||||
private $defaultLocale;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
|
@ -598,6 +599,15 @@ abstract class AbstractCurrencyDataProviderTest extends AbstractDataProviderTest
|
|||
$this->getDataDirectory().'/'.Intl::CURRENCY_DIR,
|
||||
$this->createEntryReader()
|
||||
);
|
||||
|
||||
$this->defaultLocale = \Locale::getDefault();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
\Locale::setDefault($this->defaultLocale);
|
||||
}
|
||||
|
||||
abstract protected function getDataDirectory();
|
||||
|
|
|
@ -831,6 +831,7 @@ abstract class AbstractLanguageDataProviderTest extends AbstractDataProviderTest
|
|||
* @var LanguageDataProvider
|
||||
*/
|
||||
protected $dataProvider;
|
||||
private $defaultLocale;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
|
@ -840,6 +841,15 @@ abstract class AbstractLanguageDataProviderTest extends AbstractDataProviderTest
|
|||
$this->getDataDirectory().'/'.Intl::LANGUAGE_DIR,
|
||||
$this->createEntryReader()
|
||||
);
|
||||
|
||||
$this->defaultLocale = \Locale::getDefault();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
\Locale::setDefault($this->defaultLocale);
|
||||
}
|
||||
|
||||
abstract protected function getDataDirectory();
|
||||
|
|
|
@ -23,6 +23,7 @@ abstract class AbstractLocaleDataProviderTest extends AbstractDataProviderTest
|
|||
* @var LocaleDataProvider
|
||||
*/
|
||||
protected $dataProvider;
|
||||
private $defaultLocale;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
|
@ -32,6 +33,13 @@ abstract class AbstractLocaleDataProviderTest extends AbstractDataProviderTest
|
|||
$this->getDataDirectory().'/'.Intl::LOCALE_DIR,
|
||||
$this->createEntryReader()
|
||||
);
|
||||
|
||||
$this->defaultLocale = \Locale::getDefault();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
\Locale::setDefault($this->defaultLocale);
|
||||
}
|
||||
|
||||
abstract protected function getDataDirectory();
|
||||
|
|
|
@ -283,6 +283,7 @@ abstract class AbstractRegionDataProviderTest extends AbstractDataProviderTest
|
|||
* @var RegionDataProvider
|
||||
*/
|
||||
protected $dataProvider;
|
||||
private $defaultLocale;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
|
@ -292,6 +293,15 @@ abstract class AbstractRegionDataProviderTest extends AbstractDataProviderTest
|
|||
$this->getDataDirectory().'/'.Intl::REGION_DIR,
|
||||
$this->createEntryReader()
|
||||
);
|
||||
|
||||
$this->defaultLocale = \Locale::getDefault();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
\Locale::setDefault($this->defaultLocale);
|
||||
}
|
||||
|
||||
abstract protected function getDataDirectory();
|
||||
|
|
|
@ -219,6 +219,7 @@ abstract class AbstractScriptDataProviderTest extends AbstractDataProviderTest
|
|||
* @var ScriptDataProvider
|
||||
*/
|
||||
protected $dataProvider;
|
||||
private $defaultLocale;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
|
@ -228,6 +229,15 @@ abstract class AbstractScriptDataProviderTest extends AbstractDataProviderTest
|
|||
$this->getDataDirectory().'/'.Intl::SCRIPT_DIR,
|
||||
$this->createEntryReader()
|
||||
);
|
||||
|
||||
$this->defaultLocale = \Locale::getDefault();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
\Locale::setDefault($this->defaultLocale);
|
||||
}
|
||||
|
||||
abstract protected function getDataDirectory();
|
||||
|
|
|
@ -24,11 +24,23 @@ use Symfony\Component\Intl\Util\IcuVersion;
|
|||
*/
|
||||
abstract class AbstractIntlDateFormatterTest extends TestCase
|
||||
{
|
||||
private $defaultLocale;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->defaultLocale = \Locale::getDefault();
|
||||
\Locale::setDefault('en');
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
\Locale::setDefault($this->defaultLocale);
|
||||
}
|
||||
|
||||
/**
|
||||
* When a time zone is not specified, it uses the system default however it returns null in the getter method.
|
||||
*
|
||||
|
|
|
@ -16,6 +16,22 @@ use Symfony\Component\Intl\Intl;
|
|||
|
||||
class IntlTest extends TestCase
|
||||
{
|
||||
private $defaultLocale;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->defaultLocale = \Locale::getDefault();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
\Locale::setDefault($this->defaultLocale);
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires extension intl
|
||||
*/
|
||||
|
|
|
@ -36,7 +36,7 @@ abstract class AbstractNumberFormatterTest extends TestCase
|
|||
{
|
||||
return [
|
||||
[100, 'ALL', '100'],
|
||||
[100, 'BRL', '100.00'],
|
||||
[100, 'BRL', '100'],
|
||||
[100, 'CRC', '100'],
|
||||
[100, 'JPY', '100'],
|
||||
[100, 'CHF', '100'],
|
||||
|
|
|
@ -87,7 +87,7 @@ class StopwatchTest extends TestCase
|
|||
$event = $stopwatch->stop('foo');
|
||||
|
||||
$this->assertInstanceOf('Symfony\Component\Stopwatch\StopwatchEvent', $event);
|
||||
$this->assertEquals(200, $event->getDuration(), '', self::DELTA);
|
||||
$this->assertEqualsWithDelta(200, $event->getDuration(), self::DELTA);
|
||||
}
|
||||
|
||||
public function testUnknownEvent()
|
||||
|
|
|
@ -41,6 +41,10 @@ class CsvFileLoader extends FileLoader
|
|||
$file->setCsvControl($this->delimiter, $this->enclosure, $this->escape);
|
||||
|
||||
foreach ($file as $data) {
|
||||
if (false === $data) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ('#' !== substr($data[0], 0, 1) && isset($data[1]) && 2 === \count($data)) {
|
||||
$messages[$data[0]] = $data[1];
|
||||
}
|
||||
|
|
|
@ -17,6 +17,22 @@ use Symfony\Component\Translation\IdentityTranslator;
|
|||
|
||||
class IdentityTranslatorTest extends TestCase
|
||||
{
|
||||
private $defaultLocale;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->defaultLocale = \Locale::getDefault();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
\Locale::setDefault($this->defaultLocale);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTransTests
|
||||
*/
|
||||
|
|
|
@ -18,6 +18,22 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
|||
|
||||
class CountryValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
private $defaultLocale;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->defaultLocale = \Locale::getDefault();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
\Locale::setDefault($this->defaultLocale);
|
||||
}
|
||||
|
||||
protected function createValidator()
|
||||
{
|
||||
return new CountryValidator();
|
||||
|
|
|
@ -18,6 +18,22 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
|||
|
||||
class CurrencyValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
private $defaultLocale;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->defaultLocale = \Locale::getDefault();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
\Locale::setDefault($this->defaultLocale);
|
||||
}
|
||||
|
||||
protected function createValidator()
|
||||
{
|
||||
return new CurrencyValidator();
|
||||
|
|
|
@ -18,6 +18,22 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
|||
|
||||
class LanguageValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
private $defaultLocale;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->defaultLocale = \Locale::getDefault();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
\Locale::setDefault($this->defaultLocale);
|
||||
}
|
||||
|
||||
protected function createValidator()
|
||||
{
|
||||
return new LanguageValidator();
|
||||
|
|
|
@ -50,7 +50,7 @@ class RangeValidatorTest extends ConstraintValidatorTestCase
|
|||
[9.99999, '9.99999'],
|
||||
['9.99999', '"9.99999"'],
|
||||
[5, '5'],
|
||||
[1.0, '1.0'],
|
||||
[1.0, '1'],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ class RangeValidatorTest extends ConstraintValidatorTestCase
|
|||
[20.000001, '20.000001'],
|
||||
['20.000001', '"20.000001"'],
|
||||
[21, '21'],
|
||||
[30.0, '30.0'],
|
||||
[30.0, '30'],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,6 @@ Exception {
|
|||
› }
|
||||
}
|
||||
%s%eTests%eCaster%eExceptionCasterTest.php:40 { …}
|
||||
Symfony\Component\VarDumper\Tests\Caster\ExceptionCasterTest->testDefaultSettings() {}
|
||||
%A
|
||||
EODUMP;
|
||||
|
||||
|
@ -71,8 +70,7 @@ EODUMP;
|
|||
› return new \Exception(''.$msg);
|
||||
› }
|
||||
}
|
||||
%s%eTests%eCaster%eExceptionCasterTest.php:65 { …}
|
||||
Symfony\Component\VarDumper\Tests\Caster\ExceptionCasterTest->testSeek() {}
|
||||
%s%eTests%eCaster%eExceptionCasterTest.php:64 { …}
|
||||
%A
|
||||
EODUMP;
|
||||
|
||||
|
@ -96,8 +94,7 @@ Exception {
|
|||
› return new \Exception(''.$msg);
|
||||
› }
|
||||
}
|
||||
%s%eTests%eCaster%eExceptionCasterTest.php:84 { …}
|
||||
Symfony\Component\VarDumper\Tests\Caster\ExceptionCasterTest->testNoArgs() {}
|
||||
%s%eTests%eCaster%eExceptionCasterTest.php:82 { …}
|
||||
%A
|
||||
EODUMP;
|
||||
|
||||
|
|
Reference in New Issue