forked from magento/magento2-phpstorm-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModuleDeclarationInModuleXmlInspectionTest.java
131 lines (111 loc) · 4.35 KB
/
ModuleDeclarationInModuleXmlInspectionTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
package com.magento.idea.magento2plugin.inspections.xml;
import com.magento.idea.magento2plugin.magento.files.ModuleXml;
import com.magento.idea.magento2plugin.project.Settings;
public class ModuleDeclarationInModuleXmlInspectionTest
extends InspectionXmlFixtureTestCase {
private static final String MESSAGE_ID =
"inspection.moduleDeclaration.warning.wrongModuleName";
private static final String WRONG_MODULE_NAME = "Wrong_ModuleName";
private static final String SETUP_VERSION_ATTRIBUTE_VALUE = "1.0.0";
@Override
public void setUp() throws Exception {
super.setUp();
myFixture.enableInspections(ModuleDeclarationInModuleXmlInspection.class);
}
@Override
protected boolean isWriteActionRequired() {
return false;
}
/**
* Inspection highlights warning in editable module.
*/
public void testWrongDeclarationInEditableModule() {
final Settings settings = Settings.getInstance(myFixture.getProject());
settings.magentoPath =
"/src/xml/ModuleDeclarationInModuleXmlInspection/"
+ "wrongDeclarationInEditableModule";
myFixture.configureByFile(
getFixturePath("app/code/Test/TestModule/etc/" + ModuleXml.FILE_NAME)
);
final String errorMessage = inspectionBundle.message(
MESSAGE_ID,
WRONG_MODULE_NAME,
"Test_TestModule"
);
assertHasHighlighting(errorMessage);
}
/**
* Inspection do not highlight wrong module name warning for setup version attribute.
*/
public void testSetupVersionNotErrorMessageInEditableModule() {
final Settings settings = Settings.getInstance(myFixture.getProject());
settings.magentoPath =
"/src/xml/ModuleDeclarationInModuleXmlInspection/"
+ "setupVersionNotErrorMessageInEditableModule";
myFixture.configureByFile(
getFixturePath("app/code/Test/TestModule/etc/" + ModuleXml.FILE_NAME)
);
final String errorMessage = inspectionBundle.message(
MESSAGE_ID,
SETUP_VERSION_ATTRIBUTE_VALUE,
"Test_TestModule"
);
assertHasNoHighlighting(errorMessage);
}
/**
* Inspection skips sub tags.
*/
public void testSubTagShouldNotBeHighlightedInEditableModule() {
final Settings settings = Settings.getInstance(myFixture.getProject());
settings.magentoPath =
"/src/xml/ModuleDeclarationInModuleXmlInspection/"
+ "wrongDeclarationInEditableModule";
myFixture.configureByFile(
getFixturePath("app/code/Test/TestModule/etc/" + ModuleXml.FILE_NAME)
);
final String errorMessage = inspectionBundle.message(
MESSAGE_ID,
WRONG_MODULE_NAME,
"Test_TestModule"
);
assertHasNoHighlighting(errorMessage);
}
/**
* Inspection skips warning in root.
*/
public void testWrongDeclarationInRoot() {
final Settings settings = Settings.getInstance(myFixture.getProject());
settings.magentoPath =
"/src/xml/ModuleDeclarationInModuleXmlInspection/wrongDeclarationInRoot";
myFixture.configureByFile(
getFixturePath("etc/" + ModuleXml.FILE_NAME)
);
final String errorMessage = inspectionBundle.message(
MESSAGE_ID,
WRONG_MODULE_NAME,
"WrongDeclarationInRoot_etc"
);
assertHasNoHighlighting(errorMessage);
}
/**
* Inspection skips warning in vendor.
*/
public void testWrongDeclarationInVendor() {
final Settings settings = Settings.getInstance(myFixture.getProject());
settings.magentoPath =
"/src/xml/ModuleDeclarationInModuleXmlInspection/wrongDeclarationInVendor";
myFixture.configureByFile(
getFixturePath("vendor/magento/module-catalog/etc/" + ModuleXml.FILE_NAME)
);
final String errorMessage = inspectionBundle.message(
MESSAGE_ID,
WRONG_MODULE_NAME,
"module-catalog_etc"
);
assertHasNoHighlighting(errorMessage);
}
}