mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 11:58:51 +00:00
[ticket/17176] Remove no longer needed backward compatible phpunit code
PHPBB3-17176
This commit is contained in:
parent
5d6218dcba
commit
4078ed7e20
15 changed files with 27 additions and 181 deletions
|
@ -38,6 +38,6 @@ class phpbb_functional_acp_smilies_test extends phpbb_functional_test_case
|
|||
$crawler = self::submit($form);
|
||||
|
||||
$html = $crawler->filter('#preview')->html();
|
||||
$this->assertRegexp('(<img [^>]+ alt=">:D" title=">:D"[^>]*>)', $html);
|
||||
$this->assertMatchesRegularExpression('(<img [^>]+ alt=">:D" title=">:D"[^>]*>)', $html);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,9 +30,9 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
|
|||
{
|
||||
parent::__construct($name, $data, $dataName);
|
||||
|
||||
$this->excludeBackupStaticAttributes([
|
||||
$this->backupStaticAttributesExcludeList += [
|
||||
'phpbb_functional_feed_test' => ['init_values'],
|
||||
]);
|
||||
];
|
||||
|
||||
$this->purge_cache();
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
|
|||
|
||||
$crawler = self::request('GET', "posting.php?mode=quote&p={$post['post_id']}&sid={$this->sid}");
|
||||
|
||||
$this->assertRegexp($expected, $crawler->filter('textarea#message')->text());
|
||||
$this->assertMatchesRegularExpression($expected, $crawler->filter('textarea#message')->text());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -122,7 +122,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
|
|||
{
|
||||
$this->set_quote_depth($quote_depth);
|
||||
$crawler = self::request('GET', $quote_url);
|
||||
$this->assertRegexp(
|
||||
$this->assertMatchesRegularExpression(
|
||||
"(\[quote=admin[^\]]*\]\s?" . preg_quote($expected_text) . "\s?\[\/quote\])",
|
||||
$crawler->filter('textarea#message')->text()
|
||||
);
|
||||
|
|
|
@ -79,7 +79,7 @@ class phpbb_functional_private_messages_test extends phpbb_functional_test_case
|
|||
|
||||
$crawler = self::request('GET', 'ucp.php?i=pm&mode=compose&action=quotepost&p=' . $post['post_id'] . '&sid=' . $this->sid);
|
||||
|
||||
$this->assertRegexp($expected, $crawler->filter('textarea#message')->text());
|
||||
$this->assertMatchesRegularExpression($expected, $crawler->filter('textarea#message')->text());
|
||||
}
|
||||
|
||||
public function test_quote_pm()
|
||||
|
@ -92,7 +92,7 @@ class phpbb_functional_private_messages_test extends phpbb_functional_test_case
|
|||
|
||||
$crawler = self::request('GET', 'ucp.php?i=pm&mode=compose&action=quote&p=' . $message_id . '&sid=' . $this->sid);
|
||||
|
||||
$this->assertRegexp($expected, $crawler->filter('textarea#message')->text());
|
||||
$this->assertMatchesRegularExpression($expected, $crawler->filter('textarea#message')->text());
|
||||
}
|
||||
|
||||
public function test_quote_forward()
|
||||
|
@ -105,6 +105,6 @@ class phpbb_functional_private_messages_test extends phpbb_functional_test_case
|
|||
|
||||
$crawler = self::request('GET', 'ucp.php?i=pm&mode=compose&action=forward&f=0&p=' . $message_id . '&sid=' . $this->sid);
|
||||
|
||||
$this->assertRegexp($expected, $crawler->filter('textarea#message')->text());
|
||||
$this->assertMatchesRegularExpression($expected, $crawler->filter('textarea#message')->text());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,9 +22,9 @@ class phpbb_functional_ucp_allow_pm_test extends phpbb_functional_test_case
|
|||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->excludeBackupStaticAttributes([
|
||||
$this->backupStaticAttributesExcludeList += [
|
||||
'phpbb_functional_ucp_allow_pm_test' => ['data'],
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
// user A sends a PM to user B where B accepts PM
|
||||
|
|
|
@ -44,7 +44,7 @@ class phpbb_random_gen_rand_string_test extends phpbb_test_case
|
|||
$random_string_length == $num_chars,
|
||||
sprintf('Failed asserting that random string length matches expected length. Expected %1$u, Actual %2$u', $num_chars, $random_string_length)
|
||||
);
|
||||
$this->assertRegExp('#^[A-Z0-9]+$#', $random_string);
|
||||
$this->assertMatchesRegularExpression('#^[A-Z0-9]+$#', $random_string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ class phpbb_random_gen_rand_string_test extends phpbb_test_case
|
|||
$random_string_length == $num_chars,
|
||||
sprintf('Failed asserting that random string length matches expected length. Expected %1$u, Actual %2$u', $num_chars, $random_string_length)
|
||||
);
|
||||
$this->assertRegExp('#^[A-NP-Z1-9]+$#', $random_string);
|
||||
$this->assertMatchesRegularExpression('#^[A-NP-Z1-9]+$#', $random_string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,6 @@ class phpbb_regex_censor_test extends phpbb_test_case
|
|||
{
|
||||
$regex = get_censor_preg_expression($pattern);
|
||||
|
||||
$this->assertRegExp($regex, $subject);
|
||||
$this->assertMatchesRegularExpression($regex, $subject);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,8 +88,8 @@ class phpbb_storage_adapter_local_subfolders_test extends phpbb_local_test_case
|
|||
$this->adapter->delete('file.txt');
|
||||
|
||||
// Then
|
||||
$this->assertFileNotExists($this->path . '3d/8e/file.txt');
|
||||
$this->assertFileNotExists($this->path . '3d');
|
||||
$this->assertFileDoesNotExist($this->path . '3d/8e/file.txt');
|
||||
$this->assertFileDoesNotExist($this->path . '3d');
|
||||
}
|
||||
|
||||
public function test_rename(): void
|
||||
|
@ -102,9 +102,9 @@ class phpbb_storage_adapter_local_subfolders_test extends phpbb_local_test_case
|
|||
$this->adapter->rename('file.txt', 'file2.txt');
|
||||
|
||||
// Then
|
||||
$this->assertFileNotExists($this->path . '3d/8e/file.txt');
|
||||
$this->assertFileDoesNotExist($this->path . '3d/8e/file.txt');
|
||||
$this->assertFileExists($this->path . '27/36/file2.txt');
|
||||
$this->assertFileNotExists($this->path . '3d');
|
||||
$this->assertFileDoesNotExist($this->path . '3d');
|
||||
|
||||
// Clean test
|
||||
unlink($this->path . '27/36/file2.txt');
|
||||
|
|
|
@ -77,7 +77,7 @@ class phpbb_storage_adapter_local_test extends phpbb_local_test_case
|
|||
$this->adapter->delete('file.txt');
|
||||
|
||||
// Then
|
||||
$this->assertFileNotExists($this->path . 'file.txt');
|
||||
$this->assertFileDoesNotExist($this->path . 'file.txt');
|
||||
}
|
||||
|
||||
public function test_rename(): void
|
||||
|
@ -85,13 +85,13 @@ class phpbb_storage_adapter_local_test extends phpbb_local_test_case
|
|||
// Given
|
||||
touch($this->path . 'file.txt');
|
||||
$this->assertFileExists($this->path . 'file.txt');
|
||||
$this->assertFileNotExists($this->path . 'file2.txt');
|
||||
$this->assertFileDoesNotExist($this->path . 'file2.txt');
|
||||
|
||||
// When
|
||||
$this->adapter->rename('file.txt', 'file2.txt');
|
||||
|
||||
// Then
|
||||
$this->assertFileNotExists($this->path . 'file.txt');
|
||||
$this->assertFileDoesNotExist($this->path . 'file.txt');
|
||||
$this->assertFileExists($this->path . 'file2.txt');
|
||||
|
||||
// Clean test
|
||||
|
|
|
@ -528,7 +528,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
|
|||
$filename = 'file_not_found.html';
|
||||
|
||||
$this->template->set_filenames(array('test' => $filename));
|
||||
$this->assertFileNotExists($this->template_path . '/' . $filename, 'Testing missing file, file cannot exist');
|
||||
$this->assertFileDoesNotExist($this->template_path . '/' . $filename, 'Testing missing file, file cannot exist');
|
||||
|
||||
$this->expectException(\Twig\Error\LoaderError::class);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case
|
|||
$factory->tidy();
|
||||
|
||||
$this->assertFileExists($new_file, 'The current renderer has been deleted');
|
||||
$this->assertFileNotExists($old_file, 'The old renderer has not been deleted');
|
||||
$this->assertFileDoesNotExist($old_file, 'The old renderer has not been deleted');
|
||||
|
||||
unlink($new_file);
|
||||
}
|
||||
|
|
|
@ -230,7 +230,7 @@ class phpbb_filespec_test extends phpbb_test_case
|
|||
$name = $filespec->get('realname');
|
||||
|
||||
$this->assertEquals(strlen($name), 32 + strlen(self::PREFIX));
|
||||
$this->assertRegExp('#^[A-Za-z0-9]+$#', substr($name, strlen(self::PREFIX)));
|
||||
$this->assertMatchesRegularExpression('#^[A-Za-z0-9]+$#', substr($name, strlen(self::PREFIX)));
|
||||
$this->assertFalse(isset($filenames[$name]));
|
||||
$filenames[$name] = true;
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ class phpbb_filespec_test extends phpbb_test_case
|
|||
$name = $filespec->get('realname');
|
||||
|
||||
$this->assertEquals(strlen($name), 32 + strlen(self::PREFIX) + strlen('.jpg'));
|
||||
$this->assertRegExp('#^[A-Za-z0-9]+\.jpg$#', substr($name, strlen(self::PREFIX)));
|
||||
$this->assertMatchesRegularExpression('#^[A-Za-z0-9]+\.jpg$#', substr($name, strlen(self::PREFIX)));
|
||||
$this->assertFalse(isset($filenames[$name]));
|
||||
$filenames[$name] = true;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue