|
2 | 2 |
|
3 | 3 | import com.intellij.psi.PsiElement;
|
4 | 4 | import com.intellij.util.containers.ContainerUtil;
|
| 5 | +import com.jetbrains.php.PhpIndex; |
5 | 6 | import com.jetbrains.php.lang.PhpFileType;
|
6 | 7 | import com.jetbrains.php.lang.psi.PhpPsiElementFactory;
|
7 | 8 | import com.jetbrains.php.lang.psi.elements.*;
|
8 | 9 | import fr.adrienbrault.idea.symfony2plugin.tests.SymfonyLightCodeInsightFixtureTestCase;
|
9 | 10 | import fr.adrienbrault.idea.symfony2plugin.util.MethodMatcher;
|
10 | 11 | import fr.adrienbrault.idea.symfony2plugin.util.PhpElementsUtil;
|
11 | 12 |
|
12 |
| -import java.util.ArrayList; |
13 |
| -import java.util.Arrays; |
14 |
| -import java.util.Collection; |
15 |
| -import java.util.Collections; |
| 13 | +import java.util.*; |
16 | 14 |
|
17 | 15 | /**
|
18 | 16 | * @author Daniel Espendiller <daniel@espendiller.net>
|
@@ -307,4 +305,21 @@ public void testThatPhpThatStringValueCanBeResolvedViaChainResolve() {
|
307 | 305 | assertContainsElements(PhpElementsUtil.StringResolver.findStringValues(PhpPsiElementFactory.createPhpPsiFromText(getProject(), ParameterList.class, "<?php $var = 'test.html'; foo($var);").getFirstPsiChild()), "test.html");
|
308 | 306 | assertContainsElements(PhpElementsUtil.StringResolver.findStringValues(PhpPsiElementFactory.createPhpPsiFromText(getProject(), TernaryExpression.class, "<?php $var = 'test.html'; $x = true == true ? $var : 'test2.html';")), "test.html", "test2.html");
|
309 | 307 | }
|
| 308 | + |
| 309 | + public void testGetImplementedMethodsForRecursiveClassHierarchy() { |
| 310 | + myFixture.addFileToProject("First.php", "<?php class First extends Second { public function method() {} }"); |
| 311 | + myFixture.addFileToProject("Second.php", "<?php class Second extends First { public function method() {} }"); |
| 312 | + |
| 313 | + var firstClass = PhpIndex.getInstance(getProject()).getClassByName("First"); |
| 314 | + var secondClass = PhpIndex.getInstance(getProject()).getClassByName("Second"); |
| 315 | + |
| 316 | + var actualResult = PhpElementsUtil.getImplementedMethods( |
| 317 | + secondClass.findOwnMethodByName("method") |
| 318 | + ); |
| 319 | + |
| 320 | + assertEquals(new Method[] { |
| 321 | + secondClass.findOwnMethodByName("method"), |
| 322 | + firstClass.findOwnMethodByName("method") |
| 323 | + }, actualResult); |
| 324 | + } |
310 | 325 | }
|
0 commit comments