File tree Expand file tree Collapse file tree 3 files changed +58
-0
lines changed
testData/inspections/xml/ObserverDeclarationInspection
observerNameUsedInDifferentFile
observerNameUsedInSameFile
tests/com/magento/idea/magento2plugin/inspections/xml Expand file tree Collapse file tree 3 files changed +58
-0
lines changed Original file line number Diff line number Diff line change 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 >
9+ <event name =" test_event_in_test_class" >
10+ <observer name =" test_observer" instance =" Magento\Catalog\Observer\TestObserver" />
11+ </event >
12+ </config >
Original file line number Diff line number Diff line change 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 >
9+ <event name =" some_random_event" >
10+ <observer name =" observer_one" instance =" Vendor\Module\Observer\Class" />
11+ <observer name =" observer_two" instance =" Vendor\Module\Observer\Class" />
12+ </event >
13+ </config >
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright © Magento, Inc. All rights reserved.
3+ * See COPYING.txt for license details.
4+ */
5+
6+ package com .magento .idea .magento2plugin .inspections .xml ;
7+
8+ import com .magento .idea .magento2plugin .magento .files .ModuleEventsXml ;
9+
10+ public class ObserverDeclarationInspectionTest extends InspectionXmlFixtureTestCase {
11+
12+ @ Override
13+ public void setUp () throws Exception {
14+ super .setUp ();
15+ myFixture .enableInspections (ObserverDeclarationInspection .class );
16+ }
17+
18+ /**
19+ * Tests for duplicate observer name inspection warning in the same events.xml
20+ */
21+ public void testObserverNameUsedInSameFile () {
22+ myFixture .configureByFile (getFixturePath (ModuleEventsXml .FILE_NAME ));
23+ myFixture .testHighlighting (true , false , false );
24+ }
25+
26+ /**
27+ * Tests for duplicate observer name inspection warning in a different events.xml
28+ */
29+ public void testObserverNameUsedInDifferentFile () {
30+ myFixture .configureByFile (getFixturePath (ModuleEventsXml .FILE_NAME ));
31+ myFixture .testHighlighting (true , false , false );
32+ }
33+ }
You can’t perform that action at this time.
0 commit comments