diff --git a/rules-tests/CodeQuality/Rector/MethodCall/AssertEqualsToSameRector/Fixture/skip.php b/rules-tests/CodeQuality/Rector/MethodCall/AssertEqualsToSameRector/Fixture/skip.php deleted file mode 100644 index 1a7b0b71..00000000 --- a/rules-tests/CodeQuality/Rector/MethodCall/AssertEqualsToSameRector/Fixture/skip.php +++ /dev/null @@ -1,19 +0,0 @@ -assertEquals($expectedNull, $null); - - $bool = true; - $expectedBool = true; - $this->assertEquals($expectedBool, $bool); - } -} diff --git a/rules-tests/CodeQuality/Rector/MethodCall/FlipAssertRector/Fixture/cover_external_static_call.php.inc b/rules-tests/CodeQuality/Rector/MethodCall/FlipAssertRector/Fixture/cover_external_static_call.php.inc new file mode 100644 index 00000000..b46bac6e --- /dev/null +++ b/rules-tests/CodeQuality/Rector/MethodCall/FlipAssertRector/Fixture/cover_external_static_call.php.inc @@ -0,0 +1,33 @@ + +----- + diff --git a/src/Enum/PHPUnitClassName.php b/src/Enum/PHPUnitClassName.php new file mode 100644 index 00000000..51708c6a --- /dev/null +++ b/src/Enum/PHPUnitClassName.php @@ -0,0 +1,18 @@ +isInTestClass($node)) { - return false; + if ($node instanceof MethodCall) { + return $this->isInTestClass($node); + } + + if ($node instanceof StaticCall) { + $classType = $this->nodeTypeResolver->getType($node->class); + if ($classType instanceof ObjectType) { + if ($classType->isInstanceOf(PHPUnitClassName::TEST_CASE)->yes()) { + return true; + } + + if ($classType->isInstanceOf(PHPUnitClassName::ASSERT)->yes()) { + return true; + } + } } - return $node instanceof MethodCall || $node instanceof StaticCall; + return false; } }