Skip to content

Commit bab351a

Browse files
author
Vitaliy Boyko
committed
Refactored BaseProjectTestCase
1 parent 970c129 commit bab351a

File tree

5 files changed

+58
-46
lines changed

5 files changed

+58
-46
lines changed

tests/com/magento/idea/magento2plugin/BaseProjectTestCase.java

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,18 @@
44
*/
55
package com.magento.idea.magento2plugin;
66

7-
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
87
import com.intellij.openapi.util.text.StringUtil;
98
import com.intellij.testFramework.fixtures.BasePlatformTestCase;
10-
import com.magento.idea.magento2plugin.bundles.InspectionBundle;
119
import com.magento.idea.magento2plugin.indexes.IndexManager;
1210
import com.magento.idea.magento2plugin.project.Settings;
1311
import com.magento.idea.magento2plugin.magento.packages.File;
14-
import java.util.List;
1512

1613
/**
1714
* Configure test environment with Magento 2 project
1815
*/
1916
abstract public class BaseProjectTestCase extends BasePlatformTestCase {
2017
private static final String testDataProjectPath = "testData" + File.separator + "project";
2118
private static final String testDataProjectDirectory = "magento2";
22-
protected final InspectionBundle inspectionBundle = new InspectionBundle();
2319

2420
@Override
2521
protected void setUp() throws Exception {
@@ -69,38 +65,4 @@ private String name() {
6965
return StringUtil.trimEnd(getTestName(true), "Test");
7066
}
7167

72-
protected void assertHasHighlighting(String message) {
73-
String highlightingNotFound = "Failed that documents contains highlighting with the description `%s`";
74-
75-
List<HighlightInfo> highlightingList = myFixture.doHighlighting();
76-
if (highlightingList.isEmpty()) {
77-
fail(String.format(highlightingNotFound, message));
78-
}
79-
80-
for (HighlightInfo highlighting :
81-
highlightingList) {
82-
if (highlighting.getDescription() == null) continue;
83-
if (highlighting.getDescription().equals(message)) {
84-
return;
85-
}
86-
}
87-
fail(String.format(highlightingNotFound, message));
88-
}
89-
90-
protected void assertHasNoHighlighting(String message) {
91-
String highlightingNotFound = "Failed that documents not contains highlighting with the description `%s`";
92-
93-
List<HighlightInfo> highlightingList = myFixture.doHighlighting();
94-
if (highlightingList.isEmpty()) {
95-
return;
96-
}
97-
98-
for (HighlightInfo highlighting :
99-
highlightingList) {
100-
if (highlighting.getDescription() == null) continue;
101-
if (highlighting.getDescription().equals(message)) {
102-
fail(String.format(highlightingNotFound, message));
103-
}
104-
}
105-
}
10668
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
package com.magento.idea.magento2plugin.inspections;
6+
7+
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
8+
import com.magento.idea.magento2plugin.BaseProjectTestCase;
9+
import com.magento.idea.magento2plugin.bundles.InspectionBundle;
10+
import java.util.List;
11+
12+
/**
13+
* Configure test environment with Magento 2 project
14+
*/
15+
abstract public class BaseInspectionsTestCase extends BaseProjectTestCase {
16+
protected final InspectionBundle inspectionBundle = new InspectionBundle();
17+
18+
protected void assertHasHighlighting(String message) {
19+
String highlightingNotFound = "Failed that documents contains highlighting with the description `%s`";
20+
21+
List<HighlightInfo> highlightingList = myFixture.doHighlighting();
22+
if (highlightingList.isEmpty()) {
23+
fail(String.format(highlightingNotFound, message));
24+
}
25+
26+
for (HighlightInfo highlighting :
27+
highlightingList) {
28+
if (highlighting.getDescription() == null) continue;
29+
if (highlighting.getDescription().equals(message)) {
30+
return;
31+
}
32+
}
33+
fail(String.format(highlightingNotFound, message));
34+
}
35+
36+
protected void assertHasNoHighlighting(String message) {
37+
String highlightingNotFound = "Failed that documents not contains highlighting with the description `%s`";
38+
39+
List<HighlightInfo> highlightingList = myFixture.doHighlighting();
40+
if (highlightingList.isEmpty()) {
41+
return;
42+
}
43+
44+
for (HighlightInfo highlighting :
45+
highlightingList) {
46+
if (highlighting.getDescription() == null) continue;
47+
if (highlighting.getDescription().equals(message)) {
48+
fail(String.format(highlightingNotFound, message));
49+
}
50+
}
51+
}
52+
}

tests/com/magento/idea/magento2plugin/inspections/graphqls/InspectionGraphqlsFixtureTestCase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
package com.magento.idea.magento2plugin.inspections.graphqls;
77

8-
import com.magento.idea.magento2plugin.BaseProjectTestCase;
8+
import com.magento.idea.magento2plugin.inspections.BaseInspectionsTestCase;
99
import com.magento.idea.magento2plugin.magento.packages.File;
1010

11-
abstract public class InspectionGraphqlsFixtureTestCase extends BaseProjectTestCase {
11+
abstract public class InspectionGraphqlsFixtureTestCase extends BaseInspectionsTestCase {
1212

1313
private static final String testDataFolderPath = "testData" + File.separator + "inspections" + File.separator;
1414
private static final String fixturesFolderPath = "graphqls" + File.separator;

tests/com/magento/idea/magento2plugin/inspections/php/InspectionPhpFixtureTestCase.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
*/
55
package com.magento.idea.magento2plugin.inspections.php;
66

7-
import com.magento.idea.magento2plugin.BaseProjectTestCase;
7+
import com.magento.idea.magento2plugin.inspections.BaseInspectionsTestCase;
88
import com.magento.idea.magento2plugin.magento.packages.File;
9-
import java.util.List;
109

11-
abstract public class InspectionPhpFixtureTestCase extends BaseProjectTestCase {
10+
abstract public class InspectionPhpFixtureTestCase extends BaseInspectionsTestCase {
1211

1312
private static final String testDataFolderPath = "testData" + File.separator + "inspections" + File.separator;
1413
private static final String fixturesFolderPath = "php" + File.separator;

tests/com/magento/idea/magento2plugin/inspections/xml/InspectionXmlFixtureTestCase.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package com.magento.idea.magento2plugin.inspections.xml;
22

3-
import com.magento.idea.magento2plugin.BaseProjectTestCase;
4-
3+
import com.magento.idea.magento2plugin.inspections.BaseInspectionsTestCase;
54
import com.magento.idea.magento2plugin.magento.packages.File;
65

7-
abstract public class InspectionXmlFixtureTestCase extends BaseProjectTestCase {
6+
abstract public class InspectionXmlFixtureTestCase extends BaseInspectionsTestCase {
87

98
private static final String testDataFolderPath = "testData" + File.separator + "inspections" + File.separator;
109
private static final String fixturesFolderPath = "xml" + File.separator;

0 commit comments

Comments
 (0)