diff --git a/tests/Config/PluginListTest.php b/tests/Config/PluginListTest.php index 1274eff9d..52fce5d3b 100644 --- a/tests/Config/PluginListTest.php +++ b/tests/Config/PluginListTest.php @@ -159,7 +159,7 @@ class PluginListTest extends TestCase { $plugin_list = new PluginList($this->config_file->reveal(), $this->composer_lock->reveal()); $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessageRegExp('/unknown plugin/i'); + $this->expectExceptionMessageMatches('/unknown plugin/i'); $plugin_list->resolvePluginClass('vendor/package'); } diff --git a/tests/Config/PluginTest.php b/tests/Config/PluginTest.php index 6fd8b4976..88099c63f 100644 --- a/tests/Config/PluginTest.php +++ b/tests/Config/PluginTest.php @@ -1156,7 +1156,7 @@ class PluginTest extends TestCase $this->project_analyzer->trackTaintedInputs(); $this->expectException(CodeException::class); - $this->expectExceptionMessageRegExp('/TaintedHtml/'); + $this->expectExceptionMessageMatches('/TaintedHtml/'); $this->analyzeFile($file_path, new Context()); } diff --git a/tests/DocumentationTest.php b/tests/DocumentationTest.php index 0c8ab29d2..99f04cacf 100644 --- a/tests/DocumentationTest.php +++ b/tests/DocumentationTest.php @@ -237,7 +237,7 @@ class DocumentationTest extends TestCase } $this->expectException(CodeException::class); - $this->expectExceptionMessageRegExp('/\b' . preg_quote($error_message, '/') . '\b/'); + $this->expectExceptionMessageMatches('/\b' . preg_quote($error_message, '/') . '\b/'); $codebase = $this->project_analyzer->getCodebase(); $codebase->config->visitPreloadedStubFiles($codebase); diff --git a/tests/FileUpdates/ErrorAfterUpdateTest.php b/tests/FileUpdates/ErrorAfterUpdateTest.php index 1f2bade42..c9805f589 100644 --- a/tests/FileUpdates/ErrorAfterUpdateTest.php +++ b/tests/FileUpdates/ErrorAfterUpdateTest.php @@ -90,7 +90,7 @@ class ErrorAfterUpdateTest extends TestCase } $this->expectException(CodeException::class); - $this->expectExceptionMessageRegExp('/\b' . preg_quote($error_message, '/') . '\b/'); + $this->expectExceptionMessageMatches('/\b' . preg_quote($error_message, '/') . '\b/'); $codebase->reloadFiles($this->project_analyzer, array_keys($end_files)); diff --git a/tests/IncludeTest.php b/tests/IncludeTest.php index 0f06ff7e6..bfbc4b557 100644 --- a/tests/IncludeTest.php +++ b/tests/IncludeTest.php @@ -88,7 +88,7 @@ class IncludeTest extends TestCase $config->skip_checks_on_unresolvable_includes = false; $this->expectException(CodeException::class); - $this->expectExceptionMessageRegExp('/\b' . preg_quote($error_message, '/') . '\b/'); + $this->expectExceptionMessageMatches('/\b' . preg_quote($error_message, '/') . '\b/'); $codebase->scanFiles(); diff --git a/tests/PsalmPluginTest.php b/tests/PsalmPluginTest.php index 4a33e6034..592c2d97e 100644 --- a/tests/PsalmPluginTest.php +++ b/tests/PsalmPluginTest.php @@ -150,7 +150,7 @@ class PsalmPluginTest extends TestCase $help_command = new CommandTester($this->app->find('help')); $help_command->execute(['command_name' => $command]); $output = $help_command->getDisplay(); - $this->assertRegExp('/Usage:.*$\s+' . preg_quote($command, '/') . '\b/m', $output); + $this->assertMatchesRegularExpression('/Usage:.*$\s+' . preg_quote($command, '/') . '\b/m', $output); } /** diff --git a/tests/TaintTest.php b/tests/TaintTest.php index cfae07433..75419f8a6 100644 --- a/tests/TaintTest.php +++ b/tests/TaintTest.php @@ -50,7 +50,7 @@ class TaintTest extends TestCase } $this->expectException(CodeException::class); - $this->expectExceptionMessageRegExp('/\b' . preg_quote($error_message, '/') . '\b/'); + $this->expectExceptionMessageMatches('/\b' . preg_quote($error_message, '/') . '\b/'); $file_path = self::$src_dir_path . 'somefile.php'; diff --git a/tests/TestCase.php b/tests/TestCase.php index f48b50cc9..69502082e 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -24,7 +24,6 @@ use function defined; use function getcwd; use function ini_set; use function is_string; -use function method_exists; use const ARRAY_FILTER_USE_KEY; use const DIRECTORY_SEPARATOR; @@ -153,28 +152,6 @@ class TestCase extends BaseTestCase return $this->getName($withDataSet); } - /** - * Compatibility alias - */ - public function expectExceptionMessageRegExp(string $regexp): void - { - if (method_exists($this, 'expectExceptionMessageMatches')) { - $this->expectExceptionMessageMatches($regexp); - } else { - /** @psalm-suppress UndefinedMethod */ - parent::expectExceptionMessageRegExp($regexp); - } - } - - public static function assertRegExp(string $pattern, string $string, string $message = ''): void - { - if (method_exists(self::class, 'assertMatchesRegularExpression')) { - self::assertMatchesRegularExpression($pattern, $string, $message); - } else { - parent::assertRegExp($pattern, $string, $message); - } - } - public static function assertArrayKeysAreStrings(array $array, string $message = ''): void { $validKeys = array_filter($array, 'is_string', ARRAY_FILTER_USE_KEY); diff --git a/tests/Traits/InvalidCodeAnalysisTestTrait.php b/tests/Traits/InvalidCodeAnalysisTestTrait.php index 0bbd2f463..daff91c92 100644 --- a/tests/Traits/InvalidCodeAnalysisTestTrait.php +++ b/tests/Traits/InvalidCodeAnalysisTestTrait.php @@ -81,11 +81,7 @@ trait InvalidCodeAnalysisTestTrait $this->expectException(CodeException::class); - if (method_exists($this, 'expectExceptionMessageMatches')) { - $this->expectExceptionMessageMatches('/\b' . preg_quote($error_message, '/') . '\b/'); - } else { - $this->expectExceptionMessageRegExp('/\b' . preg_quote($error_message, '/') . '\b/'); - } + $this->expectExceptionMessageMatches('/\b' . preg_quote($error_message, '/') . '\b/'); $codebase = $this->project_analyzer->getCodebase(); $codebase->config->visitPreloadedStubFiles($codebase); diff --git a/tests/UnusedCodeTest.php b/tests/UnusedCodeTest.php index f913b1211..341de7fe6 100644 --- a/tests/UnusedCodeTest.php +++ b/tests/UnusedCodeTest.php @@ -90,7 +90,7 @@ class UnusedCodeTest extends TestCase } $this->expectException(CodeException::class); - $this->expectExceptionMessageRegExp('/\b' . preg_quote($error_message, '/') . '\b/'); + $this->expectExceptionMessageMatches('/\b' . preg_quote($error_message, '/') . '\b/'); $file_path = self::$src_dir_path . 'somefile.php'; diff --git a/tests/UnusedVariableTest.php b/tests/UnusedVariableTest.php index 055be038d..61fdb840f 100644 --- a/tests/UnusedVariableTest.php +++ b/tests/UnusedVariableTest.php @@ -82,7 +82,7 @@ class UnusedVariableTest extends TestCase } $this->expectException(CodeException::class); - $this->expectExceptionMessageRegExp('/\b' . preg_quote($error_message, '/') . '\b/'); + $this->expectExceptionMessageMatches('/\b' . preg_quote($error_message, '/') . '\b/'); $file_path = self::$src_dir_path . 'somefile.php';