Skip to content

Commit 00cf658

Browse files
committed
Covered ObserverDeclarationInspection with tests
1 parent 0dfc0b3 commit 00cf658

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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>
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>
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>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
}

0 commit comments

Comments
 (0)