Skip to content

Commit 00cf140

Browse files
committed
Added unit test for Haehnchen#1599
1 parent 02f3e6c commit 00cf140

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/util/PhpElementsUtilTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.intellij.psi.PsiElement;
44
import com.intellij.util.containers.ContainerUtil;
5+
import com.jetbrains.php.PhpIndex;
56
import com.jetbrains.php.lang.PhpFileType;
67
import com.jetbrains.php.lang.psi.PhpPsiElementFactory;
78
import com.jetbrains.php.lang.psi.elements.*;
@@ -307,4 +308,20 @@ public void testThatPhpThatStringValueCanBeResolvedViaChainResolve() {
307308
assertContainsElements(PhpElementsUtil.StringResolver.findStringValues(PhpPsiElementFactory.createPhpPsiFromText(getProject(), ParameterList.class, "<?php $var = 'test.html'; foo($var);").getFirstPsiChild()), "test.html");
308309
assertContainsElements(PhpElementsUtil.StringResolver.findStringValues(PhpPsiElementFactory.createPhpPsiFromText(getProject(), TernaryExpression.class, "<?php $var = 'test.html'; $x = true == true ? $var : 'test2.html';")), "test.html", "test2.html");
309310
}
311+
312+
public void testGetImplementedMethodsForRecursiveClassHierarchy() {
313+
myFixture.addFileToProject("First.php", "<?php class First extends Second { public function method() {} }");
314+
myFixture.addFileToProject("Second.php", "<?php class Second extends First { public function method() {} }");
315+
316+
var firstClass = PhpIndex.getInstance(getProject()).getClassByName("First");
317+
var secondClass = PhpIndex.getInstance(getProject()).getClassByName("Second");
318+
319+
var actualResult = PhpElementsUtil.getImplementedMethods(
320+
secondClass.findOwnMethodByName("method")
321+
);
322+
323+
assertSize(2, actualResult);
324+
assertEquals(secondClass.findOwnMethodByName("method"), actualResult[0]);
325+
assertEquals(firstClass.findOwnMethodByName("method"), actualResult[1]);
326+
}
310327
}

0 commit comments

Comments
 (0)