diff --git a/tests/functional/acp_smilies_test.php b/tests/functional/acp_smilies_test.php
index c24b884dd0..955a00b488 100644
--- a/tests/functional/acp_smilies_test.php
+++ b/tests/functional/acp_smilies_test.php
@@ -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('(
]+ alt=">:D" title=">:D"[^>]*>)', $html);
+ $this->assertMatchesRegularExpression('(
]+ alt=">:D" title=">:D"[^>]*>)', $html);
}
}
diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php
index fc0115a063..984f3da0d5 100644
--- a/tests/functional/feed_test.php
+++ b/tests/functional/feed_test.php
@@ -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();
}
diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php
index 1c1544a533..9f8b299756 100644
--- a/tests/functional/posting_test.php
+++ b/tests/functional/posting_test.php
@@ -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()
);
diff --git a/tests/functional/private_messages_test.php b/tests/functional/private_messages_test.php
index 087f6d5891..1f31fda240 100644
--- a/tests/functional/private_messages_test.php
+++ b/tests/functional/private_messages_test.php
@@ -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());
}
}
diff --git a/tests/functional/ucp_allow_pm_test.php b/tests/functional/ucp_allow_pm_test.php
index 0b57e4119b..6c275ad916 100644
--- a/tests/functional/ucp_allow_pm_test.php
+++ b/tests/functional/ucp_allow_pm_test.php
@@ -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
diff --git a/tests/random/gen_rand_string_test.php b/tests/random/gen_rand_string_test.php
index 13ca0df245..cb89a1703e 100644
--- a/tests/random/gen_rand_string_test.php
+++ b/tests/random/gen_rand_string_test.php
@@ -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);
}
}
}
diff --git a/tests/regex/censor_test.php b/tests/regex/censor_test.php
index 5a516b71de..6da6083e19 100644
--- a/tests/regex/censor_test.php
+++ b/tests/regex/censor_test.php
@@ -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);
}
}
diff --git a/tests/storage/adapter/local_subfolders_test.php b/tests/storage/adapter/local_subfolders_test.php
index 8421224098..33b232a131 100644
--- a/tests/storage/adapter/local_subfolders_test.php
+++ b/tests/storage/adapter/local_subfolders_test.php
@@ -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');
diff --git a/tests/storage/adapter/local_test.php b/tests/storage/adapter/local_test.php
index 5adee7d916..61d2e1d0c1 100644
--- a/tests/storage/adapter/local_test.php
+++ b/tests/storage/adapter/local_test.php
@@ -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
diff --git a/tests/template/template_test.php b/tests/template/template_test.php
index 73f897749f..8faa52d8ac 100644
--- a/tests/template/template_test.php
+++ b/tests/template/template_test.php
@@ -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);
diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php
index 98626865b0..030c8100ea 100644
--- a/tests/test_framework/phpbb_database_test_case.php
+++ b/tests/test_framework/phpbb_database_test_case.php
@@ -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);
- }
- }
}
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index 89f0762ded..a5b16082ff 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -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()
diff --git a/tests/test_framework/phpbb_test_case.php b/tests/test_framework/phpbb_test_case.php
index 56d8decbd8..11f9020e4f 100644
--- a/tests/test_framework/phpbb_test_case.php
+++ b/tests/test_framework/phpbb_test_case.php
@@ -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);
- }
- }
}
diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php
index 7e35c18332..5300b4c52d 100644
--- a/tests/text_formatter/s9e/factory_test.php
+++ b/tests/text_formatter/s9e/factory_test.php
@@ -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);
}
diff --git a/tests/upload/filespec_test.php b/tests/upload/filespec_test.php
index c501788829..887cfdee41 100644
--- a/tests/upload/filespec_test.php
+++ b/tests/upload/filespec_test.php
@@ -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;
}