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

Skip to content

Use PHPUnit 9.6 to run Symfony's test suite #49233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions phpunit
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Comment on lines -13 to -14
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a leftover from Symfony 4 wasn't it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd keep this, the bridge is still declared as compatible with <7.2

} 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}

/**
Expand Down Expand Up @@ -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();
}
}

/**
Expand Down Expand Up @@ -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()
Expand All @@ -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;
}
}