1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

[ticket/17176] Remove no longer needed backward compatible phpunit code

PHPBB3-17176
This commit is contained in:
Marc Alexander
2023-09-07 20:49:59 +02:00
parent 5d6218dcba
commit 4078ed7e20
15 changed files with 27 additions and 181 deletions

View File

@@ -29,8 +29,6 @@ abstract class phpbb_database_test_case extends TestCase
protected static $install_schema_file;
protected static $phpunit_version;
/**
* @var \Doctrine\DBAL\Connection[]
*/
@@ -40,9 +38,7 @@ abstract class phpbb_database_test_case extends TestCase
{
parent::__construct($name, $data, $dataName);
self::$phpunit_version = PHPUnit\Runner\Version::id();
$backupStaticAttributesBlacklist = [
$this->backupStaticAttributesExcludeList += [
'SebastianBergmann\CodeCoverage\CodeCoverage' => ['instance'],
'SebastianBergmann\CodeCoverage\Filter' => ['instance'],
'SebastianBergmann\CodeCoverage\Util' => ['ignoredLines', 'templateMethods'],
@@ -53,15 +49,6 @@ abstract class phpbb_database_test_case extends TestCase
'phpbb_database_test_case' => ['already_connected'],
];
if (version_compare(self::$phpunit_version, '9.0', '>='))
{
$this->backupStaticAttributesExcludeList += $backupStaticAttributesBlacklist;
}
else
{
$this->backupStaticAttributesBlacklist += $backupStaticAttributesBlacklist;
}
$this->db_connections = [];
$this->db_connections_doctrine = [];
}
@@ -411,56 +398,4 @@ abstract class phpbb_database_test_case extends TestCase
return $core_tables;
}
/**
* PHPUnit deprecates several methods and properties in its recent versions
* Provide BC layer to be able to test in multiple environment settings
*/
public function expectException(string $exception): void
{
if (version_compare(self::$phpunit_version, '9.0', '>='))
{
switch ($exception) {
case PHPUnit\Framework\Error\Deprecated::class:
parent::expectDeprecation();
break;
case PHPUnit\Framework\Error\Error::class:
parent::expectError();
break;
case PHPUnit\Framework\Error\Notice::class:
parent::expectNotice();
break;
case PHPUnit\Framework\Error\Warning::class:
parent::expectWarning();
break;
default:
parent::expectException($exception);
break;
}
}
else
{
parent::expectException($exception);
}
}
/**
* PHPUnit deprecates several methods and properties in its recent versions
* Provide BC layer to be able to test in multiple environment settings
*/
public static function assertFileNotExists(string $filename, string $message = ''): void
{
if (version_compare(self::$phpunit_version, '9.0', '>='))
{
parent::assertFileDoesNotExist($filename, $message);
}
else
{
parent::assertFileNotExists($filename, $message);
}
}
}

View File

@@ -208,10 +208,9 @@ class phpbb_functional_test_case extends phpbb_test_case
{
parent::__construct($name, $data, $dataName);
$backupStaticAttributesBlacklist = [
$this->backupStaticAttributesExcludeList += [
'phpbb_functional_test_case' => ['config', 'already_installed'],
];
$this->excludeBackupStaticAttributes($backupStaticAttributesBlacklist);
}
protected function get_db()

View File

@@ -16,15 +16,12 @@ use PHPUnit\Framework\TestCase;
class phpbb_test_case extends TestCase
{
protected $test_case_helpers;
protected static $phpunit_version;
public function __construct($name = NULL, array $data = array(), $dataName = '')
{
parent::__construct($name, $data, $dataName);
self::$phpunit_version = PHPUnit\Runner\Version::id();
$backupStaticAttributesBlacklist = [
$this->backupStaticAttributesExcludeList += [
'SebastianBergmann\CodeCoverage\CodeCoverage' => ['instance'],
'SebastianBergmann\CodeCoverage\Filter' => ['instance'],
'SebastianBergmann\CodeCoverage\Util' => ['ignoredLines', 'templateMethods'],
@@ -34,7 +31,6 @@ class phpbb_test_case extends TestCase
'phpbb_database_test_case' => ['already_connected', 'last_post_timestamp'],
];
$this->excludeBackupStaticAttributes($backupStaticAttributesBlacklist);
}
public function get_test_case_helpers()
@@ -51,88 +47,4 @@ class phpbb_test_case extends TestCase
{
$this->get_test_case_helpers()->setExpectedTriggerError($errno, $message);
}
/**
* PHPUnit deprecates several methods and properties in its recent versions
* Provide BC layer to be able to test in multiple environment settings
*/
public function excludeBackupStaticAttributes($attributes_array)
{
if (version_compare(self::$phpunit_version, '9.0', '>='))
{
$this->backupStaticAttributesExcludeList += $attributes_array;
}
else
{
$this->backupStaticAttributesBlacklist += $attributes_array;
}
}
/**
* PHPUnit deprecates several methods and properties in its recent versions
* Provide BC layer to be able to test in multiple environment settings
*/
public static function assertRegExp(string $pattern, string $string, string $message = ''): void
{
if (version_compare(self::$phpunit_version, '9.0', '>='))
{
parent::assertMatchesRegularExpression($pattern, $string, $message);
}
else
{
parent::assertRegExp($pattern, $string, $message);
}
}
/**
* PHPUnit deprecates several methods and properties in its recent versions
* Provide BC layer to be able to test in multiple environment settings
*/
public function expectException(string $exception): void
{
if (version_compare(self::$phpunit_version, '9.0', '>='))
{
switch ($exception) {
case PHPUnit\Framework\Error\Deprecated::class:
parent::expectDeprecation();
break;
case PHPUnit\Framework\Error\Error::class:
parent::expectError();
break;
case PHPUnit\Framework\Error\Notice::class:
parent::expectNotice();
break;
case PHPUnit\Framework\Error\Warning::class:
parent::expectWarning();
break;
default:
parent::expectException($exception);
break;
}
}
else
{
parent::expectException($exception);
}
}
/**
* PHPUnit deprecates several methods and properties in its recent versions
* Provide BC layer to be able to test in multiple environment settings
*/
public static function assertFileNotExists(string $filename, string $message = ''): void
{
if (version_compare(self::$phpunit_version, '9.0', '>='))
{
parent::assertFileDoesNotExist($filename, $message);
}
else
{
parent::assertFileNotExists($filename, $message);
}
}
}