Skip to content

Commit

Permalink
Added test for PluginReferenceProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
drpayyne committed Nov 5, 2020
1 parent afbf781 commit 5b0fad7
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.intellij.psi.PsiReference;
import com.intellij.psi.PsiReferenceProvider;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.xml.XmlAttribute;
import com.intellij.psi.xml.XmlTag;
import com.intellij.util.ProcessingContext;
import com.magento.idea.magento2plugin.indexes.PluginIndex;
Expand Down Expand Up @@ -47,9 +48,9 @@ public class PluginReferenceProvider extends PsiReferenceProvider {
final XmlTag typeTag = (XmlTag) type.getParent().getParent();
final XmlTag[] pluginTags = typeTag.findSubTags("plugin");
for (final XmlTag pluginTag: pluginTags) {
final String pluginName = pluginTag.getAttribute("name").getValue();
if (pluginName.equals(originalPluginName)) {
psiElements.add(pluginTag);
final XmlAttribute pluginNameAttribute = pluginTag.getAttribute("name");
if (pluginNameAttribute.getValue().equals(originalPluginName)) {
psiElements.add(pluginNameAttribute.getValueElement());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Theme\Block\Html\Topmenu">
<plugin name="catalogTopmenu<caret>" disabled="true"/>
</type>
</config>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

package com.magento.idea.magento2plugin.reference.xml;

import com.magento.idea.magento2plugin.magento.files.ModuleDiXml;

public class DisabledPluginReferenceRegistrarTest extends ReferenceXmlFixtureTestCase {
public void testDisabledPluginNameMustHaveReference() {
String filePath = this.getFixturePath(ModuleDiXml.FILE_NAME);
myFixture.configureByFile(filePath);

assertHasReferenceToXmlAttributeValue("catalogTopmenu");
}
}

0 comments on commit 5b0fad7

Please sign in to comment.