Skip to content

Commit 04b56f6

Browse files
committed
Added test for PluginReferenceProvider
1 parent afbf781 commit 04b56f6

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

src/com/magento/idea/magento2plugin/reference/provider/PluginReferenceProvider.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.intellij.psi.PsiReference;
1313
import com.intellij.psi.PsiReferenceProvider;
1414
import com.intellij.psi.search.GlobalSearchScope;
15+
import com.intellij.psi.xml.XmlAttribute;
1516
import com.intellij.psi.xml.XmlTag;
1617
import com.intellij.util.ProcessingContext;
1718
import com.magento.idea.magento2plugin.indexes.PluginIndex;
@@ -47,9 +48,9 @@ public class PluginReferenceProvider extends PsiReferenceProvider {
4748
final XmlTag typeTag = (XmlTag) type.getParent().getParent();
4849
final XmlTag[] pluginTags = typeTag.findSubTags("plugin");
4950
for (final XmlTag pluginTag: pluginTags) {
50-
final String pluginName = pluginTag.getAttribute("name").getValue();
51-
if (pluginName.equals(originalPluginName)) {
52-
psiElements.add(pluginTag);
51+
final XmlAttribute pluginNameAttribute = pluginTag.getAttribute("name");
52+
if (pluginNameAttribute.getValue().equals(originalPluginName)) {
53+
psiElements.add(pluginNameAttribute.getValueElement());
5354
}
5455
}
5556
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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:ObjectManager/etc/config.xsd">
10+
<type name="Magento\Theme\Block\Html\Topmenu">
11+
<plugin name="catalogTopmenu<caret>" disabled="true"/>
12+
</type>
13+
</config>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
package com.magento.idea.magento2plugin.reference.xml;
7+
8+
import com.magento.idea.magento2plugin.magento.files.ModuleDiXml;
9+
10+
public class DisabledPluginReferenceRegistrarTest extends ReferenceXmlFixtureTestCase {
11+
12+
/**
13+
* Tests for disabled plugin name reference to original definition.
14+
*/
15+
public void testDisabledPluginNameMustHaveReference() {
16+
myFixture.configureByFile(this.getFixturePath(ModuleDiXml.FILE_NAME));
17+
18+
assertHasReferenceToXmlAttributeValue("catalogTopmenu");
19+
}
20+
}

0 commit comments

Comments
 (0)