diff --git a/phpunit b/phpunit index e26fecd73cc9d..3ab931750e179 100755 --- a/phpunit +++ b/phpunit @@ -10,12 +10,10 @@ if (!file_exists(__DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) { exit(1); } if (!getenv('SYMFONY_PHPUNIT_VERSION')) { - if (\PHP_VERSION_ID < 70200) { - putenv('SYMFONY_PHPUNIT_VERSION=7.5'); - } elseif (\PHP_VERSION_ID < 70300) { + if (\PHP_VERSION_ID < 70300) { putenv('SYMFONY_PHPUNIT_VERSION=8.5.26'); } else { - putenv('SYMFONY_PHPUNIT_VERSION=9.5'); + putenv('SYMFONY_PHPUNIT_VERSION=9.6'); } } if (!getenv('SYMFONY_PATCH_TYPE_DECLARATIONS') && \PHP_VERSION_ID >= 70300) { diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/ConfigurationTest.php b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/ConfigurationTest.php index 09a2a32054b69..9170605a5aa9a 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/ConfigurationTest.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/ConfigurationTest.php @@ -482,10 +482,24 @@ public function testBaselineFileWriteError() { $filename = $this->createFile(); chmod($filename, 0444); - $this->expectError(); - $this->expectErrorMessageMatches('/[Ff]ailed to open stream: Permission denied/'); $configuration = Configuration::fromUrlEncodedString('generateBaseline=true&baselineFile='.urlencode($filename)); - $configuration->writeBaseline(); + + $this->expectException(\ErrorException::class); + $this->expectExceptionMessageMatches('/[Ff]ailed to open stream: Permission denied/'); + + set_error_handler(static function (int $errno, string $errstr, string $errfile = null, int $errline = null): bool { + if ($errno & (E_WARNING | E_WARNING)) { + throw new \ErrorException($errstr, 0, $errno, $errfile, $errline); + } + + return false; + }); + + try { + $configuration->writeBaseline(); + } finally { + restore_error_handler(); + } } protected function setUp(): void diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ButtonTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ButtonTypeTest.php index afb5f820827d8..0125631c582c6 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ButtonTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ButtonTypeTest.php @@ -72,7 +72,7 @@ public function testFormAttrOnChild() public function testFormAttrAsBoolWithNoId() { $this->expectException(LogicException::class); - $this->expectErrorMessage('form_attr'); + $this->expectExceptionMessage('form_attr'); $this->factory ->createNamedBuilder('', FormType::class, null, [ 'form_attr' => true, diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php index 3f535d89a5cbc..1d2ff4ff12003 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php @@ -809,7 +809,7 @@ public function testFormAttrOnChild() public function testFormAttrAsBoolWithNoId() { $this->expectException(LogicException::class); - $this->expectErrorMessage('form_attr'); + $this->expectExceptionMessage('form_attr'); $this->factory ->createNamedBuilder('', self::TESTED_TYPE, null, [ 'form_attr' => true, diff --git a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php index 0b7de5767ae7c..295b908d29fd2 100644 --- a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php @@ -11,7 +11,6 @@ namespace Symfony\Component\Intl\Tests\NumberFormatter; -use PHPUnit\Framework\Error\Warning; use PHPUnit\Framework\TestCase; use Symfony\Component\Intl\Globals\IntlGlobals; use Symfony\Component\Intl\NumberFormatter\NumberFormatter; @@ -328,13 +327,17 @@ public function testFormatTypeCurrency($formatter, $value) { if (\PHP_VERSION_ID >= 80000) { $this->expectException(\ValueError::class); - } elseif (method_exists($this, 'expectWarning')) { - $this->expectWarning(); } else { - $this->expectException(Warning::class); + $this->expectException(\ErrorException::class); } - $formatter->format($value, NumberFormatter::TYPE_CURRENCY); + set_error_handler([self::class, 'throwOnWarning']); + + try { + $formatter->format($value, NumberFormatter::TYPE_CURRENCY); + } finally { + restore_error_handler(); + } } /** @@ -705,16 +708,21 @@ public static function parseProvider() public function testParseTypeDefault() { + $formatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL); + if (\PHP_VERSION_ID >= 80000) { $this->expectException(\ValueError::class); - } elseif (method_exists($this, 'expectWarning')) { - $this->expectWarning(); } else { - $this->expectException(Warning::class); + $this->expectException(\ErrorException::class); } - $formatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL); - $formatter->parse('1', NumberFormatter::TYPE_DEFAULT); + set_error_handler([self::class, 'throwOnWarning']); + + try { + $formatter->parse('1', NumberFormatter::TYPE_DEFAULT); + } finally { + restore_error_handler(); + } } /** @@ -831,16 +839,21 @@ public static function parseTypeDoubleProvider() public function testParseTypeCurrency() { + $formatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL); + if (\PHP_VERSION_ID >= 80000) { $this->expectException(\ValueError::class); - } elseif (method_exists($this, 'expectWarning')) { - $this->expectWarning(); } else { - $this->expectException(Warning::class); + $this->expectException(\ErrorException::class); } - $formatter = static::getNumberFormatter('en', NumberFormatter::DECIMAL); - $formatter->parse('1', NumberFormatter::TYPE_CURRENCY); + set_error_handler([self::class, 'throwOnWarning']); + + try { + $formatter->parse('1', NumberFormatter::TYPE_CURRENCY); + } finally { + restore_error_handler(); + } } public function testParseWithNotNullPositionValue() @@ -864,4 +877,13 @@ abstract protected function getIntlErrorCode(): int; * @param int $errorCode */ abstract protected function isIntlFailure($errorCode): bool; + + public static function throwOnWarning(int $errno, string $errstr, string $errfile = null, int $errline = null): bool + { + if ($errno & (\E_WARNING | \E_USER_WARNING)) { + throw new \ErrorException($errstr, 0, $errno, $errfile ?? __FILE__, $errline ?? __LINE__); + } + + return false; + } }