Skip to content

Commit 649b098

Browse files
authored
Merge pull request #407 from drpayyne/tests-10
Covered ObserverDeclarationInspection with tests
2 parents 31f0b0e + 201b17d commit 649b098

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-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: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
}

0 commit comments

Comments
 (0)