This commit is contained in:
TomasVotruba 2018-01-03 19:03:34 +01:00
parent 87e207055c
commit 50d4d25d1c

View File

@ -30,6 +30,16 @@ final class DelegateExceptionArgumentsRector extends AbstractRector
'setExpectedExceptionRegExp' => 'expectExceptionMessageRegExp',
];
/**
* @var string[]
*/
private $phpUnitTestCaseClasses = [
// PHPUnit 6 and lower
'PHPUnit_Framework_TestCase',
// PHPUnit 5 and higher
'PHPUnit\Framework\TestCase',
];
/**
* @var MethodCallAnalyzer
*/
@ -39,29 +49,20 @@ final class DelegateExceptionArgumentsRector extends AbstractRector
* @var MethodCallNodeFactory
*/
private $methodCallNodeFactory;
/**
* @var Scoper
*/
private $scoper;
public function __construct(MethodCallAnalyzer $methodCallAnalyzer, MethodCallNodeFactory $methodCallNodeFactory, Scoper $scoper)
public function __construct(MethodCallAnalyzer $methodCallAnalyzer, MethodCallNodeFactory $methodCallNodeFactory)
{
$this->methodCallAnalyzer = $methodCallAnalyzer;
$this->methodCallNodeFactory = $methodCallNodeFactory;
$this->scoper = $scoper;
}
public function isCandidate(Node $node): bool
{
if (! $this->scoper->isInClassOfPhpUnitTestCase($node)) {
return false;
}
if (! $this->methodCallAnalyzer->isTypeAndMethods(
if (! $this->methodCallAnalyzer->isTypesAndMethods(
$node,
'PHPUnit\Framework\TestCase',
array_keys($this->oldToNewMethod)
)) {
$this->phpUnitTestCaseClasses,
array_keys($this->oldToNewMethod))
) {
return false;
}