Skip to content

Commit

Permalink
Merge pull request #7435 from orklah/old-phpunit
Browse files Browse the repository at this point in the history
drop phpunit compatibility aliases
  • Loading branch information
orklah committed Jan 19, 2022
2 parents bbfdd57 + 7d07f42 commit 5c4be6b
Show file tree
Hide file tree
Showing 11 changed files with 10 additions and 38 deletions.
2 changes: 1 addition & 1 deletion tests/Config/PluginListTest.php
Expand Up @@ -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');
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Config/PluginTest.php
Expand Up @@ -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());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/DocumentationTest.php
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/FileUpdates/ErrorAfterUpdateTest.php
Expand Up @@ -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));

Expand Down
2 changes: 1 addition & 1 deletion tests/IncludeTest.php
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion tests/PsalmPluginTest.php
Expand Up @@ -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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/TaintTest.php
Expand Up @@ -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';

Expand Down
23 changes: 0 additions & 23 deletions tests/TestCase.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 1 addition & 6 deletions tests/Traits/InvalidCodeAnalysisTestTrait.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/UnusedCodeTest.php
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion tests/UnusedVariableTest.php
Expand Up @@ -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';

Expand Down

0 comments on commit 5c4be6b

Please sign in to comment.