File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
rules/CodeQuality/Rector/ClassMethod Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ public function getNodeTypes(): array
7878 */
7979 public function refactor (Node $ node ): ?Node
8080 {
81- if (! $ this ->testsNodeAnalyzer ->isInTestClass ($ node )) {
81+ if (! $ this ->testsNodeAnalyzer ->isDirectlyExtendsTestCase ($ node )) {
8282 return null ;
8383 }
8484
Original file line number Diff line number Diff line change @@ -43,6 +43,27 @@ public function isInTestClass(Node $node): bool
4343 return false ;
4444 }
4545
46+ public function isDirectlyExtendsTestCase (Node $ node ): bool
47+ {
48+ $ classReflection = $ this ->reflectionResolver ->resolveClassReflection ($ node );
49+ if (! $ classReflection instanceof ClassReflection) {
50+ return false ;
51+ }
52+
53+ $ parents = $ classReflection ->getParents ();
54+ if ($ parents === []) {
55+ return false ;
56+ }
57+
58+ foreach (PHPUnitClassName::TEST_CLASSES as $ testCaseObjectClass ) {
59+ if ($ parents [0 ]->getName () === $ testCaseObjectClass ) {
60+ return true ;
61+ }
62+ }
63+
64+ return false ;
65+ }
66+
4667 public function isTestClassMethod (ClassMethod $ classMethod ): bool
4768 {
4869 if (! $ classMethod ->isPublic ()) {
You can’t perform that action at this time.
0 commit comments