@@ -176,14 +176,16 @@ private function createProductMock(): \PHPUnit_Framework_MockObject_MockObject
176
176
{
177
177
$ productMock = $ this ->getMockBuilder (\Magento \Catalog \Model \Product::class)
178
178
->disableOriginalConstructor ()
179
- ->setMethods ([
180
- 'getAttribute ' ,
181
- 'getId ' ,
182
- 'setQuoteItemQty ' ,
183
- 'setQuoteItemPrice ' ,
184
- 'getTypeId ' ,
185
- 'hasData ' ,
186
- ])
179
+ ->setMethods (
180
+ [
181
+ 'getAttribute ' ,
182
+ 'getId ' ,
183
+ 'setQuoteItemQty ' ,
184
+ 'setQuoteItemPrice ' ,
185
+ 'getTypeId ' ,
186
+ 'hasData ' ,
187
+ ]
188
+ )
187
189
->getMock ();
188
190
$ productMock
189
191
->expects ($ this ->any ())
@@ -223,4 +225,38 @@ public function testChildIsNotUsedForValidation()
223
225
224
226
$ this ->validatorPlugin ->beforeValidate ($ this ->validator , $ item );
225
227
}
228
+
229
+ /**
230
+ * Test for Configurable product in invalid state with no children does not raise error
231
+ */
232
+ public function testChildIsNotUsedForValidationWhenConfigurableProductIsMissingChildren ()
233
+ {
234
+ $ configurableProductMock = $ this ->createProductMock ();
235
+ $ configurableProductMock
236
+ ->expects ($ this ->any ())
237
+ ->method ('getTypeId ' )
238
+ ->willReturn (Configurable::TYPE_CODE );
239
+
240
+ $ configurableProductMock
241
+ ->expects ($ this ->any ())
242
+ ->method ('hasData ' )
243
+ ->with ($ this ->equalTo ('special_price ' ))
244
+ ->willReturn (false );
245
+
246
+ /* @var AbstractItem|\PHPUnit_Framework_MockObject_MockObject $item */
247
+ $ item = $ this ->getMockBuilder (AbstractItem::class)
248
+ ->disableOriginalConstructor ()
249
+ ->setMethods (['setProduct ' , 'getProduct ' , 'getChildren ' ])
250
+ ->getMockForAbstractClass ();
251
+ $ item ->expects ($ this ->any ())
252
+ ->method ('getProduct ' )
253
+ ->willReturn ($ configurableProductMock );
254
+ $ item ->expects ($ this ->any ())
255
+ ->method ('getChildren ' )
256
+ ->willReturn ([]);
257
+
258
+ $ this ->validator ->setAttribute ('special_price ' );
259
+
260
+ $ this ->validatorPlugin ->beforeValidate ($ this ->validator , $ item );
261
+ }
226
262
}
0 commit comments