diff --git a/rules-tests/AnnotationsToAttributes/Rector/ClassMethod/TestWithAnnotationToAttributeRector/Fixture/some_fixture_with_test_attribute.php.inc b/rules-tests/AnnotationsToAttributes/Rector/ClassMethod/TestWithAnnotationToAttributeRector/Fixture/some_fixture_with_test_attribute.php.inc new file mode 100644 index 00000000..40134aba --- /dev/null +++ b/rules-tests/AnnotationsToAttributes/Rector/ClassMethod/TestWithAnnotationToAttributeRector/Fixture/some_fixture_with_test_attribute.php.inc @@ -0,0 +1,37 @@ + +----- + diff --git a/rules-tests/PHPUnit60/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/test_in_annotation.php.inc b/rules-tests/PHPUnit60/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/test_in_annotation.php.inc index 1c1ea2e9..5659ec54 100644 --- a/rules-tests/PHPUnit60/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/test_in_annotation.php.inc +++ b/rules-tests/PHPUnit60/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/test_in_annotation.php.inc @@ -2,7 +2,7 @@ namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture; -class TestInAnnotatoin extends \PHPUnit\Framework\TestCase +class TestInAnnotation extends \PHPUnit\Framework\TestCase { /** * @test @@ -19,7 +19,7 @@ class TestInAnnotatoin extends \PHPUnit\Framework\TestCase namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture; -class TestInAnnotatoin extends \PHPUnit\Framework\TestCase +class TestInAnnotation extends \PHPUnit\Framework\TestCase { /** * @test diff --git a/rules-tests/PHPUnit60/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/test_in_annotation_with_test_attribute.php.inc b/rules-tests/PHPUnit60/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/test_in_annotation_with_test_attribute.php.inc new file mode 100644 index 00000000..6ea6d07a --- /dev/null +++ b/rules-tests/PHPUnit60/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/test_in_annotation_with_test_attribute.php.inc @@ -0,0 +1,32 @@ + +----- + diff --git a/src/NodeAnalyzer/TestsNodeAnalyzer.php b/src/NodeAnalyzer/TestsNodeAnalyzer.php index b3f726b2..3c4bce34 100644 --- a/src/NodeAnalyzer/TestsNodeAnalyzer.php +++ b/src/NodeAnalyzer/TestsNodeAnalyzer.php @@ -58,6 +58,14 @@ public function isTestClassMethod(ClassMethod $classMethod): bool return true; } + foreach ($classMethod->getAttrGroups() as $attributeGroup) { + foreach ($attributeGroup->attrs as $attribute) { + if ($attribute->name->toString() === 'PHPUnit\\Framework\\Attributes\\Test') { + return true; + } + } + } + $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod); return $phpDocInfo->hasByName('test'); }