Skip to content

Commit 9a5672a

Browse files
committed
fixed PMD conflict and tests
1 parent d66ee46 commit 9a5672a

File tree

7 files changed

+83
-46
lines changed

7 files changed

+83
-46
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
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+
<preference for="" type="Foo\Bar\Model\Logger"/>
5+
</config>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
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+
<preference for="Foo\Bar\Model\Logger" type=""/>
5+
</config>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
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+
<preference for="Magento\Catalog\Api\ProductRepositoryInterface" type="Foo\Bar\Model\Logger"/>
5+
</config>

tests/com/magento/idea/magento2plugin/inspections/xml/PreferenceDeclarationInspectionTest.java

Lines changed: 68 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -31,45 +31,69 @@ public void setUp() throws Exception {
3131
}
3232

3333
/**
34-
* Test for the absence of an error in the presence of
35-
* classes or interfaces specified for preferences.
34+
* Test for an error for the "type" attribute because it is empty.
35+
* <preference for="" type="Foo\Bar\Model\Logger"/>
3636
*/
37-
public void testClassAttrForAndTypeAreExist() {
37+
public void testAttrArgForValuesIsEmpty() {
3838
configureFixture();
3939

40-
final String classOneExists = inspectionBundle.message(
41-
CLASS_DOES_NOT_EXIST,
42-
EXISTENT_CLASS_ONE
40+
final String forAttrIsEmptyMessage = inspectionBundle.message(
41+
ARGUMENT_VALUE_IS_EMPTY,
42+
ModuleDiXml.TYPE_ATTR
4343
);
4444

45-
assertHasNoHighlighting(classOneExists);
45+
assertHasHighlighting(forAttrIsEmptyMessage);
46+
}
4647

47-
final String classTwoExists = inspectionBundle.message(
48-
CLASS_DOES_NOT_EXIST,
49-
EXISTENT_CLASS_TWO
48+
/**
49+
* Test for an error for the "for" attribute because it is empty.
50+
* <preference for="Foo\Bar\Model\Logger" type=""/>
51+
*/
52+
public void testAttrArgTypeValueIsEmpty() {
53+
configureFixture();
54+
55+
final String forAttrIsEmptyMessage = inspectionBundle.message(
56+
ARGUMENT_VALUE_IS_EMPTY,
57+
ModuleDiXml.PREFERENCE_ATTR_FOR
5058
);
5159

52-
assertHasNoHighlighting(classTwoExists);
60+
assertHasHighlighting(forAttrIsEmptyMessage);
5361
}
5462

5563
/**
56-
* Test for throwing an error for a class that does not exist for the "for" attribute.
64+
* Test for an no error for the "for" attribute because this class exists.
65+
* <preference for="Foo\Bar\Model\Logger" type=""/>
5766
*/
58-
public void testClassAttrForDoesNotExists() {
67+
public void testAttrForClassExists() {
5968
configureFixture();
6069

61-
final String forClassDoesNotExists = inspectionBundle.message(
62-
CLASS_DOES_NOT_EXIST,
63-
NOT_EXISTENT_CLASS
70+
final String typeAttrIsEmptyMessage = inspectionBundle.message(
71+
ARGUMENT_VALUE_IS_EMPTY,
72+
ModuleDiXml.TYPE_ATTR
6473
);
6574

66-
assertHasHighlighting(forClassDoesNotExists);
75+
assertHasNoHighlighting(typeAttrIsEmptyMessage);
6776
}
6877

6978
/**
70-
* Test for throwing an error for a class that does not exist for the "type" attribute.
79+
* Test for an no error for the "type" attribute because this class exists.
80+
* <preference for="" type="Foo\Bar\Model\Logger"/>
7181
*/
72-
public void testClassAttrTypeDoesNotExists() {
82+
public void testAttrTypeClassExists() {
83+
configureFixture();
84+
85+
final String typeAttrIsEmptyMessage = inspectionBundle.message(
86+
ARGUMENT_VALUE_IS_EMPTY,
87+
ModuleDiXml.PREFERENCE_ATTR_FOR
88+
);
89+
90+
assertHasNoHighlighting(typeAttrIsEmptyMessage);
91+
}
92+
93+
/**
94+
* Test for throwing an error for a class that does not exist for the "for" attribute.
95+
*/
96+
public void testClassAttrForDoesNotExists() {
7397
configureFixture();
7498

7599
final String forClassDoesNotExists = inspectionBundle.message(
@@ -81,49 +105,47 @@ public void testClassAttrTypeDoesNotExists() {
81105
}
82106

83107
/**
84-
* Test for an error for the "type" attribute because it is empty and
85-
* there is no error "for" the for attribute because this class exists.
86-
* <preference for="Foo\Bar\Model\Logger" type=""/>
108+
* Test for the absence of an error in the presence of
109+
* classes or interfaces specified for preferences.
87110
*/
88-
public void testForAttrArgsValuesIsEmpty() {
111+
public void testClassAttrForIsExist() {
89112
configureFixture();
90113

91-
final String forAttrIsEmptyMessage = inspectionBundle.message(
92-
ARGUMENT_VALUE_IS_EMPTY,
93-
ModuleDiXml.PREFERENCE_ATTR_FOR
94-
);
95-
96-
assertHasHighlighting(forAttrIsEmptyMessage);
97-
98-
final String typeAttrIsEmptyMessage = inspectionBundle.message(
99-
ARGUMENT_VALUE_IS_EMPTY,
100-
ModuleDiXml.TYPE_ATTR
114+
final String classOneExists = inspectionBundle.message(
115+
CLASS_DOES_NOT_EXIST,
116+
EXISTENT_CLASS_ONE
101117
);
102118

103-
assertHasNoHighlighting(typeAttrIsEmptyMessage);
119+
assertHasNoHighlighting(classOneExists);
104120
}
105121

106122
/**
107-
* Test for an error for the "for" attribute because it is empty and
108-
* there is no error "type" the for attribute because this class exists.
109-
* <preference for="" type="Foo\Bar\Model\Logger"/>
123+
* Test for throwing an error for a class that does not exist for the "type" attribute.
110124
*/
111-
public void testTypeAttrArgsValuesIsEmpty() {
125+
public void testClassAttrTypeDoesNotExists() {
112126
configureFixture();
113127

114-
final String forAttrIsEmptyMessage = inspectionBundle.message(
115-
ARGUMENT_VALUE_IS_EMPTY,
116-
ModuleDiXml.TYPE_ATTR
128+
final String forClassDoesNotExists = inspectionBundle.message(
129+
CLASS_DOES_NOT_EXIST,
130+
NOT_EXISTENT_CLASS
117131
);
118132

119-
assertHasHighlighting(forAttrIsEmptyMessage);
133+
assertHasHighlighting(forClassDoesNotExists);
134+
}
120135

121-
final String typeAttrIsEmptyMessage = inspectionBundle.message(
122-
ARGUMENT_VALUE_IS_EMPTY,
123-
ModuleDiXml.PREFERENCE_ATTR_FOR
136+
/**
137+
* Test for the absence of an error in the presence of
138+
* classes or interfaces specified for preferences.
139+
*/
140+
public void testClassAttrTypeIsExist() {
141+
configureFixture();
142+
143+
final String classOneExists = inspectionBundle.message(
144+
CLASS_DOES_NOT_EXIST,
145+
EXISTENT_CLASS_TWO
124146
);
125147

126-
assertHasNoHighlighting(typeAttrIsEmptyMessage);
148+
assertHasNoHighlighting(classOneExists);
127149
}
128150

129151
private void configureFixture() {

0 commit comments

Comments
 (0)