|
25 | 25 | import org.jetbrains.annotations.NotNull; |
26 | 26 | import org.jetbrains.annotations.Nullable; |
27 | 27 |
|
28 | | -import java.util.Arrays; |
29 | | -import java.util.stream.Stream; |
30 | | - |
31 | 28 | /** |
32 | 29 | * @author Daniel Espendiller <daniel@espendiller.net> |
33 | 30 | */ |
34 | 31 | public class PhpUnitPluginUtil { |
35 | | - private static final Stream<String> EXTENDS_TEST_CLASSES = Arrays.stream(new String[]{ |
| 32 | + private static final String[] EXTENDS_TEST_CLASSES = new String[]{ |
36 | 33 | "\\PHPUnit\\Framework\\TestCase", |
37 | 34 | "\\PHPUnit_Framework_TestCase", |
38 | 35 | "\\Symfony\\Bundle\\FrameworkBundle\\Test\\WebTestCase", |
39 | 36 | "\\Behat\\Behat\\Context\\BehatContext" |
40 | | - }); |
| 37 | + }; |
41 | 38 |
|
42 | 39 | /** |
43 | 40 | * Run tests for given element |
@@ -71,18 +68,18 @@ public static boolean isTestClassWithoutIndexAccess(@NotNull PhpClass phpClass) |
71 | 68 |
|
72 | 69 | // find "extends" classes |
73 | 70 | String superFQN = "\\" + StringUtils.stripStart(phpClass.getSuperFQN(), "\\"); |
74 | | - boolean isExtendsMatch = EXTENDS_TEST_CLASSES.anyMatch(s -> s.equalsIgnoreCase(superFQN)); |
75 | | - if (isExtendsMatch) { |
76 | | - return true; |
77 | | - } |
78 | 71 |
|
79 | | - // find via implementations |
80 | | - boolean isInterfaceMatch = Arrays.stream(phpClass.getInterfaceNames()) |
81 | | - .map(s -> "\\" + StringUtils.stripStart(s, "\\")) // normalize it |
82 | | - .anyMatch(s -> s.equalsIgnoreCase("\\Behat\\Behat\\Context\\Context")); |
| 72 | + for (String extendsTestClass : EXTENDS_TEST_CLASSES) { |
| 73 | + if (extendsTestClass.equalsIgnoreCase(superFQN)) { |
| 74 | + return true; |
| 75 | + } |
| 76 | + } |
83 | 77 |
|
84 | | - if (isInterfaceMatch) { |
85 | | - return true; |
| 78 | + for (String interfaceName : phpClass.getInterfaceNames()) { |
| 79 | + String interfaceName2 = "\\" + StringUtils.stripStart(interfaceName, "\\"); |
| 80 | + if (interfaceName2.equalsIgnoreCase("\\Behat\\Behat\\Context\\Context")) { |
| 81 | + return true; |
| 82 | + } |
86 | 83 | } |
87 | 84 |
|
88 | 85 | // find somehow inside a project test folder |
|
0 commit comments