File tree Expand file tree Collapse file tree 3 files changed +59
-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 +59
-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
+ @ SuppressWarnings ({"PMD.JUnitTestsShouldIncludeAssert" })
11
+ public class ObserverDeclarationInspectionTest extends InspectionXmlFixtureTestCase {
12
+
13
+ @ Override
14
+ public void setUp () throws Exception {
15
+ super .setUp ();
16
+ myFixture .enableInspections (ObserverDeclarationInspection .class );
17
+ }
18
+
19
+ /**
20
+ * Tests for duplicate observer name inspection warning in the same events.xml
21
+ */
22
+ public void testObserverNameUsedInSameFile () {
23
+ myFixture .configureByFile (getFixturePath (ModuleEventsXml .FILE_NAME ));
24
+ myFixture .testHighlighting (true , false , false );
25
+ }
26
+
27
+ /**
28
+ * Tests for duplicate observer name inspection warning in a different events.xml
29
+ */
30
+ public void testObserverNameUsedInDifferentFile () {
31
+ myFixture .configureByFile (getFixturePath (ModuleEventsXml .FILE_NAME ));
32
+ myFixture .testHighlighting (true , false , false );
33
+ }
34
+ }
You can’t perform that action at this time.
0 commit comments