Skip to content

Commit c48a75d

Browse files
committed
Fixed code by recommendation, added test
1 parent 030b66c commit c48a75d

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

src/com/magento/idea/magento2plugin/inspections/xml/ModuleDeclarationInModuleXmlInspection.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828

2929
public class ModuleDeclarationInModuleXmlInspection extends XmlSuppressableInspectionTool {
3030

31-
private static final String MODULE_NAME = "name";
32-
3331
@NotNull
3432
@Override
3533
public PsiElementVisitor buildVisitor(
@@ -58,7 +56,7 @@ public void visitXmlAttributeValue(final XmlAttributeValue value) {
5856
}
5957

6058
final String attributeName = XmlAttributeValuePattern.getLocalName(value);
61-
if (attributeName != null && attributeName.equals(MODULE_NAME)) {
59+
if (attributeName != null && attributeName.equals(ModuleXml.MODULE_ATTR_NAME)) {
6260
final String expectedName
6361
= GetEditableModuleNameByRootFileUtil.execute(etcDirectory);
6462
final String actualName = value.getValue();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
10+
<module name="Test_TestModule" setup_version="1.0.0" />
11+
</config>

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

+22
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class ModuleDeclarationInModuleXmlInspectionTest
1313
private static final String MESSAGE_ID =
1414
"inspection.moduleDeclaration.warning.wrongModuleName";
1515
private static final String WRONG_MODULE_NAME = "Wrong_ModuleName";
16+
private static final String SETUP_VERSION_ATTRIBUTE_VALUE = "1.0.0";
1617

1718
@Override
1819
public void setUp() throws Exception {
@@ -46,6 +47,27 @@ public void testWrongDeclarationInEditableModule() {
4647
assertHasHighlighting(errorMessage);
4748
}
4849

50+
/**
51+
* Inspection do not highlight wrong module name warning for setup version attribute.
52+
*/
53+
public void testSetupVersionNotErrorMessageInEditableModule() {
54+
final Settings settings = Settings.getInstance(myFixture.getProject());
55+
settings.magentoPath =
56+
"/src/xml/ModuleDeclarationInModuleXmlInspection/"
57+
+ "setupVersionNotErrorMessageInEditableModule";
58+
myFixture.configureByFile(
59+
getFixturePath("app/code/Test/TestModule/etc/" + ModuleXml.FILE_NAME)
60+
);
61+
62+
final String errorMessage = inspectionBundle.message(
63+
MESSAGE_ID,
64+
SETUP_VERSION_ATTRIBUTE_VALUE,
65+
"Test_TestModule"
66+
);
67+
68+
assertHasNoHighlighting(errorMessage);
69+
}
70+
4971
/**
5072
* Inspection skips sub tags.
5173
*/

0 commit comments

Comments
 (0)