@@ -147,39 +147,33 @@ public function testGetConfigCanShowConfig()
147
147
$ this ->assertTrue ($ this ->helper ->canShowConfig ('key2 ' ));
148
148
}
149
149
150
- /**
151
- * @param $attrCode
152
- * @param $attrClass
153
- * @param $customAttrClass
154
- * @param $result
155
- * @dataProvider getAttributeValidationClassDataProvider
156
- */
157
- public function testGetAttributeValidationClass ($ attrCode , $ attrClass , $ customAttrClass , $ result )
150
+ public function testGetAttributeValidationClass ()
158
151
{
159
- $ attributeMock = $ this -> getMockBuilder ( ' Magento\Customer\Api\Data\AttributeMetadataInterface ' )-> getMock () ;
160
- $ attributeMock -> expects ( $ this -> any ())-> method ( ' getFrontendClass ' )-> will ( $ this -> returnValue ( $ attrClass )) ;
152
+ $ attributeCode = ' attr_code ' ;
153
+ $ attributeClass = ' Attribute_Class ' ;
161
154
162
- $ customAttrMock = $ this ->getMockBuilder ('Magento\Customer\Api\Data\AttributeMetadataInterface ' )->getMock ();
163
- $ customAttrMock ->expects ($ this ->any ())->method ('isVisible ' )->will ($ this ->returnValue (true ));
164
- $ customAttrMock ->expects ($ this ->any ())->method ('getFrontendClass ' )->will ($ this ->returnValue ($ customAttrClass ));
165
-
166
- $ this ->customerMetadataService ->expects ($ this ->any ())
167
- ->method ('getAttributeMetadata ' )
168
- ->will ($ this ->returnValue ($ customAttrMock ));
155
+ $ attributeMock = $ this ->getMockBuilder ('Magento\Customer\Api\Data\AttributeMetadataInterface ' )
156
+ ->getMockForAbstractClass ();
157
+ $ attributeMock ->expects ($ this ->once ())
158
+ ->method ('getFrontendClass ' )
159
+ ->willReturn ($ attributeClass );
169
160
170
161
$ this ->addressMetadataService ->expects ($ this ->any ())
171
162
->method ('getAttributeMetadata ' )
172
- ->will ( $ this -> returnValue ( $ attributeMock) );
163
+ ->willReturn ( $ attributeMock );
173
164
174
- $ this ->assertEquals ($ result , $ this ->helper ->getAttributeValidationClass ($ attrCode ));
165
+ $ this ->assertEquals ($ attributeClass , $ this ->helper ->getAttributeValidationClass ($ attributeCode ));
175
166
}
176
167
177
- public function getAttributeValidationClassDataProvider ()
168
+ public function testGetAttributeValidationClassWithNoAttribute ()
178
169
{
179
- return [
180
- ['attr_code ' , 'Attribute_Class ' , '' , 'Attribute_Class ' ],
181
- ['firstname ' , 'Attribute_Class ' , 'Attribute2_Class ' , 'Attribute2_Class ' ],
182
- ];
170
+ $ attrCode = 'attr_code ' ;
171
+
172
+ $ this ->addressMetadataService ->expects ($ this ->any ())
173
+ ->method ('getAttributeMetadata ' )
174
+ ->willReturn (null );
175
+
176
+ $ this ->assertEquals ('' , $ this ->helper ->getAttributeValidationClass ($ attrCode ));
183
177
}
184
178
185
179
/**
0 commit comments