1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Allow PHPUnit 9 (#3072)

* Allow PHPUnit 9

Had to add a couple of compatibility shims to keep tests the same.

* import method_exists()
This commit is contained in:
Bruce Weirdan 2020-04-06 00:25:00 +03:00 committed by GitHub
parent a1be95dc19
commit c50faeafee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 1 deletions

View File

@ -45,7 +45,7 @@
"brianium/paratest": "^4.0.0", "brianium/paratest": "^4.0.0",
"phpmyadmin/sql-parser": "5.1.0", "phpmyadmin/sql-parser": "5.1.0",
"phpspec/prophecy": ">=1.9.0", "phpspec/prophecy": ">=1.9.0",
"phpunit/phpunit": "^7.5.16 || ^8.5", "phpunit/phpunit": "^7.5.16 || ^8.5 || ^9.0",
"psalm/plugin-phpunit": "^0.9", "psalm/plugin-phpunit": "^0.9",
"slevomat/coding-standard": "^5.0", "slevomat/coding-standard": "^5.0",
"squizlabs/php_codesniffer": "^3.5", "squizlabs/php_codesniffer": "^3.5",

View File

@ -6,6 +6,7 @@ use function defined;
use const DIRECTORY_SEPARATOR; use const DIRECTORY_SEPARATOR;
use function getcwd; use function getcwd;
use function ini_set; use function ini_set;
use function method_exists;
use PHPUnit\Framework\TestCase as BaseTestCase; use PHPUnit\Framework\TestCase as BaseTestCase;
use Psalm\Config; use Psalm\Config;
use Psalm\Internal\Analyzer\FileAnalyzer; use Psalm\Internal\Analyzer\FileAnalyzer;
@ -153,4 +154,26 @@ class TestCase extends BaseTestCase
return $name; return $name;
} }
/**
* 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);
}
}
} }