-
-
Notifications
You must be signed in to change notification settings - Fork 737
Closed
rectorphp/rector-phpunit
#582Labels
Description
Bug Report
| Subject | Details |
|---|---|
| Rector version | v2.2.7 |
---------- begin diff ----------
@@ @@
/**
* @param class-string<\Exception> $fqcn
* @return string
*/
private static function getExceptionMessage(string $fqcn): string
{
$exception = new $fqcn();
- assert($exception instanceof \Exception);
+ $this->assertInstanceOf(\Exception::class, $exception);
return $exception->getMessage();
}
----------- end diff -----------
Applied rules:
* AssertFuncCallToPHPUnitAssertRector
Minimal PHP Code Causing Issue
// inside PHPUnit's TestCase
/**
* @param class-string<\Exception> $fqcn
* @return list<string>
*/
private static function getExceptionMessage(string $fqcn): string
{
$exception = new $fqcn();
assert($exception instanceof \Exception);
return $exception->getMessage();
}Expected Behaviour
Highly Opinionated (sorry)
Do not change assert() calls into PHPUnit calls, as they have different goal: assert() calls often used as an extra validation/check layer and/or for static analysers, while PHPUnit assertions used for testing SUTs. Personally, I would disable AssertFuncCallToPHPUnitAssertRector rule on my projects.
calebdw