Skip to content

Commit d566b4d

Browse files
committed
allow "setUpBeforeTest" to be a valid "setUp" method for checking property types Haehnchen#35
1 parent 53a9084 commit d566b4d

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
ideaVersion = IU-2019.2
2-
phpPluginVersion = 192.5728.108
1+
ideaVersion = IU-2020.1
2+
phpPluginVersion = 201.6668.153

src/main/java/de/espend/idea/php/phpunit/utils/ChainVisitorUtil.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,19 @@ private static PhpPsiElement resolveField(@NotNull FieldReference fieldReference
9898
Method methodScope = PhpPsiUtil.getParentByCondition(fieldReference, Method.INSTANCEOF);
9999
if(methodScope != null) {
100100
PhpClass phpClass = methodScope.getContainingClass();
101-
if(phpClass != null/* && PhpUnitPluginUtil.isTestClassWithoutIndexAccess(phpClass) */) {
102-
Method method = phpClass.findOwnMethodByName("setUp");
103-
104-
// "setUp" is our "constructor" for test classes
105-
if(method != null) {
106-
for (AssignmentExpression assignmentExpression : PsiTreeUtil.collectElementsOfType(method, AssignmentExpression.class)) {
107-
PhpPsiElement variable = assignmentExpression.getVariable();
108-
109-
// remember or field name and attach is for a later resolve
110-
if(variable instanceof FieldReference && name.equals(variable.getName())) {
111-
return assignmentExpression.getValue();
101+
if(phpClass != null) {
102+
for (String setupMethod : new String[]{"setUp", "setUpBeforeTest"}) {
103+
Method method = phpClass.findOwnMethodByName(setupMethod);
104+
105+
// "setUp" is our "constructor" for test classes
106+
if(method != null) {
107+
for (AssignmentExpression assignmentExpression : PsiTreeUtil.collectElementsOfType(method, AssignmentExpression.class)) {
108+
PhpPsiElement variable = assignmentExpression.getVariable();
109+
110+
// remember or field name and attach is for a later resolve
111+
if(variable instanceof FieldReference && name.equals(variable.getName())) {
112+
return assignmentExpression.getValue();
113+
}
112114
}
113115
}
114116
}

0 commit comments

Comments
 (0)