Skip to content

Commit 190015a

Browse files
committed
Added test for no sort order plugin generation case
1 parent 0a872ea commit 190015a

File tree

6 files changed

+44
-6
lines changed
  • testData/actions/generation/generator/PluginDiXmlGenerator
    • addTwoPluginsToOneDiXml
    • addTwoPluginsToOneTargetClass
    • generatePluginDiXmlFileForAdminhtmlArea
    • generatePluginDiXmlFileForBaseArea
    • generatePluginDiXmlFileWithoutSortOrder
  • tests/com/magento/idea/magento2plugin/actions/generation/generator

6 files changed

+44
-6
lines changed

testData/actions/generation/generator/PluginDiXmlGenerator/addTwoPluginsToOneDiXml/di.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
44
<type name="Foo\Bar\Model\PluginTargetClassOne">
55
<plugin name="test_plugin_name_1"
6-
type="Foo\Bar\Plugin\TestOnePlugin" sortOrder="10"/>
6+
type="Foo\Bar\Plugin\TestOnePlugin"
7+
sortOrder="10"/>
78
</type>
89
<type name="Foo\Bar\Model\PluginTargetClassTwo">
910
<plugin name="test_plugin_name_2"
10-
type="Foo\Bar\Plugin\TestTwoPlugin" sortOrder="20"/>
11+
type="Foo\Bar\Plugin\TestTwoPlugin"
12+
sortOrder="20"/>
1113
</type>
1214
</config>

testData/actions/generation/generator/PluginDiXmlGenerator/addTwoPluginsToOneTargetClass/di.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
44
<type name="Foo\Bar\Model\PluginTargetClassOne">
55
<plugin name="test_plugin_name_1"
6-
type="Foo\Bar\Plugin\TestOnePlugin" sortOrder="10"/>
6+
type="Foo\Bar\Plugin\TestOnePlugin"
7+
sortOrder="10"/>
78
<plugin name="test_plugin_name_2"
8-
type="Foo\Bar\Plugin\TestTwoPlugin" sortOrder="20"/>
9+
type="Foo\Bar\Plugin\TestTwoPlugin"
10+
sortOrder="20"/>
911
</type>
1012
</config>

testData/actions/generation/generator/PluginDiXmlGenerator/generatePluginDiXmlFileForAdminhtmlArea/di.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
44
<type name="Foo\Bar\Model\PluginTargetClassTwo">
55
<plugin name="test_plugin_name_2"
6-
type="Foo\Bar\Plugin\TestTwoPlugin" sortOrder="20"/>
6+
type="Foo\Bar\Plugin\TestTwoPlugin"
7+
sortOrder="20"/>
78
</type>
89
</config>

testData/actions/generation/generator/PluginDiXmlGenerator/generatePluginDiXmlFileForBaseArea/di.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
44
<type name="Foo\Bar\Model\PluginTargetClassOne">
55
<plugin name="test_plugin_name_1"
6-
type="Foo\Bar\Plugin\TestOnePlugin" sortOrder="10"/>
6+
type="Foo\Bar\Plugin\TestOnePlugin"
7+
sortOrder="10"/>
78
</type>
89
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0"?>
2+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
4+
<type name="Foo\Bar\Model\PluginTargetClassOne">
5+
<plugin name="test_plugin_name_1"
6+
type="Foo\Bar\Plugin\TestOnePlugin"/>
7+
</type>
8+
</config>

tests/com/magento/idea/magento2plugin/actions/generation/generator/PluginDiXmlGeneratorTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,30 @@ public class PluginDiXmlGeneratorTest extends BaseGeneratorTestCase {
2525
private static final String MODULE = "Foo_Bar";
2626
private static final String MODULE_DIR = "src/app/code/Foo/Bar/";
2727

28+
/**
29+
* Test checks whether di.xml is generated correctly for the base area
30+
*/
31+
public void testGeneratePluginDiXmlFileWithoutSortOrder() {
32+
final PsiFile expectedFile = myFixture.configureByFile(
33+
this.getFixturePath(ModuleDiXml.FILE_NAME)
34+
);
35+
final String area = Areas.base.toString();
36+
37+
final PsiFile diXml = addPluginDiXml(
38+
PLUGIN_TARGET_CLASS_ONE_FNQ,
39+
area,
40+
"",
41+
"test_plugin_name_1",
42+
PLUGIN_CLASS_ONE_FNQ
43+
);
44+
45+
assertGeneratedFileIsCorrect(
46+
expectedFile,
47+
getExpectedDirectory(area),
48+
diXml
49+
);
50+
}
51+
2852
/**
2953
* Test checks whether di.xml is generated correctly for the base area
3054
*/

0 commit comments

Comments
 (0)