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

Skip to content

Commit c7a7cb8

Browse files
minor #49233 Use PHPUnit 9.6 to run Symfony's test suite (derrabus)
This PR was merged into the 5.4 branch. Discussion ---------- Use PHPUnit 9.6 to run Symfony's test suite | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | N/A | License | MIT | Doc PR | N/A Let's use PHPUnit 9.6 to run test test suite if we can. Commits ------- e1ca0aa Use PHPUnit 9.6 to run Symfony's test suite
2 parents c15367e + e1ca0aa commit c7a7cb8

File tree

5 files changed

+58
-24
lines changed

5 files changed

+58
-24
lines changed

phpunit

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@ if (!file_exists(__DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) {
1010
exit(1);
1111
}
1212
if (!getenv('SYMFONY_PHPUNIT_VERSION')) {
13-
if (\PHP_VERSION_ID < 70200) {
14-
putenv('SYMFONY_PHPUNIT_VERSION=7.5');
15-
} elseif (\PHP_VERSION_ID < 70300) {
13+
if (\PHP_VERSION_ID < 70300) {
1614
putenv('SYMFONY_PHPUNIT_VERSION=8.5.26');
1715
} else {
18-
putenv('SYMFONY_PHPUNIT_VERSION=9.5');
16+
putenv('SYMFONY_PHPUNIT_VERSION=9.6');
1917
}
2018
}
2119
if (!getenv('SYMFONY_PATCH_TYPE_DECLARATIONS') && \PHP_VERSION_ID >= 70300) {

src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/ConfigurationTest.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,10 +482,24 @@ public function testBaselineFileWriteError()
482482
{
483483
$filename = $this->createFile();
484484
chmod($filename, 0444);
485-
$this->expectError();
486-
$this->expectErrorMessageMatches('/[Ff]ailed to open stream: Permission denied/');
487485
$configuration = Configuration::fromUrlEncodedString('generateBaseline=true&baselineFile='.urlencode($filename));
488-
$configuration->writeBaseline();
486+
487+
$this->expectException(\ErrorException::class);
488+
$this->expectExceptionMessageMatches('/[Ff]ailed to open stream: Permission denied/');
489+
490+
set_error_handler(static function (int $errno, string $errstr, string $errfile = null, int $errline = null): bool {
491+
if ($errno & (E_WARNING | E_WARNING)) {
492+
throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
493+
}
494+
495+
return false;
496+
});
497+
498+
try {
499+
$configuration->writeBaseline();
500+
} finally {
501+
restore_error_handler();
502+
}
489503
}
490504

491505
protected function setUp(): void

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function testFormAttrOnChild()
7272
public function testFormAttrAsBoolWithNoId()
7373
{
7474
$this->expectException(LogicException::class);
75-
$this->expectErrorMessage('form_attr');
75+
$this->expectExceptionMessage('form_attr');
7676
$this->factory
7777
->createNamedBuilder('', FormType::class, null, [
7878
'form_attr' => true,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ public function testFormAttrOnChild()
809809
public function testFormAttrAsBoolWithNoId()
810810
{
811811
$this->expectException(LogicException::class);
812-
$this->expectErrorMessage('form_attr');
812+
$this->expectExceptionMessage('form_attr');
813813
$this->factory
814814
->createNamedBuilder('', self::TESTED_TYPE, null, [
815815
'form_attr' => true,

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

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Component\Intl\Tests\NumberFormatter;
1313

14-
use PHPUnit\Framework\Error\Warning;
1514
use PHPUnit\Framework\TestCase;
1615
use Symfony\Component\Intl\Globals\IntlGlobals;
1716
use Symfony\Component\Intl\NumberFormatter\NumberFormatter;
@@ -328,13 +327,17 @@ public function testFormatTypeCurrency($formatter, $value)
328327
{
329328
if (\PHP_VERSION_ID >= 80000) {
330329
$this->expectException(\ValueError::class);
331-
} elseif (method_exists($this, 'expectWarning')) {
332-
$this->expectWarning();
333330
} else {
334-
$this->expectException(Warning::class);
331+
$this->expectException(\ErrorException::class);
335332
}
336333

337-
$formatter->format($value, NumberFormatter::TYPE_CURRENCY);
334+
set_error_handler([self::class, 'throwOnWarning']);
335+
336+
try {
337+
$formatter->format($value, NumberFormatter::TYPE_CURRENCY);
338+
} finally {
339+
restore_error_handler();
340+
}
338341
}
339342

340343
/**
@@ -705,16 +708,21 @@ public static function parseProvider()
705708

706709
public function testParseTypeDefault()
707710
{
711+
$formatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL);
712+
708713
if (\PHP_VERSION_ID >= 80000) {
709714
$this->expectException(\ValueError::class);
710-
} elseif (method_exists($this, 'expectWarning')) {
711-
$this->expectWarning();
712715
} else {
713-
$this->expectException(Warning::class);
716+
$this->expectException(\ErrorException::class);
714717
}
715718

716-
$formatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL);
717-
$formatter->parse('1', NumberFormatter::TYPE_DEFAULT);
719+
set_error_handler([self::class, 'throwOnWarning']);
720+
721+
try {
722+
$formatter->parse('1', NumberFormatter::TYPE_DEFAULT);
723+
} finally {
724+
restore_error_handler();
725+
}
718726
}
719727

720728
/**
@@ -831,16 +839,21 @@ public static function parseTypeDoubleProvider()
831839

832840
public function testParseTypeCurrency()
833841
{
842+
$formatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL);
843+
834844
if (\PHP_VERSION_ID >= 80000) {
835845
$this->expectException(\ValueError::class);
836-
} elseif (method_exists($this, 'expectWarning')) {
837-
$this->expectWarning();
838846
} else {
839-
$this->expectException(Warning::class);
847+
$this->expectException(\ErrorException::class);
840848
}
841849

842-
$formatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL);
843-
$formatter->parse('1', NumberFormatter::TYPE_CURRENCY);
850+
set_error_handler([self::class, 'throwOnWarning']);
851+
852+
try {
853+
$formatter->parse('1', NumberFormatter::TYPE_CURRENCY);
854+
} finally {
855+
restore_error_handler();
856+
}
844857
}
845858

846859
public function testParseWithNotNullPositionValue()
@@ -864,4 +877,13 @@ abstract protected function getIntlErrorCode(): int;
864877
* @param int $errorCode
865878
*/
866879
abstract protected function isIntlFailure($errorCode): bool;
880+
881+
public static function throwOnWarning(int $errno, string $errstr, string $errfile = null, int $errline = null): bool
882+
{
883+
if ($errno & (\E_WARNING | \E_USER_WARNING)) {
884+
throw new \ErrorException($errstr, 0, $errno, $errfile ?? __FILE__, $errline ?? __LINE__);
885+
}
886+
887+
return false;
888+
}
867889
}

0 commit comments

Comments
 (0)