Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e0dda4f

Browse files
committed
Fix remaining tests
1 parent 87c8561 commit e0dda4f

23 files changed

+167
-23
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
264264
->canBeEnabled()
265265
->beforeNormalization()
266266
->always(function ($v) {
267-
if (true === $v['enabled']) {
267+
if (\is_array($v) && true === $v['enabled']) {
268268
$workflows = $v;
269269
unset($workflows['enabled']);
270270

src/Symfony/Component/Config/Util/XmlUtils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public static function phpize($value)
234234
return true;
235235
case 'false' === $lowercaseValue:
236236
return false;
237-
case isset($value[1]) && '0b' == $value[0].$value[1]:
237+
case isset($value[1]) && '0b' == $value[0].$value[1] && preg_match('/^0b[01]*$/', $value):
238238
return bindec($value);
239239
case is_numeric($value):
240240
return '0x' === $value[0].$value[1] ? hexdec($value) : (float) $value;

src/Symfony/Component/Debug/ErrorHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ public function handleError($type, $message, $file, $line)
470470
}
471471

472472
if ($throw) {
473-
if (E_USER_ERROR & $type) {
473+
if (\PHP_VERSION_ID < 70400 && E_USER_ERROR & $type) {
474474
for ($i = 1; isset($backtrace[$i]); ++$i) {
475475
if (isset($backtrace[$i]['function'], $backtrace[$i]['type'], $backtrace[$i - 1]['function'])
476476
&& '__toString' === $backtrace[$i]['function']

src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,10 @@ public function testHandleError()
283283

284284
public function testHandleUserError()
285285
{
286+
if (\PHP_VERSION_ID >= 70400) {
287+
$this->markTestSkipped('PHP 7.4 allows __toString to throw exceptions');
288+
}
289+
286290
try {
287291
$handler = ErrorHandler::register();
288292
$handler->throwAt(0, true);

src/Symfony/Component/DomCrawler/FormFieldRegistry.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function remove($name)
5757
$target = &$this->fields;
5858
while (\count($segments) > 1) {
5959
$path = array_shift($segments);
60-
if (!\array_key_exists($path, $target)) {
60+
if (!\is_array($target) || !\array_key_exists($path, $target)) {
6161
return;
6262
}
6363
$target = &$target[$path];
@@ -80,7 +80,7 @@ public function &get($name)
8080
$target = &$this->fields;
8181
while ($segments) {
8282
$path = array_shift($segments);
83-
if (!\array_key_exists($path, $target)) {
83+
if (!\is_array($target) || !\array_key_exists($path, $target)) {
8484
throw new \InvalidArgumentException(sprintf('Unreachable field "%s"', $path));
8585
}
8686
$target = &$target[$path];

src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,7 @@ public function testAccept($mode, $expected)
3333
if (!\is_callable($mode)) {
3434
switch ($mode) {
3535
case SortableIterator::SORT_BY_ACCESSED_TIME:
36-
if ('\\' === \DIRECTORY_SEPARATOR) {
37-
touch(self::toAbsolute('.git'));
38-
} else {
39-
file_get_contents(self::toAbsolute('.git'));
40-
}
36+
touch(self::toAbsolute('.git'));
4137
sleep(1);
4238
file_get_contents(self::toAbsolute('.bar'));
4339
break;

src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,7 @@ public function testYearsOption()
471471

472472
public function testMonthsOption()
473473
{
474+
\Locale::setDefault('en');
474475
$form = $this->factory->create(static::TESTED_TYPE, null, [
475476
'months' => [6, 7],
476477
'format' => \IntlDateFormatter::SHORT,
@@ -479,8 +480,8 @@ public function testMonthsOption()
479480
$view = $form->createView();
480481

481482
$this->assertEquals([
482-
new ChoiceView(6, '6', '06'),
483-
new ChoiceView(7, '7', '07'),
483+
new ChoiceView(6, '6', '6'),
484+
new ChoiceView(7, '7', '7'),
484485
], $view['month']->vars['choices']);
485486
}
486487

@@ -544,14 +545,16 @@ public function testMonthsOptionLongFormatWithDifferentTimezone()
544545

545546
public function testIsDayWithinRangeReturnsTrueIfWithin()
546547
{
548+
\Locale::setDefault('en');
547549
$view = $this->factory->create(static::TESTED_TYPE, null, [
548550
'days' => [6, 7],
549551
])
550552
->createView();
551553

554+
552555
$this->assertEquals([
553-
new ChoiceView(6, '6', '06'),
554-
new ChoiceView(7, '7', '07'),
556+
new ChoiceView(6, '6', '6'),
557+
new ChoiceView(7, '7', '7'),
555558
], $view['day']->vars['choices']);
556559
}
557560

src/Symfony/Component/Intl/Tests/Data/Provider/AbstractCurrencyDataProviderTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@ abstract class AbstractCurrencyDataProviderTest extends AbstractDataProviderTest
589589
* @var CurrencyDataProvider
590590
*/
591591
protected $dataProvider;
592+
private $defaultLocale;
592593

593594
protected function setUp()
594595
{
@@ -598,6 +599,15 @@ protected function setUp()
598599
$this->getDataDirectory().'/'.Intl::CURRENCY_DIR,
599600
$this->createEntryReader()
600601
);
602+
603+
$this->defaultLocale = \Locale::getDefault();
604+
}
605+
606+
protected function tearDown()
607+
{
608+
parent::tearDown();
609+
610+
\Locale::setDefault($this->defaultLocale);
601611
}
602612

603613
abstract protected function getDataDirectory();

src/Symfony/Component/Intl/Tests/Data/Provider/AbstractLanguageDataProviderTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,7 @@ abstract class AbstractLanguageDataProviderTest extends AbstractDataProviderTest
831831
* @var LanguageDataProvider
832832
*/
833833
protected $dataProvider;
834+
private $defaultLocale;
834835

835836
protected function setUp()
836837
{
@@ -840,6 +841,15 @@ protected function setUp()
840841
$this->getDataDirectory().'/'.Intl::LANGUAGE_DIR,
841842
$this->createEntryReader()
842843
);
844+
845+
$this->defaultLocale = \Locale::getDefault();
846+
}
847+
848+
protected function tearDown()
849+
{
850+
parent::tearDown();
851+
852+
\Locale::setDefault($this->defaultLocale);
843853
}
844854

845855
abstract protected function getDataDirectory();

src/Symfony/Component/Intl/Tests/Data/Provider/AbstractLocaleDataProviderTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ abstract class AbstractLocaleDataProviderTest extends AbstractDataProviderTest
2323
* @var LocaleDataProvider
2424
*/
2525
protected $dataProvider;
26+
private $defaultLocale;
2627

2728
protected function setUp()
2829
{
@@ -32,6 +33,13 @@ protected function setUp()
3233
$this->getDataDirectory().'/'.Intl::LOCALE_DIR,
3334
$this->createEntryReader()
3435
);
36+
37+
$this->defaultLocale = \Locale::getDefault();
38+
}
39+
40+
protected function tearDown()
41+
{
42+
\Locale::setDefault($this->defaultLocale);
3543
}
3644

3745
abstract protected function getDataDirectory();

src/Symfony/Component/Intl/Tests/Data/Provider/AbstractRegionDataProviderTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ abstract class AbstractRegionDataProviderTest extends AbstractDataProviderTest
283283
* @var RegionDataProvider
284284
*/
285285
protected $dataProvider;
286+
private $defaultLocale;
286287

287288
protected function setUp()
288289
{
@@ -292,6 +293,15 @@ protected function setUp()
292293
$this->getDataDirectory().'/'.Intl::REGION_DIR,
293294
$this->createEntryReader()
294295
);
296+
297+
$this->defaultLocale = \Locale::getDefault();
298+
}
299+
300+
protected function tearDown()
301+
{
302+
parent::tearDown();
303+
304+
\Locale::setDefault($this->defaultLocale);
295305
}
296306

297307
abstract protected function getDataDirectory();

src/Symfony/Component/Intl/Tests/Data/Provider/AbstractScriptDataProviderTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ abstract class AbstractScriptDataProviderTest extends AbstractDataProviderTest
219219
* @var ScriptDataProvider
220220
*/
221221
protected $dataProvider;
222+
private $defaultLocale;
222223

223224
protected function setUp()
224225
{
@@ -228,6 +229,15 @@ protected function setUp()
228229
$this->getDataDirectory().'/'.Intl::SCRIPT_DIR,
229230
$this->createEntryReader()
230231
);
232+
233+
$this->defaultLocale = \Locale::getDefault();
234+
}
235+
236+
protected function tearDown()
237+
{
238+
parent::tearDown();
239+
240+
\Locale::setDefault($this->defaultLocale);
231241
}
232242

233243
abstract protected function getDataDirectory();

src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,23 @@
2424
*/
2525
abstract class AbstractIntlDateFormatterTest extends TestCase
2626
{
27+
private $defaultLocale;
28+
2729
protected function setUp()
2830
{
31+
parent::setUp();
32+
33+
$this->defaultLocale = \Locale::getDefault();
2934
\Locale::setDefault('en');
3035
}
3136

37+
protected function tearDown()
38+
{
39+
parent::tearDown();
40+
41+
\Locale::setDefault($this->defaultLocale);
42+
}
43+
3244
/**
3345
* When a time zone is not specified, it uses the system default however it returns null in the getter method.
3446
*

src/Symfony/Component/Intl/Tests/IntlTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@
1616

1717
class IntlTest extends TestCase
1818
{
19+
private $defaultLocale;
20+
21+
protected function setUp()
22+
{
23+
parent::setUp();
24+
25+
$this->defaultLocale = \Locale::getDefault();
26+
}
27+
28+
protected function tearDown()
29+
{
30+
parent::tearDown();
31+
32+
\Locale::setDefault($this->defaultLocale);
33+
}
34+
1935
/**
2036
* @requires extension intl
2137
*/

src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function formatCurrencyWithDecimalStyleProvider()
3636
{
3737
return [
3838
[100, 'ALL', '100'],
39-
[100, 'BRL', '100.00'],
39+
[100, 'BRL', '100'],
4040
[100, 'CRC', '100'],
4141
[100, 'JPY', '100'],
4242
[100, 'CHF', '100'],

src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function testStop()
8787
$event = $stopwatch->stop('foo');
8888

8989
$this->assertInstanceOf('Symfony\Component\Stopwatch\StopwatchEvent', $event);
90-
$this->assertEquals(200, $event->getDuration(), '', self::DELTA);
90+
$this->assertEqualsWithDelta(200, $event->getDuration(), self::DELTA);
9191
}
9292

9393
public function testUnknownEvent()

src/Symfony/Component/Translation/Loader/CsvFileLoader.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ protected function loadResource($resource)
4141
$file->setCsvControl($this->delimiter, $this->enclosure, $this->escape);
4242

4343
foreach ($file as $data) {
44+
if (false === $data) {
45+
continue;
46+
}
47+
4448
if ('#' !== substr($data[0], 0, 1) && isset($data[1]) && 2 === \count($data)) {
4549
$messages[$data[0]] = $data[1];
4650
}

src/Symfony/Component/Translation/Tests/IdentityTranslatorTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,22 @@
1717

1818
class IdentityTranslatorTest extends TestCase
1919
{
20+
private $defaultLocale;
21+
22+
protected function setUp()
23+
{
24+
parent::setUp();
25+
26+
$this->defaultLocale = \Locale::getDefault();
27+
}
28+
29+
protected function tearDown()
30+
{
31+
parent::tearDown();
32+
33+
\Locale::setDefault($this->defaultLocale);
34+
}
35+
2036
/**
2137
* @dataProvider getTransTests
2238
*/

src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,22 @@
1818

1919
class CountryValidatorTest extends ConstraintValidatorTestCase
2020
{
21+
private $defaultLocale;
22+
23+
protected function setUp()
24+
{
25+
parent::setUp();
26+
27+
$this->defaultLocale = \Locale::getDefault();
28+
}
29+
30+
protected function tearDown()
31+
{
32+
parent::tearDown();
33+
34+
\Locale::setDefault($this->defaultLocale);
35+
}
36+
2137
protected function createValidator()
2238
{
2339
return new CountryValidator();

src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,22 @@
1818

1919
class CurrencyValidatorTest extends ConstraintValidatorTestCase
2020
{
21+
private $defaultLocale;
22+
23+
protected function setUp()
24+
{
25+
parent::setUp();
26+
27+
$this->defaultLocale = \Locale::getDefault();
28+
}
29+
30+
protected function tearDown()
31+
{
32+
parent::tearDown();
33+
34+
\Locale::setDefault($this->defaultLocale);
35+
}
36+
2137
protected function createValidator()
2238
{
2339
return new CurrencyValidator();

src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,22 @@
1818

1919
class LanguageValidatorTest extends ConstraintValidatorTestCase
2020
{
21+
private $defaultLocale;
22+
23+
protected function setUp()
24+
{
25+
parent::setUp();
26+
27+
$this->defaultLocale = \Locale::getDefault();
28+
}
29+
30+
protected function tearDown()
31+
{
32+
parent::tearDown();
33+
34+
\Locale::setDefault($this->defaultLocale);
35+
}
36+
2137
protected function createValidator()
2238
{
2339
return new LanguageValidator();

0 commit comments

Comments
 (0)