diff --git a/tests/Config/PluginListTest.php b/tests/Config/PluginListTest.php index 1274eff9d44..52fce5d3bee 100644 --- a/tests/Config/PluginListTest.php +++ b/tests/Config/PluginListTest.php @@ -159,7 +159,7 @@ public function errorsOutWhenTryingToResolveUnknownPlugin(): void { $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 6fd8b4976f8..88099c63f1b 100644 --- a/tests/Config/PluginTest.php +++ b/tests/Config/PluginTest.php @@ -1156,7 +1156,7 @@ function output(array $build) {} $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 8ccc26002ed..f721041cab5 100644 --- a/tests/DocumentationTest.php +++ b/tests/DocumentationTest.php @@ -241,7 +241,7 @@ public function testInvalidCode($code, $error_message, $error_levels = [], $chec } $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 1f2bade4261..c9805f5898b 100644 --- a/tests/FileUpdates/ErrorAfterUpdateTest.php +++ b/tests/FileUpdates/ErrorAfterUpdateTest.php @@ -90,7 +90,7 @@ public function testErrorAfterUpdate( } $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 0f06ff7e6a0..bfbc4b5576d 100644 --- a/tests/IncludeTest.php +++ b/tests/IncludeTest.php @@ -88,7 +88,7 @@ public function testInvalidInclude( $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 4a33e603481..592c2d97e54 100644 --- a/tests/PsalmPluginTest.php +++ b/tests/PsalmPluginTest.php @@ -150,7 +150,7 @@ public function showsHelpForCommand(string $command): void $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 cfae0743390..75419f8a68d 100644 --- a/tests/TaintTest.php +++ b/tests/TaintTest.php @@ -50,7 +50,7 @@ public function testInvalidCode(string $code, string $error_message): void } $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 f48b50cc9c4..69502082e5b 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -24,7 +24,6 @@ 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 @@ protected function getTestName($withDataSet = true): string 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 0bbd2f46348..79573f75a28 100644 --- a/tests/Traits/InvalidCodeAnalysisTestTrait.php +++ b/tests/Traits/InvalidCodeAnalysisTestTrait.php @@ -7,7 +7,6 @@ use Psalm\Exception\CodeException; use function is_int; -use function method_exists; use function preg_quote; use function str_replace; use function strpos; @@ -81,11 +80,7 @@ public function testInvalidCode( $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 f913b121147..341de7fe61c 100644 --- a/tests/UnusedCodeTest.php +++ b/tests/UnusedCodeTest.php @@ -90,7 +90,7 @@ public function testInvalidCode($code, $error_message, $error_levels = []): void } $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 055be038db8..61fdb840fce 100644 --- a/tests/UnusedVariableTest.php +++ b/tests/UnusedVariableTest.php @@ -82,7 +82,7 @@ public function testInvalidCode($code, $error_message, $error_levels = []): void } $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';